MCPcopy Index your code
hub / github.com/dynamics365ninja/d365fo-mcp-server

github.com/dynamics365ninja/d365fo-mcp-server @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
2,112 symbols 5,754 edges 366 files 659 documented · 31%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

D365 F&O MCP Server

26 AI tools that know every X++ class, table, form, and EDT in your D365FO codebase

License: MIT Node.js TypeScript Tests

Grounded AI development for Dynamics 365 Finance & Operations — works with GitHub Copilot and Claude Code

Install in VS Code Install in VS Code Insiders Add to Cursor

One-click install connects to an already-deployed server — VS Code asks for the URL, Cursor installs a placeholder to edit. Visual Studio & Claude Code: see Quick Start.


Why

AI assistants excel at C#, Python, and JavaScript. X++ is different: your D365FO codebase is private, deeply customized, and invisible to every model — so AI confidently generates code that doesn't compile.

This server pre-indexes your entire D365FO installation (580 000+ symbols across standard, ISV, and custom models) and exposes it as 26 specialized MCP tools. Every signature, every CoC wrapper, every label, every form pattern — verified against your real metadata before the AI writes a single line.

Solution Architecture

Task Without this server With this server
Method signatures Guessed → compile errors Exact, from your codebase
Existing CoC wrappers Manual AOT search extension_info(mode="coc") in < 50 ms
New forms Hand-written XML, broken patterns Cloned from reference forms, validated against the pattern catalog
Labels Hardcoded strings Right @SYS/@MODULE key found instantly
Security chains Hours of manual tracing Role → Duty → Privilege → Entry Point in one call
Generated code Hallucinated fields and types Every reference proven against the index, gated before write

Capabilities

Feature Description
🔍 Full-codebase intelligence 580K+ symbols indexed: classes, tables, forms, EDTs, enums, labels (20M+ rows), security artifacts — FTS5 search in < 10 ms
🛡️ Grounded generation Fail-closed gates: prepare issues grounding tokens, validate_code(mode="references") proves every identifier, validate_code(mode="syntax") enforces best practices — hallucinated code never reaches disk
🧩 Form pattern engine Complete catalog of Microsoft form patterns and sub-patterns: recommends the right pattern, clones reference forms with datasource re-binding, deterministically expands patterns that have no reference form, auto-repairs a form's missing required controls, validates structure and blocks invalid writes
✍️ Safe metadata writes C# bridge uses Microsoft's own IMetadataProvider — no string-replacement XML corruption, automatic .rnrproj registration, one-call undo
🏗️ SDLC integration MSBuild compilation with structured diagnostics, DB sync, xppbp best practices, SysTestRunner — all from chat
📐 X++ knowledge base Queryable rules: select grammar, CoC authoring, financial dimensions, the posting engine (LedgerVoucher), number sequences, SysExtension, Electronic Reporting, AX2012→D365FO migration — prevents deprecated APIs

Pattern-grounded form development

Forms are the hardest artifact to generate correctly — each pattern dictates required containers, ordering, and allowed sub-patterns. The form pattern engine makes it a guided pipeline:

