How to integrate Dynamics365 MCP with Claude Code

Connect Claude Code to Dynamics365 MCP. Create a new sales lead for acme corp, list all open invoices for this quarter, and more using natural language, with authentication handled for you.

Dynamics365 logoDynamics365
Oauth2

Dynamics 365 is Microsoft's platform combining CRM, ERP, and productivity apps. It streamlines sales, marketing, service, and operations in one place.

119 Tools

Introduction

Manage your Dynamics365 directly from Claude Code with zero worries about OAuth hassles, API-breaking issues, or reliability and security concerns.

You can do this in two different ways:

  1. Via Composio Connect - Direct and easiest approach
  2. Via Composio SDK - Programmatic approach with more control

For exact tool slugs and parameter tables, see the tool catalog in the Composio docs.

Also integrate Dynamics365 with

Why use Composio?

  • Only one MCP URL to connect multiple apps with Claude Code with zero auth hassles.
  • Programmatic tool calling allows LLMs to write its code in a remote workbench to handle complex tool chaining. Reduces to-and-fro with LLMs for frequent tool calling.
  • Handling Large tool responses out of LLM context to minimize context rot.
  • Dynamic just-in-time access to 20,000 tools across 1700+ other Apps for cross-app workflows. It loads the tools you need, so LLMs aren't overwhelmed by tools you don't need.

Connecting Dynamics365 to Claude Code using Composio

1. Add the Composio MCP to Claude

Terminal

2. Start Claude Code

bash
claude

3. Open your MCP list

bash
/mcp

4. Select Composio and click on Authenticate

Select Composio and click Authenticate

5. This will redirect you to the Composio OAuth page. Complete the flow by authorizing Composio and you're all set.

Composio OAuth authorization page
Composio authorization complete
Ask Claude to connect to your account and authenticate via the link

What is the Dynamics365 MCP server, and what's possible with it?

The Dynamics 365 MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Dynamics 365 account. It provides structured and secure access to your CRM records, so your agent can create accounts and contacts, manage leads and opportunities, handle customer cases, and process invoices and sales orders on your behalf.

  • Account and contact creation: Have your agent create new customer accounts and contact records in Dynamics 365.
  • Lead and opportunity management: Let the agent create leads and opportunities, retrieve lead details, list all leads, and update records as deals progress.
  • Customer case handling: Direct your agent to open new customer cases and update existing cases as issues move toward resolution.
  • Invoice management: Instruct your agent to create invoices, retrieve individual invoices or a full invoice list, and update invoice details.
  • Sales order processing: Have your agent create sales orders and update them when order information changes.

Connecting Dynamics365 via Composio SDK

Composio SDK is the underlying technology that powers these integrations. It provides a universal gateway with full programmatic control. You can programmatically generate an MCP URL with the app you need (here Dynamics365) for even more tool search precision. It's secure and reliable.

How the Composio SDK works

The Composio SDK follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Step by step10 STEPS
1

Prerequisites

Before starting, make sure you have:
  • Claude Pro, Max, or API billing enabled Anthropic account
  • Composio API Key
  • A Dynamics365 account
  • Basic knowledge of Python or TypeScript
2

Install Claude Code

bash
# macOS, Linux, WSL
curl -fsSL https://claude.ai/install.sh | bash

# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

To install Claude Code, use one of the following methods based on your operating system:

3

Set up Claude Code

bash
cd your-project-folder
claude

Open a terminal, go to your project folder, and start Claude Code:

  • Claude Code will open in your terminal
  • Follow the prompts to sign in with your Anthropic account
  • Complete the authentication flow
  • Once authenticated, you can start using Claude Code
Claude Code initial setup showing sign-in prompt
Claude Code terminal after successful login
4

Set up environment variables

bash
COMPOSIO_API_KEY=your_composio_api_key_here
USER_ID=your_user_id_here

Create a .env file in your project root with the following variables:

  • COMPOSIO_API_KEY authenticates with Composio (get it from Composio dashboard)
  • USER_ID identifies the user for session management (use any unique identifier)
5

Install Composio library

npm install @composio/core dotenv

Install the Composio TypeScript library to create MCP sessions.

  • @composio/core provides the core Composio functionality
  • dotenv loads environment variables from your .env file
6

Generate Composio MCP URL

import 'dotenv/config';
import { Composio } from '@composio/core';

const { COMPOSIO_API_KEY, USER_ID } = process.env;

if (!COMPOSIO_API_KEY || !USER_ID) {
  throw new Error('COMPOSIO_API_KEY and USER_ID required in .env');
}

const composioClient = new Composio({ apiKey: COMPOSIO_API_KEY });

const composioSession = await composioClient.create(USER_ID, {
  toolkits: ['dynamics365'],
});

const composioMcpUrl = composioSession?.mcp.url;

console.log(`MCP URL: ${composioMcpUrl}`);
console.log(`\nUse this command to add to Claude Code:`);
console.log(`claude mcp add --transport http dynamics365-composio "${composioMcpUrl}" --headers "X-API-Key:${COMPOSIO_API_KEY}"`);

Create a script to generate a Composio MCP URL for Dynamics365. This URL will be used to connect Claude Code to Dynamics365.

What's happening

  • We import the Composio client and load environment variables
  • Create a Composio instance with your API key
  • Call create() to create a Tool Router session for Dynamics365
  • The returned mcp.url is the MCP server URL that Claude Code will use
  • The script prints this URL so you can copy it
7

Run the script and copy the MCP URL

node --loader ts-node/esm generate_mcp_url.ts
# or if using tsx
tsx generate_mcp_url.ts

Run your TypeScript script to generate the MCP URL.

  • The script connects to Composio and creates a Tool Router session
  • It prints the MCP URL and the exact command you need to run
  • Copy the entire claude mcp add command from the output
8

Add Dynamics365 MCP to Claude Code

bash
claude mcp add --transport http dynamics365-composio "YOUR_MCP_URL_HERE" --headers "X-API-Key:YOUR_COMPOSIO_API_KEY"

# Then restart Claude Code
exit
claude

In your terminal, add the MCP server using the command from the previous step. The command format is:

  • claude mcp add registers a new MCP server with Claude Code
  • --transport http specifies that this is an HTTP-based MCP server
  • The server name (dynamics365-composio) is how you'll reference it
  • The URL points to your Composio Tool Router session
  • --headers includes your Composio API key for authentication

After running the command, close the current Claude Code session and start a new one for the changes to take effect.

9

Verify the installation

bash
claude mcp list

Check that your Dynamics365 MCP server is properly configured.

  • This command lists all MCP servers registered with Claude Code
  • You should see your dynamics365-composio entry in the list
  • This confirms that Claude Code can now access Dynamics365 tools

If everything is wired up, you should see your dynamics365-composio entry listed:

Claude Code MCP list showing the toolkit MCP server
10

Authenticate Dynamics365

The first time you try to use Dynamics365 tools, you'll be prompted to authenticate.

  • Claude Code will detect that you need to authenticate with Dynamics365
  • It will show you an authentication link
  • Open the link in your browser (or copy/paste it)
  • Complete the Dynamics365 authorization flow
  • Return to the terminal and start using Dynamics365 through Claude Code

Once authenticated, you can ask Claude Code to perform Dynamics365 operations in natural language. For example:

  • "Create a new sales lead for Acme Corp"
  • "List all open invoices for this quarter"
  • "Add a support case for a specific customer"

Complete Code

Here's the complete code to get you started with Dynamics365 and Claude Code:

import 'dotenv/config';
import { Composio } from '@composio/core';

const { COMPOSIO_API_KEY, USER_ID } = process.env;

if (!COMPOSIO_API_KEY || !USER_ID) {
  throw new Error('COMPOSIO_API_KEY and USER_ID required in .env');
}

const composioClient = new Composio({ apiKey: COMPOSIO_API_KEY });

const composioSession = await composioClient.create(USER_ID, {
  toolkits: ['dynamics365'],
});

const composioMcpUrl = composioSession?.mcp.url;

console.log(`MCP URL: ${composioMcpUrl}`);
console.log(`\nUse this command to add to Claude Code:`);
console.log(`claude mcp add --transport http dynamics365-composio "${composioMcpUrl}" --headers "X-API-Key:${COMPOSIO_API_KEY}"`);

Conclusion

You've successfully integrated Dynamics365 with Claude Code using Composio's MCP server. Now you can interact with Dynamics365 directly from your terminal using natural language commands.

Key features of this setup:

  • Terminal-native experience without switching contexts
  • Natural language commands for Dynamics365 operations
  • Secure authentication through Composio's managed MCP
  • Tool Router for dynamic tool discovery and execution

Next steps:

  • Try asking Claude Code to perform various Dynamics365 operations
  • Add more toolkits to your Tool Router session for multi-app workflows
  • Integrate this setup into your development workflow for increased productivity

You can extend this by adding more toolkits, implementing custom workflows, or building automation scripts that leverage Claude Code's capabilities.

TOOLS

Supported Tools

Every Dynamics365 action and event your agent gets out of the box.

Add Contact to Account

Associate an existing contact with an existing account in Dynamics 365.

Assign User Security Role

Assign a security role to a system user in the connected Dataverse environment.

Associate Contact Account

Sets an existing contact's parent account, replacing any current parent customer.

Clear Account Description

Clear an existing account's description to null without deleting the account.

Create Annotation

Create a text or attachment note, optionally linked to a supported record.

Create appointment

Create a Dataverse appointment from writable logical column values and return the created row.

Create Email Activity

Create and store a draft email activity without sending it.

Create invoice line item

Create a Dataverse invoice line item from writable logical column values and return the created row.

Create opportunity line item

Create a Dataverse opportunity line item from writable logical column values and return the created row.

Create Phone Call

Record a CRM phone-call activity; this does not place a telephone call.

Create price list

Create a Dataverse price list from writable logical column values and return the created row.

Create Product

Create a Dataverse catalog product and return its selected representation.

Create Product Price List Item

Add an existing product and unit to an existing Dynamics price list.

Create quote

Create a Dataverse quote from writable logical column values and return the created row.

Create quote line item

Create a Dataverse quote line item from writable logical column values and return the created row.

Create sales order line item

Create a Dataverse sales order line item from writable logical column values and return the created row.

Create Social Activity

Create a Dataverse social activity and return its stored representation.

Create system user

Create a Dataverse system user from writable logical column values and return the created row.

Create Task

Create a Dataverse task activity and return its selected representation.

Create transaction currency

Create a Dataverse transaction currency from writable logical column values and return the created row.

Delete account

Delete a Dataverse account by GUID.

Delete appointment

Delete a Dataverse appointment by GUID.

Delete case

Delete a Dataverse case by GUID.

Delete contact

Delete a Dataverse contact by GUID.

Delete email activity

Delete a Dataverse email activity by GUID.

Delete invoice

Delete a Dataverse invoice by GUID.

Delete invoice line item

Delete a Dataverse invoice line item by GUID.

Delete lead

Delete a Dataverse lead by GUID.

Delete note

Delete a Dataverse note by GUID.

Delete opportunity

Delete a Dataverse opportunity by GUID.

Delete opportunity line item

Delete a Dataverse opportunity line item by GUID.

Delete price list

Delete a Dataverse price list by GUID.

Delete product

Delete a Dataverse product by GUID.

Delete quote

Delete a Dataverse quote by GUID.

Delete quote line item

Delete a Dataverse quote line item by GUID.

Delete sales order

Delete a Dataverse sales order by GUID.

Delete sales order line item

Delete a Dataverse sales order line item by GUID.

Delete system user

Request deletion of a Dataverse system user by GUID.

Delete task

Delete a Dataverse task by GUID.

Delete transaction currency

Delete a Dataverse transaction currency by GUID.

Disassociate Contact Account

Remove a contact's parent account relationship without deleting either record.

Create Account

Creates a new account entity record in Dynamics CRM using the Web API.

Create Case

Creates a new case (incident) in Dynamics CRM using the Web API.

Create Contact

Creates a new contact entity record in Dynamics CRM using the Web API.

Create Invoice

Creates a new invoice entity record in Dynamics CRM using the Web API.

Create Lead

Creates a new lead entity record in Dynamics CRM using the Web API.

Create Opportunity

Creates a new opportunity entity record in Dynamics CRM using the Web API.

Create Sales Order

Creates a new sales order entity record in Dynamics CRM using the Web API.

Dynamicscrm get a invoice

Retrieve a Dynamics CRM invoice by ID, returning selected invoice details such as its number, dates, billing and shipping addresses, amounts and status.

Dynamicscrm get a lead

Dynamicscrm get a lead

Dynamicscrm get all leads

Retrieve one page of Dynamics CRM leads with optional OData query options.

Update Case

Updates a case (incident) in Dynamics CRM using the Web API.

Update Invoice

Update a Dynamics CRM invoice by ID using the Web API.

Update Lead

Updates an existing Dynamics CRM lead using the Web API.

Update Opportunity

Updates an existing Dynamics CRM opportunity using the Web API.

Update Sales Order

Updates an existing Dynamics CRM sales order using the Web API.

Execute Batch

Execute a Dataverse multipart batch, optionally containing atomic change sets.

Get account

Retrieve a Dataverse account by its GUID, optionally selecting columns and expanding relationships.

Get all invoices action

Retrieve one page of Dynamics 365 invoices with optional OData query options.

Get appointment

Retrieve a Dataverse appointment by its GUID, optionally selecting columns and expanding relationships.

Get Attribute Metadata

Retrieve one Dataverse attribute definition by its metadata IDs.

Get case

Retrieve a Dataverse case by its GUID, optionally selecting columns and expanding relationships.

Get contact

Retrieve a Dataverse contact by its GUID, optionally selecting columns and expanding relationships.

Get email activity

Retrieve a Dataverse email activity by its GUID, optionally selecting columns and expanding relationships.

Get invoice line item

Retrieve a Dataverse invoice line item by its GUID, optionally selecting columns and expanding relationships.

