How to integrate Dynamics365 MCP with Google ADK

Connect Google ADK 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

This guide walks you through connecting Dynamics365 to Google ADK using the Composio tool router. By the end, you'll have a working Dynamics365 agent that can manage accounts and contacts, capture leads, track opportunities, create quotes and invoices, and resolve support cases through natural language commands.

This guide will help you understand how to give your Google ADK agent real control over a Dynamics365 account through Composio's Dynamics365 MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

Also integrate Dynamics365 with

TL;DR

Here's what you'll learn:
  • Get a Dynamics365 account set up and connected to Composio
  • Install the Google ADK and Composio packages
  • Create a Composio Tool Router session for Dynamics365
  • Build an agent that connects to Dynamics365 through MCP
  • Interact with Dynamics365 using natural language

What is Google ADK?

Google ADK (Agents Development Kit) is Google's framework for building AI agents powered by Gemini models. It provides tools for creating agents that can use external services through the Model Context Protocol.

Key features include:

  • Gemini Integration: Native support for Google's Gemini models
  • MCP Toolset: Built-in support for Model Context Protocol tools
  • Streamable HTTP: Connect to external services through streamable HTTP
  • CLI and Web UI: Run agents via command line or web interface

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.

What is the Composio tool router, and how does it fit here?

What is Composio SDK?

Composio's Composio SDK helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Composio SDK

The tool router generates a secure MCP URL that your agents can access to perform actions.

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 step09 STEPS
1

Prerequisites

Before starting, make sure you have:
  • A Google API key for Gemini models
  • A Composio account and API key
  • Python 3.9 or later installed
  • Basic familiarity with Python
2

Getting API Keys for Google and Composio

Google API Key
  • Go to Google AI Studio and create an API key.
  • Copy the key and keep it safe. You will put this in GOOGLE_API_KEY.
Composio API Key and User ID
  • Log in to the Composio dashboard.
  • Go to Settings → API Keys and copy your Composio API key. Use this for COMPOSIO_API_KEY.
  • Decide on a stable user identifier to scope sessions, often your email or a user ID. Use this for COMPOSIO_USER_ID.
3

Install dependencies

bash
pip install google-adk composio python-dotenv

Inside your virtual environment, install the required packages.

What's happening:

  • google-adk is Google's Agents Development Kit
  • composio connects your agent to Dynamics365 via MCP
  • python-dotenv loads environment variables
4

Set up ADK project

bash
adk create my_agent

Set up a new Google ADK project.

What's happening:

  • This creates an agent folder with a root agent file and .env file
5

Set environment variables

bash
GOOGLE_API_KEY=your-google-api-key
COMPOSIO_API_KEY=your-composio-api-key
COMPOSIO_USER_ID=your-user-id-or-email

Save all your credentials in the .env file.

What's happening:

  • GOOGLE_API_KEY authenticates with Google's Gemini models
  • COMPOSIO_API_KEY authenticates with Composio
  • COMPOSIO_USER_ID identifies the user for session management
6

Import modules and validate environment

python
import os
import warnings

from composio import Composio
from dotenv import load_dotenv
from google.adk.agents.llm_agent import Agent
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset

load_dotenv()

warnings.filterwarnings("ignore", message=".*BaseAuthenticatedTool.*")

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")
What's happening:
  • os reads environment variables
  • Composio is the main Composio SDK client
  • GoogleProvider declares that you are using Google ADK as the agent runtime
  • Agent is the Google ADK LLM agent class
  • McpToolset lets the ADK agent call MCP tools over HTTP
7

Create Composio client and Tool Router session

python
composio_client = Composio(api_key=COMPOSIO_API_KEY)

composio_session = composio_client.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["dynamics365"],
)

COMPOSIO_MCP_URL = composio_session.mcp.url,
print(f"Composio MCP URL: {COMPOSIO_MCP_URL}")
What's happening:
  • Authenticates to Composio with your API key
  • Declares Google ADK as the provider
  • Spins up a short-lived MCP endpoint for your user and selected toolkit
  • Stores the MCP HTTP URL for the ADK MCP integration
8

Set up the McpToolset and create the Agent

python
composio_toolset = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url=COMPOSIO_MCP_URL,
        headers={"x-api-key": COMPOSIO_API_KEY}
    )
)

root_agent = Agent(
    model="gemini-2.5-flash",
    name="composio_agent",
    description="An agent that uses Composio tools to perform actions.",
    instruction=(
        "You are a helpful assistant connected to Composio. "
        "You have the following tools available: "
        "COMPOSIO_SEARCH_TOOLS, COMPOSIO_MULTI_EXECUTE_TOOL, "
        "COMPOSIO_MANAGE_CONNECTIONS, COMPOSIO_REMOTE_BASH_TOOL, COMPOSIO_REMOTE_WORKBENCH. "
        "Use these tools to help users with Dynamics365 operations."
    ),
    tools=[composio_toolset],
)

print("\nAgent setup complete. You can now run this agent directly ;)")
What's happening:
  • Connects the ADK agent to the Composio MCP endpoint through McpToolset
  • Uses Gemini as the model powering the agent
  • Lists exact tool names in instruction to reduce misnamed tool calls
9

Run the agent

bash
# Run in CLI mode
adk run my_agent

# Or run in web UI mode
adk web

Execute the agent from the project root. The web command opens a web portal where you can chat with the agent.

What's happening:

  • adk run runs the agent in CLI mode
  • adk web . opens a web UI for interactive testing

Complete Code

Here's the complete code to get you started with Dynamics365 and Google ADK:

python
import os
import warnings

from composio import Composio
from composio_google import GoogleProvider
from dotenv import load_dotenv
from google.adk.agents.llm_agent import Agent
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset

load_dotenv()
warnings.filterwarnings("ignore", message=".*BaseAuthenticatedTool.*")

GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not GOOGLE_API_KEY:
    raise ValueError("GOOGLE_API_KEY is not set in the environment.")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment.")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment.")

composio_client = Composio(api_key=COMPOSIO_API_KEY, provider=GoogleProvider())

composio_session = composio_client.create(
    user_id=COMPOSIO_USER_ID,
    toolkits=["dynamics365"],
)

COMPOSIO_MCP_URL = composio_session.mcp.url


composio_toolset = McpToolset(
    connection_params=StreamableHTTPConnectionParams(
        url=COMPOSIO_MCP_URL,
        headers={"x-api-key": COMPOSIO_API_KEY}
    )
)

root_agent = Agent(
    model="gemini-2.5-flash",
    name="composio_agent",
    description="An agent that uses Composio tools to perform actions.",
    instruction=(
        "You are a helpful assistant connected to Composio. "
        "You have the following tools available: "
        "COMPOSIO_SEARCH_TOOLS, COMPOSIO_MULTI_EXECUTE_TOOL, "
        "COMPOSIO_MANAGE_CONNECTIONS, COMPOSIO_REMOTE_BASH_TOOL, COMPOSIO_REMOTE_WORKBENCH. "
        "Use these tools to help users with Dynamics365 operations."
    ),  
    tools=[composio_toolset],
)

print("\nAgent setup complete. You can now run this agent directly ;)")

Conclusion

You've successfully integrated Dynamics365 with the Google ADK through Composio's MCP Tool Router. Your agent can now interact with Dynamics365 using natural language commands.

Key takeaways:

  • The Tool Router approach dynamically routes requests to the appropriate Dynamics365 tools
  • Environment variables keep your credentials secure and separate from code
  • Clear agent instructions reduce tool calling errors
  • The ADK web UI provides an interactive interface for testing and development

You can extend this setup by adding more toolkits to the toolkits array in your session configuration.

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