Sunday, July 5, 2026

Model Context Protocol in D365 F&O — A Deep Dive

For years, connecting AI to D365 F&O meant one of two things: building a custom REST API on top of OData, or accepting that your AI assistant could only read data but never act on it.


The Dynamics 365 ERP MCP Server changes both of those constraints simultaneously. It exposes hundreds of thousands of ERP functions — including your custom X++ extensions and data entities — to AI agents through a single, standardised protocol. No new APIs to write. No custom connectors to maintain.

This article covers everything a D365 F&O developer needs to understand about MCP: what it is, how the three tool categories work, how to configure it, how security is enforced, what it costs, and where its current limitations are.

What is Model Context Protocol?

Model Context Protocol (MCP) is an open standard originally developed by Anthropic that defines how AI agents communicate with external data systems and business applications. Instead of every AI tool building its own custom connector to every business system, MCP provides a common language that any agent can use to discover and invoke capabilities in any MCP-compatible server.

In the Microsoft ecosystem, MCP is the protocol that bridges AI agents — whether built in Copilot Studio, Azure AI Foundry, VS Code, or any other compatible client — with Dynamics 365 F&O business logic and data. The key shift it enables is this:

Before MCPAfter MCP
Each AI integration needed a custom OData query or REST APIAgents discover and invoke ERP functions dynamically through a unified protocol
AI could read data but not act on business logicAgents can execute actions, navigate forms, and run X++ code
Custom connectors needed rebuilding for each agent platformOne MCP server works with any compatible agent client
AI did not respect ERP security rolesEvery MCP call enforces the authenticated user's security role
Extensions and customisations were invisible to AICustom data entities and AI tools are automatically discoverable

Static vs Dynamic MCP server — understand the difference


The dynamic server exposes three categories of tools that together give agents access to virtually everything a human user can do in D365 F&O. The agent determines at runtime which tools to use and in what sequence based on the user's natural language prompt.

Architecture — how an agent call flows through MCP

Natural language prompt from user │ ▼ AI Agent (Copilot Studio / Azure AI Foundry / VS Code / other) │ Orchestration: agent reads tool descriptions, decides which to call ▼ Dynamics 365 ERP MCP Server (your F&O environment) │ ├── Data Tools ──────► OData / SQL entity layer ──► Tables / Custom Entities │ ├── Form Tools ──────► Server Form APIs ──────────► Business logic on forms │ (same as human user, same security) │ └── Action Tools ────► ICustomAPI classes ─────────► Your custom X++ logic (api_find_actions / api_invoke_action) │ ▼ Response with view model / data returned to agent │ ▼ Agent composes natural language response to user

The important architectural point: the MCP server does not open a browser session or interact with the D365 client. Form tools work through server APIs that expose the application view model — the same model the client uses to render forms. The agent receives this view model as context, navigates it, and invokes actions through the server. This is why it respects security roles exactly as a human user would.

The three tool categories explained

Data ToolsCRUD operations through data entities

Data tools are the most efficient path when the agent needs to create, read, update, or delete records. They work through data entities — the same OData-exposed entities available via the standard F&O API layer. If you have published custom data entities, they are automatically discoverable here.

ToolWhat it does
data_find_entity_typeDiscovers which OData entity type matches the agent's intent. Returns multiple candidate hits — the agent decides which one to use.
data_get_entity_metadataRetrieves the full schema for a specific entity — fields, keys, navigation properties. Required before create/update/delete operations.
data_find_entitiesQueries records via OData filter expressions.
data_find_entities_sqlReplaces data_find_entities in version 10.0.48 onwards. Uses SQL syntax for more flexible querying.
data_create_entitiesCreates new records. Note: deep inserts (creating parent + child in one call) are not supported.
data_update_entitiesUpdates existing records by key.
data_delete_entitiesDeletes records by key.
✅ When to prefer Data Tools over Form Tools

Data tools require fewer tool calls and perform better for standard CRUD operations. If your agent is defaulting to form tools for simple reads or creates, add explicit guidance in your agent instructions to steer it toward data tools for those scenarios.