Get note

Retrieve a Dataverse note by its GUID, optionally selecting columns and expanding relationships.

Get opportunity

Retrieve a Dataverse opportunity by its GUID, optionally selecting columns and expanding relationships.

Get opportunity line item

Retrieve a Dataverse opportunity line item by its GUID, optionally selecting columns and expanding relationships.

Get price list

Retrieve a Dataverse price list by its GUID, optionally selecting columns and expanding relationships.

Get product

Retrieve a Dataverse product by its GUID, optionally selecting columns and expanding relationships.

Get quote

Retrieve a Dataverse quote by its GUID, optionally selecting columns and expanding relationships.

Get quote line item

Retrieve a Dataverse quote line item by its GUID, optionally selecting columns and expanding relationships.

Get sales order

Retrieve a Dataverse sales order by its GUID, optionally selecting columns and expanding relationships.

Get sales order line item

Retrieve a Dataverse sales order line item by its GUID, optionally selecting columns and expanding relationships.

Get system user

Retrieve a Dataverse system user by its GUID, optionally selecting columns and expanding relationships.

Get task

Retrieve a Dataverse task by its GUID, optionally selecting columns and expanding relationships.

Get transaction currency

Retrieve a Dataverse transaction currency by its GUID, optionally selecting columns and expanding relationships.

List appointments

List one page of Dataverse appointments.

List Entity Definitions

Discover Dataverse table definitions and return caller-selected metadata.

List entity sets

List available Dataverse entity sets and their resource URLs, not table rows.

List invoice line items

List one page of Dataverse invoice line items.

List notes

List one page of Dataverse notes.

List opportunity line items

List one page of Dataverse opportunity line items.

List price lists

List one page of Dataverse price lists.

List products

List one page of Dataverse products.

List quote line items

List one page of Dataverse quote line items.

List quotes

List one page of Dataverse quotes.

List sales orders

List one page of Dataverse sales orders.

List system users

List one page of Dataverse system users.

List transaction currencies

List one page of Dataverse transaction currencies.

Query accounts

List or filter Dynamics accounts with projection, ordering, and bounded results.

Query campaigns

List, filter, expand, or aggregate Dynamics campaigns.

Query cases

Return one bounded page of cases; pass next_link back to fetch the next page.

Query contacts

List or filter Dynamics contacts with selected fields and ordering.

Query email activities

Return one bounded page of email activities; pass next_link back to fetch the next page.

Query Entity Data

Query contacts, incidents, phone calls, activity pointers, opportunities, or sales order details and return one page with its next link.

Query opportunities

Return one bounded page of opportunities; pass next_link back to fetch the next page.

Query phone calls

Return one bounded page of phone-call activities; pass next_link back to fetch the next page.

Query social activities

Return one bounded page of social activities; pass next_link back to fetch the next page.

Query tasks

Return one bounded page of tasks; pass next_link back to fetch the next page.

Remove Contact from Account

Remove an existing contact from an account without deleting either record.

Resolve Case

Resolve an active case by creating its incident-resolution activity.

Update account

Update only the supplied writable columns of an existing Dataverse account and return the updated row.

Update Account Name

Updates only the name of an existing Dynamics 365 account.

Update appointment

Update only the supplied writable columns of an existing Dataverse appointment and return the updated row.

Update contact

Update only the supplied writable columns of an existing Dataverse contact and return the updated row.

Update email activity

Update only the supplied writable columns of an existing Dataverse email activity and return the updated row.

Update invoice line item

Update only the supplied writable columns of an existing Dataverse invoice line item and return the updated row.

Update note

Update only the supplied writable columns of an existing Dataverse note and return the updated row.

Update opportunity line item

Update only the supplied writable columns of an existing Dataverse opportunity line item and return the updated row.

Update price list

Update only the supplied writable columns of an existing Dataverse price list and return the updated row.

Update product

Update only the supplied writable columns of an existing Dataverse product and return the updated row.

Update quote

Update only the supplied writable columns of an existing Dataverse quote and return the updated row.

Update quote line item

Update only the supplied writable columns of an existing Dataverse quote line item and return the updated row.

Update sales order line item

Update only the supplied writable columns of an existing Dataverse sales order line item and return the updated row.

Update system user

Update only the supplied writable columns of an existing Dataverse system user and return the updated row.

Update task

Update only the supplied writable columns of an existing Dataverse task and return the updated row.

Update transaction currency

Update only the supplied writable columns of an existing Dataverse transaction currency and return the updated row.

Get Caller Identity

Return the connected Dataverse caller's identity IDs.

FAQ

Frequently asked questions

Start with Dynamics365.It takes 30 seconds.

Managed auth, hosted MCP servers, and every Dynamics365 tool your agent needs.Free to start.

Start building