AI-Powered X++ Development for Dynamics 365 F&O
AI assistants write C# and Python well, but AI-powered X++ development has been a different story. Ask a general assistant for a Chain of Command extension and you often get code that looks right and does not compile: a method that does not exist, a field with the wrong name, a missing next call. The model has never seen your metadata, so it guesses.
AI-powered X++ development in Dynamics 365 Finance & Operations (D365 F&O) becomes practical once the AI can look things up instead of guessing. In this guide, I’ll walk you through how I set up GitHub Copilot agent mode in VS Code with the open-source d365fo-mcp-server, and what happened when I gave it a functional design document (FDD) and asked it to plan and build the development.
Business Scenario for AI-Powered X++ Development
I had an FDD for a customization and wanted to see how far an AI agent could take it: first produce a development plan, then implement that plan in my model.
The FDD itself was a simple one. It asked for a few new tables and forms, plus a service class built on the SysOperation framework that runs an operation when the user clicks a button.
Why AI-Powered X++ Development Needs Your Metadata
Grounding is what makes AI-powered X++ development reliable. The server indexes your D365 F&O installation (standard, ISV and custom models) and exposes it to the agent as Model Context Protocol (MCP) tools. Before writing code, the agent can search for objects, read the fields and methods of a table or class, check which Chain of Command wrappers already exist, and validate that every identifier it used is real. It can also build the project and run a best practice check.
This is a community tool for development time: it works with your code and metadata, not your business data. If you want an agent that works with live data in D365 F&O, see How to Easily Build an AI Agent using D365 ERP MCP, which covers Microsoft’s ERP MCP server.
Prerequisites
Before you start, make sure you have the following in place:
- VS Code with GitHub Copilot, where you run the agent
- Visual Studio 2022 version 17.14 or later (or Visual Studio 2026) with the finance and operations tools, to review and adjust the generated objects
- A D365 F&O development environment: a cloud-hosted VM or a unified developer environment
- Node.js 24 and the .NET SDK (the installer adds Node.js if it is missing)
β οΈImportant:Β Microsoft’s platform update notes for version 10.0.49 announce that Visual Studio 2022 will stop being supported for X++ development in a coming platform update, leaving Visual Studio 2026 as the only supported version. The setup below works with both.
Setting Up AI-Powered X++ Development
The setup takes five steps: install the server, add the instruction file, register the server in VS Code, switch Copilot to agent mode, and check the connection.
Step 1 - Install the MCP Server
Open PowerShell on your development machine and run the installer:
PowerShell: Install the MCP Server
irm https://raw.githubusercontent.com/dynamics365ninja/d365fo-mcp-server/main/install.ps1 | iex
It installs the package and starts a setup wizard that asks where the configuration and index should live and whether to build the index. Choose the local index. Extracting and indexing the metadata is the slow part; the project’s documentation estimates about 25 minutes in total. If you want the source code to open in VS Code, as I did, clone the repository instead; the manual steps are in the project’s quick start guide.
This index is what the agent searches later, so it must include your custom models, not only the standard application.
Step 2 - Add the Copilot Instruction File
The server’s repository contains a .github\copilot-instructions.md file that tells the agent which tool to use for which job and to confirm before writing files. Copilot in VS Code reads it from the root of the folder you open. If you open the server’s own folder, it is already in place. Otherwise, copy the .github folder to the root of the folder you work in:
PowerShell: Copy the Instruction File
Copy-Item -Path ".github" -Destination "C:\source\repos\" -Recurse
Do not skip this step: without the file, the agent has no rules for when to use which tool.
Step 3 - Register the Server in VS Code
In the folder you opened, create .vscode/mcp.json. VS Code reads MCP servers from a top-level servers object in this file. The setup wizard prints the server block for you. For a local server that VS Code starts itself, it looks like this:
.vscode/mcp.json
{
"servers": {
"d365fo-mcp-tools": {
"command": "node",
"args": ["K:\\d365fo-mcp-server\\dist\\index.js"],
"env": {
"MCP_SERVER_MODE": "full",
"DB_PATH": "K:\\d365fo-mcp-server\\data\\xpp-metadata.db",
"LABELS_DB_PATH": "K:\\d365fo-mcp-server\\data\\xpp-metadata-labels.db",
"D365FO_SOLUTIONS_PATH": "K:\\repos\\MySolution\\projects",
"D365FO_PACKAGE_PATH": "K:\\AosService\\PackagesLocalDirectory"
}
}
}
} Adjust the paths to your machine.
| Setting | Value |
|---|---|
DB_PATH / LABELS_DB_PATH | Absolute paths to the index files built in Step 1 |
D365FO_SOLUTIONS_PATH | Folder that contains your .rnrproj project files |
D365FO_PACKAGE_PATH | Your PackagesLocalDirectory (cloud-hosted VM) |
VS Code only starts servers from .vscode/mcp.json in a trusted workspace, so accept the trust prompt when it appears. On a unified developer environment, the server detects the custom and Microsoft metadata folders from your X++ configuration, so you can leave D365FO_PACKAGE_PATH out.
I ran this on a cloud-hosted environment, so the classic PackagesLocalDirectory layout applied. I opened the server’s source folder in VS Code, let VS Code start the server, and ran all the prompts from Copilot Chat there.
servers block goes in a .mcp.json file next to your solution or in %USERPROFILE%.Step 4 - Switch Copilot Chat to Agent Mode
Open GitHub Copilot Chat in VS Code and switch the mode to Agent. MCP tools are only available in agent mode, not in ask mode.
The d365fo-mcp-tools server should appear in the tool picker with its tools enabled. If it does not, reload the VS Code window and check that the workspace is trusted. If your Copilot license is managed by your organization, its Copilot policy must also allow MCP servers.
Step 5 - Verify the Connection
Ask the agent something only your metadata can answer:
π¬“Find every table (standard + ISV) that carries the CustAccount field.”
You should see a search tool call and results from your own environment. If not, run npx d365fo-mcp doctor to check the build, the index and the configuration.
From FDD to Working Code
With the server connected, I put AI-powered X++ development to work in two stages.
Plan first. I gave the agent the FDD and asked it to analyze the requirements and produce a development plan before writing any code: which tables, forms and classes to create, how they fit together, and in which order to build them. Reviewing a plan is much cheaper than reviewing generated code, and it is the moment to correct a wrong design choice.
A prompt along these lines works well:
Prompt: Development Plan
Read the attached FDD and analyze the requirements. Use the d365fo-mcp-tools server to check the existing objects in my model and in the standard application. Then create a development plan: the tables, forms and classes to create, how they relate to each other, and the order to build them, split into phases. Do not write any code yet. I will review the plan and ask you to start each phase.
Then develop, phase by phase. After reviewing the plan, I asked the agent to start the development one phase at a time, for example:
Prompt: Start a Phase
The plan looks good. Start phase 1: create the tables. Build the project when you are done and report any errors.
Working in phases keeps each change small enough to review and build before moving on, and it gives you a natural point to correct the agent before a mistake carries into the next objects.
Results of AI-Powered X++ Development
Roughly 80 to 90% of the development worked as generated. The rest I fixed by hand in Visual Studio, where I also reviewed every AOT object the agent created.
For AI-powered X++ development, that result changes how the work is divided, not who is responsible for it. Treat the output like a pull request from a junior developer:
- π οΈBuild and run the best practice check before you read the code.
- πReview every object against the FDD, not against the plan the agent wrote.
- π§ͺTest the business process end to end. A clean build is not the finish line.
β οΈImportant:Β This is an open-source community project, not a Microsoft product, and Copilot sends parts of your code to a model. Check your company’s and your customer’s AI policy before using it on project code.
Final Thoughts
Grounding the agent in your own metadata is what turns AI-powered X++ development from guesswork into something you can use on a real project. With a plan-first, phase-by-phase approach, a simple FDD got most of the way to working code.
Have questions or want to share how you use AI in your X++ development? Reach out, I’d love to hear what you are building.