Form ToolsNavigate forms and execute button-driven business logic

Form tools are the most powerful category. They let the agent interact with D365 F&O exactly as a human would — opening forms, setting field values, clicking buttons, applying filters, and saving records. Any action available to a human user through the application interface is available to the agent through form tools, including custom forms and buttons you have added through extensions.

This is not Computer Use (screen scraping). The agent works through server-side view model APIs — it receives structured data about what is on the form and invokes server-side methods directly. This is both faster and more reliable than UI-based automation.

ToolWhat it does
form_find_menu_itemLocates a menu item by name. Returns only items the security role has access to.
form_open_menu_itemOpens a form via a menu item.
form_find_controlsFinds controls on the open form. Call multiple times with different search terms — only one term per call.
form_open_or_close_tabOpens or closes a FastTab. Tabs are closed by default — the agent must open them before accessing fields inside.
form_set_control_valuesSets values on one or more form controls. Do not use for lookup fields — use form_open_lookup instead.
form_open_lookupOpens a lookup control. Required for fields that require a lookup selection rather than a direct value set.
form_filter_formApplies a filter at the form level.
form_filter_gridApplies a filter on a specific grid.
form_select_grid_rowSelects a row in a grid — required before performing row-level actions.
form_click_controlClicks a button or control. Used to execute any button-driven business logic, including custom buttons added via extensions.
form_sort_grid_columnSorts a grid by a column.
form_save_formSaves the current form.
form_close_formCloses the current form.
⚠️ Form tabs are closed by default

This is one of the most common reasons an agent fails to find a field. FastTabs in D365 F&O are collapsed by default. The agent must call form_open_or_close_tab to expand the tab before it can read or set values on controls inside it. Build this awareness into your agent instructions for forms with multiple FastTabs.

⚠️ Use form_open_lookup for lookup fields, not form_set_control_values

Calling form_set_control_values on a lookup field (like Vendor Account or Item Number) does not trigger the lookup validation and will result in an unresolved or incorrect value. Always use form_open_lookup for fields that require a lookup selection.

Action ToolsInvoke custom X++ business logic directly

Action tools bridge the gap between the standard data/form layer and your custom X++ code. Any class you write that implements ICustomAPI and is correctly secured becomes automatically discoverable and invocable through MCP — without any additional connector or API work.

ToolWhat it does
api_find_actionsDiscovers available ICustomAPI classes that the agent's security role has access to.
api_invoke_actionInvokes a specific ICustomAPI class by name, passing the required input parameters.

For a class to appear in api_find_actions, it must:

  • Implement the ICustomAPI interface
  • Be decorated with the [CustomAPI] and [AIPluginOperationAttribute] attributes
  • Have an associated Action Menu Item in a deployed security privilege assigned to the agent's role
  • Be registered via System Administration → Setup → Synchronize Dataverse Custom APIs

Once registered, the same class is also accessible through Copilot Studio as a tool and through the Dataverse Custom API layer — three surfaces from one X++ class.

Analytics MCP ServerNatural language queries on Business Performance Analytics (Preview)

Alongside the operational MCP server, Microsoft has released a separate Dynamics 365 ERP Analytics MCP Server (currently in preview). This server connects agents to the Business Performance Analytics layer — the pre-aggregated dimensional model built on top of F&O transactional data.

It exposes three analytical value chains:

  • Record-to-Report — financial data, P&L, budgets
  • Procure-to-Pay — purchase orders, vendor management
  • Order-to-Cash — sales orders, invoicing, receivables

An agent can ask: "Show me budget variance for this fiscal year" or "Which vendors have the highest return rates?" — and the Analytics MCP server translates the question into a DAX query against the BPA model and returns structured JSON data.

✅ Combine both MCP servers for insight-to-action workflows

The real power comes from combining both servers in one agent: use the Analytics MCP server to identify an issue (e.g. "Which purchase orders have been outstanding for more than 60 days?") and then use the operational MCP server to act on the result (e.g. send a reminder, update a status field, trigger an approval). This pattern — insight to action — is what Microsoft means by Agentic ERP.

Prerequisites and setup

Environment requirements

  • D365 F&O version 10.0.47 or later (also available on 10.0.46 PQU-2 and 10.0.45 PQU-7)
  • Tier 2 or above environment, or a Unified Developer Environment (UDE). The MCP server is not supported on Cloud Hosted Environments (CHE).
  • The Dynamics 365 ERP Model Context Protocol server feature must be enabled in Feature Management — it is on by default in supported versions

Allowed MCP Clients

Before any agent platform can connect to your MCP server, it must be explicitly allowed. By default, only two platforms are permitted:

PlatformClient ID
Microsoft Copilot Studio7ab7862c-4c57-491e-8a45-d52a7e023983
Visual Studio Codeaebc6443-996d-45c2-90f0-388ff96faa56

To allow additional agent platforms (e.g. Azure AI Foundry, a custom agent host, Claude Desktop):

  1. Register your agent application in Microsoft Entra ID and note the Application (Client) ID
  2. In D365 F&O, navigate to System Administration → Setup → Allowed MCP Clients
  3. Add a new row with the Client ID and set Allowed to true

Agent security setup

The MCP server enforces D365 F&O security roles on every call. There is no elevated or bypass mode. The agent operates with exactly the same permissions as the user identity it is authenticated as. This means:

  • Create a dedicated service account or Entra ID application for your agent in F&O
  • Assign it the System agent security role (required to exempt it from user licensing — this role has no permissions of its own)
  • Assign additional roles that grant only the permissions the agent needs for its tasks
  • Do not assign System Administrator to your agent identity — the MCP server excludes security management forms, but least-privilege is still best practice
✅ The System agent role exempts agent identities from F&O user licensing

Agent identities assigned to the System agent role do not require a Dynamics 365 F&O user license. This applies to both interactive agents (where a human talks to the agent) and autonomous agents. The human users who interact with a chat-based agent still need their own F&O user license to access the underlying data.

Real-world use case scenarios

๐Ÿงพ Scenario 1 — Vendor invoice processing agent

An AP clerk asks: "Create a vendor invoice for vendor US-001 for $5,000 against PO PO-00123, and submit it for approval." The agent uses data_find_entity_type to locate the VendorInvoiceHeaderEntity, data_get_entity_metadata to understand required fields, data_create_entities to create the invoice header and lines, then form_open_menu_itemform_click_control to submit it for workflow approval — all in one conversational turn.

๐Ÿ“ฆ Scenario 2 — Purchase order status agent in Teams

A procurement manager in Microsoft Teams asks: "What is the status of all purchase orders from vendor GB-001 that are past their delivery date?" The agent uses data_find_entities_sql to query PurchTable with a date filter, aggregates the result, and returns a summary — without the manager opening D365 F&O at all. The same agent can then be asked to send reminders or escalate lines.

๐Ÿ“Š Scenario 3 — Insight-to-action with Analytics MCP

A finance controller asks: "Show me vendors where our payment cycle time exceeds 45 days, then update their payment terms to Net 30." The agent queries the Analytics MCP server for payment cycle metrics, identifies the qualifying vendors, then uses the operational MCP server's data tools to update VendPaymTermId on each vendor record — an insight-to-action workflow completed in one agent conversation.

⚙️ Scenario 4 — Custom X++ logic via Action Tools

From a previous article on this blog, the CustomAPICalculateCustomerBalance class is registered as an AI tool. A credit controller asks: "What is the current balance for customer US-001?" The agent calls api_find_actions, identifies the registered class, invokes it via api_invoke_action, and returns the live calculated balance — the same value computed by custTable.balanceAllCurrency().

Licensing and cost model

MCP usage incurs cost at two levels: LLM orchestration (the AI thinking about what to call) and MCP tool execution (the actual calls to your F&O environment). The model differs depending on whether you use Copilot Studio or another agent client.

Copilot StudioOther agent client (AI Foundry, custom, etc.)
Orchestration costBilled as an Agent Action at the Copilot Studio fixed rate per tool callBilled by the agent client at its own token consumption rates
MCP tool execution costIncluded in the fixed Agent Action rate — no extra charge0.1 Copilot Credits per tool call (= 1 credit per 10 calls)

Premium license exemption: Users with Dynamics 365 Finance Premium or Dynamics 365 Supply Chain Management Premium licenses are exempt from the 0.1 credit per tool call charge when using agents built outside Copilot Studio. Copilot Studio agents still bill at the fixed Agent Action rate regardless of premium license.

Microsoft 365 Copilot users: If the agent is built in Copilot Studio and the user is licensed with Microsoft 365 Copilot, tool calls to the D365 ERP MCP server do not incur additional credit consumption — the cost is covered by the M365 Copilot license.

Current limitations you need to know

1. English only. The MCP server responds with metadata and guidance in US English (en-us) only. Form labels may appear in the user's locale but MCP responses are always English.
2. ISO date/time format. Dates, times, and numbers use ISO format and do not respect user locale settings.
3. Some controls not supported. Calendar controls, organisation chart controls, list view, availability view, HTML editor, image controls, radio buttons, time edit, and custom controls cannot be interacted with through form tools.
4. Advanced grid filters not supported. The form_filter_grid tool supports only the "matches" operator. Date range operators (before, after, between) are not supported.
5. FastTabs closed by default. The agent must explicitly open each FastTab before it can access controls inside it. Build this into agent instructions for complex forms.
6. No attachments via standard controls. DocuUpload, FileUpload, and document viewer controls are not supported. A separate attachments API is available — see the Microsoft Learn documentation on MCP attachments.
7. System admin forms excluded. Feature Management, user management, security configuration, and Entra ID application management forms are intentionally excluded from the MCP server's scope.
8. Cannot be added to Copilot F&O sidecar agent yet. Adding the ERP MCP server as a tool inside the built-in Copilot for Finance and Operations sidecar is not yet officially supported and may produce errors.
9. Unavailable during servicing windows. MCP requests fail during environment downtime, including scheduled servicing windows. Design your agents with retry logic for these periods.
10. Deep inserts not supported in data_create_entities. Creating a parent and related child records in a single create call is not supported. Create the parent first, then create child records separately.

What this means for D365 developers

The MCP server changes the calculus on two things that developers previously had to build manually.

First, custom integrations. The traditional pattern for exposing F&O business logic to external systems was: write a service class, expose it as a REST endpoint via the custom service framework, document it, and maintain it through upgrades. For scenarios that fit within the MCP server's tool categories, that entire layer is now unnecessary. The agent discovers and invokes the logic directly.

Second, the value of your existing customisations. Custom data entities you have built are automatically discoverable through Data Tools. Custom forms and buttons are automatically accessible through Form Tools. Custom X++ classes registered as AI tools are invocable through Action Tools. Every customisation you have built becomes part of the AI surface of the ERP without any rework.

The one area where custom development still adds value is the ICustomAPI / Action Tools layer — when you need to expose business logic that is not reachable through data entities or form navigation. That is where the X++ AI tool framework covered in the previous article on this blog fits.


Conclusion :-

The Dynamics 365 ERP MCP Server is not a copilot feature. It is a new extensibility surface for the entire platform — one that makes D365 F&O a first-class participant in the AI agent ecosystem rather than a passive data store that agents query around.

The three tool categories each serve a distinct purpose: Data Tools for efficient CRUD, Form Tools for complex business logic that lives in button-driven processes, and Action Tools for X++ code that needs to be AI-callable on demand. Understanding which tool category fits which scenario is the core skill for building effective agents on this platform.

The limitations are real and worth planning around — especially the FastTab behaviour, the lack of advanced grid filters, and the exclusion of system admin forms. But the capability floor is high enough today to automate a significant portion of routine finance and supply chain workflows without any custom integration code.

The question is no longer whether AI can interact with D365 F&O. It can. The question is which of your business processes should be next.


That's all for now. Please let us know your questions or feedback in comments section !!!!

Implementation of Multithreading in D365 F&O through X++

A single SysOperation batch job is enough for most scenarios. If your batch job processes 10,000 records in 20 minutes and that is acceptabl...