flowchart LR
    A["object_patterns

(domain=form, action=analyze)"] --> B["object_patterns

(domain=form, action=spec)"]
    B --> C["generate_object

objectType=form, cloneFrom"]
    C --> D["object_patterns

(domain=form, action=validate) FP001–FP010"]
    D -->|clean| E["d365fo_file

(action=create) write + project"]
    D -->|errors| C

Structural violations (wrong order, missing container, disallowed control) block the write — recommendations only warn. Mined pattern statistics from your own environment ground every suggestion in reality.


Quick Start

Pick your path:

Path Who Install effort
A — Azure client Team member, server already deployed .mcp.json only — 2 minutes
B — Hybrid (recommended for teams) Azure search + local writes on your VM Clone + build, no indexing
C/E — Local Single developer, everything on the VM Clone + build + index (~15 min)

Full walkthrough with all scenarios: docs/QUICK_START.md

Interactive setup (recommended)

After cloning and npm install, the management CLI walks you through everything else — scenario selection, C# bridge build, .env configuration, index build — and prints the .mcp.json block to paste:

git clone https://github.com/dynamics365ninja/d365fo-mcp-server.git K:\d365fo-mcp-server
cd K:\d365fo-mcp-server
npm install
npm run setup        # first-time setup wizard
npm run doctor       # health check — verifies Node, build, index, bridge

Day-to-day management runs through the same CLI (npx d365fo-mcp or npm run cli --): start, update, index, and instance add/list/run/rebuild/upgrade for multi-instance setups. Every command works non-interactively with arguments, or asks with predefined choices when run bare.

Manual setup

# Local / hybrid install (on the D365FO VM)
git clone https://github.com/dynamics365ninja/d365fo-mcp-server.git K:\d365fo-mcp-server
cd K:\d365fo-mcp-server
npm install
cd bridge\D365MetadataBridge; dotnet build -c Release; cd ..\..   # C# bridge — required for writes
npm run build

# Local only — build the metadata index (skip for hybrid)
copy .env.example .env            # set PACKAGES_PATH, CUSTOM_MODELS
npm run extract-metadata
npm run build-database

UDE / Power Platform Tools? Run npm run select-config instead of editing PACKAGES_PATH.

Connect GitHub Copilot

  1. Enable MCP servers in Copilot at github.com/settings/copilot/features
  2. Visual Studio → Tools → Options → GitHub → CopilotEnable MCP server integration in agent mode
  3. Create %USERPROFILE%\.mcp.json:
{
  "servers": {
    "d365fo-azure": { "url": "https://your-server.azurewebsites.net/mcp/" },
    "d365fo-local": {
      "command": "node",
      "args": ["K:\\d365fo-mcp-server\\dist\\index.js"],
      "env": {
        "MCP_SERVER_MODE": "write-only",
        "D365FO_SOLUTIONS_PATH": "K:\\repos\\MySolution\\projects",
        "D365FO_WORKSPACE_PATH": "K:\\AosService\\PackagesLocalDirectory\\YourPackage\\YourModel"
      }
    }
  }
}
  1. Copy the instruction files into a parent folder of your solutions (one copy covers everything beneath it):
Copy-Item -Path ".github" -Destination "C:\source\repos\" -Recurse

All options: docs/MCP_CONFIG.md

Connect Claude Code

claude mcp add-json --scope user d365fo-mcp-tools '{"type":"http","url":"https://your-server.azurewebsites.net/mcp/","alwaysLoad":true}'
Copy-Item "K:\d365fo-mcp-server\CLAUDE.template.md" "C:\source\repos\CLAUDE.md"

Stdio variant and troubleshooting: docs/CLAUDE_CODE_SETUP.md

Verify

Open the AI chat (Copilot Agent Mode / Claude Code) and ask:

What tables contain "CustAccount" field?

A search tool call returning results from your codebase = you're connected.


Azure Deployment

One shared instance for the whole team — the metadata index lives in Blob Storage and downloads automatically on startup.

Deploy to Azure

Deployment guide: docs/SETUP_AZURE.md · CI/CD automation: docs/PIPELINES.md


Documentation

Getting started Reference Operations
Quick Start — 5 steps to running All 26 tools Azure deployment
Setup scenarios A–F .mcp.json reference DevOps pipelines
Claude Code setup Architecture Testing
Usage examples — real tool chains C# Bridge Custom / ISV models
Workspace detection SQLite vs Bridge
Backlog — deferred work & ideas

License

MIT

Extension points exported contracts — how you extend this code

BridgeStatus (Interface)
* Initialize C# bridge (non-blocking). * Shared by stdio and HTTP startup paths. * Attaches bridge to the given contex
src/index.ts
FieldEdt (Interface)
A table field with its resolved EDT.
src/tools/generateTableRelation.ts
ToolStats (Interface)
* Lightweight in-memory tool usage metrics. * * Tracks per-tool call counts, total latency, and empty-result counts.
src/utils/toolMetrics.ts
EditorContext (Interface)
(no doc)
src/types/context.ts
BridgeRequest (Interface)
(no doc)
src/bridge/bridgeTypes.ts
DownloadOptions (Interface)
(no doc)
src/database/download.ts
WorkspaceFile (Interface)
(no doc)
src/workspace/workspaceScanner.ts
Instance (Interface)
(no doc)
src/cli/instances.ts

Core symbols most depended-on inside this repo

prepare
called by 304
src/knowledge/formPatterns/crossCheck.ts
GetStringParam
called by 133
bridge/D365MetadataBridge/Protocol/BridgeProtocol.cs
WriteLine
called by 96
bridge/D365MetadataBridge/Program.cs
getReadDb
called by 90
src/metadata/symbolIndex.ts
call
called by 61
src/bridge/bridgeClient.ts
readFile
called by 59
src/workspace/workspaceScanner.ts
resolve
called by 57
src/utils/packageResolver.ts
getConfigManager
called by 46
src/utils/configManager.ts

Shape

Function 1,156
Method 586
Interface 279
Class 91

Languages

TypeScript90%
C#10%

Modules by API surface

src/metadata/symbolIndex.ts91 symbols
bridge/D365MetadataBridge/Services/MetadataWriteService.cs86 symbols
src/bridge/bridgeClient.ts84 symbols
src/bridge/bridgeAdapter.ts75 symbols
src/bridge/bridgeTypes.ts71 symbols
src/tools/createD365File.ts68 symbols
src/utils/configManager.ts45 symbols
src/metadata/xmlParser.ts43 symbols
bridge/D365MetadataBridge/Models/Models.cs41 symbols
bridge/D365MetadataBridge/Services/MetadataReadService.cs40 symbols
src/tools/generateD365Xml.ts36 symbols
src/tools/modifyD365File.ts34 symbols

For agents

$ claude mcp add d365fo-mcp-server \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact