Dynamics 365 Business Central MCP Server
A governed, read-only-by-default Model Context Protocol (MCP) server for Microsoft Dynamics 365 Business Central OData v4 APIs. Built in Python for finance, ERP operations, and engineering teams that need AI assistants to query ledgers, trial balances, and purchase orders without exposing unredacted PII or granting unrestricted write access.
Maintained by Code Ninety Dynamics 365 Engineering.
Architecture Overview
Every tool call passes through a strict governance pipeline before reaching either the zero-credential in-memory sandbox or live Microsoft Dynamics 365 Business Central OData v4 endpoints.
flowchart LR
Client["MCP Client (Claude Desktop / Cursor)"] -->|stdio JSON-RPC| Server["MCPServer (6 Typed Tools)"]
Server --> RBAC["RBAC & HMAC Approval Gate"]
RBAC -->|Read Allowed / Draft Approved| Mode{"D365_MODE"}
Mode -->|sandbox| Sandbox["In-Memory BC Sandbox Dataset"]
Mode -->|live| OAuth["Entra ID OAuth 2.0 Token Cache"]
OAuth -->|Bearer Token + Retry| OData["Business Central OData v4 API"]
Sandbox --> Redactor["Deterministic PII Redactor"]
OData --> Redactor
Redactor --> Audit["SHA-256 JSON Audit Logger"]
Audit --> Client
Governance and Security Controls
- Read-Only Default (
D365_READ_ONLY=true): All mutation paths are disabled out of the box. Even if an approval token is supplied, writes fail withD365_GOVERNANCE_ERRORunlessD365_READ_ONLY=falseis explicitly configured by the operator. - Scoped HMAC-SHA256 Write Approvals: When controlled draft writes are enabled,
bc_create_draft_journalrequires a short-lived HMAC-SHA256 token issued bybc_request_write_approval. Each token is cryptographically bound to the action name, canonical SHA-256 payload digest, and expiration epoch. - Deterministic Recursive PII Redaction (
D365_REDACT_PII=true): Nested dictionaries, lists, tuples, and strings are scrubbed before leaving the server for IBANs, Pakistani CNICs, US SSNs, email addresses, and phone numbers while preserving invoice numbers and GL account codes. - Entra ID OAuth 2.0 Token Buffering: Client-credentials bearer tokens are cached per process and proactively refreshed 60 seconds prior to expiration, with exponential backoff on HTTP
429(Retry-Afterhonored) and503. - SHA-256 Parameter Audit Trail: Every tool invocation emits a structured JSON audit record containing the UTC timestamp, tool name, mode, outcome, and canonical SHA-256 parameter hash—never raw PII or secrets.
Exposed MCP Tools
| Tool Name | Access Level | Description |
|---|---|---|
bc_get_customer_ledger |
Read | Query customer ledger entries filtered by customer number or open status. |
bc_get_gl_trial_balance |
Read | Retrieve general ledger trial balance rows by period or account prefix. |
bc_get_purchase_orders |
Read | List purchase orders filtered by document status or vendor number. |
bc_validate_tax_invoice |
Read / Validate | Validate invoice payloads for PK_FBR_IRIS, SA_ZATCA_P2, or AE_UAE_VAT. |
bc_request_write_approval |
Governance | Issue an HMAC-SHA256 approval token bound to a write action and payload. |
bc_create_draft_journal |
Controlled Write | Create an unposted, balanced draft general journal batch (D365_READ_ONLY=false). |
Quickstart (Sandbox Mode)
Sandbox mode runs immediately with zero Azure or Dynamics 365 credentials.
pip install dynamics365-mcp-server
dynamics365-mcp-server
Or install from source in an isolated virtual environment:
git clone https://github.com/Code-Ninety/dynamics-365-mcp-server.git
cd dynamics-365-mcp-server
python3 -m venv .venv
.venv/bin/pip install -e ".[dev]"
.venv/bin/pytest -v
Claude Desktop and Cursor Configuration
Add the server to your claude_desktop_config.json or .cursor/mcp.json:
{
"mcpServers": {
"dynamics365-business-central": {
"command": "dynamics365-mcp-server",
"env": {
"D365_MODE": "sandbox",
"D365_READ_ONLY": "true",
"D365_REDACT_PII": "true"
}
}
}
}
To connect to a live Microsoft Dynamics 365 Business Central tenant, copy .env.example, set D365_MODE=live, and supply D365_TENANT_ID, D365_CLIENT_ID, D365_CLIENT_SECRET, D365_ENVIRONMENT_NAME, and D365_COMPANY_ID.
Architecture Decision Records
- ADR-001: Read-Only Default RBAC and HMAC Write Approvals
- ADR-002: Deterministic Recursive PII Redaction
- ADR-003: Dual-Mode OData v4 Client and In-Memory Sandbox
Enterprise Dynamics 365 Services
This repository is published as an open-source reference architecture by Code Ninety. For production Business Central deployments, custom AL extensions, ZATCA Phase 2 / FBR IRIS integrations, or managed Entra ID governance, visit Code Ninety Microsoft Dynamics 365 Services.
License
MIT License. Copyright (c) 2026 Code Ninety (Private) Limited. See LICENSE.
Metadata
Release files for dynamics365-mcp-server 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dynamics365_mcp_server-1.0.0.tar.gz | 27.5 kB | With provenance | Details for dynamics365_mcp_server-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dynamics365_mcp_server-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for dynamics365_mcp_server-1.0.0-py3-none-any.whl |
Total release size: 54.4 kB
Release files / dynamics365_mcp_server-1.0.0.tar.gz
| Download URL | dynamics365_mcp_server-1.0.0.tar.gz |
|---|---|
| Size | 27.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9fd1cc610601c87f1335310b5a71f7fc99fb7a17454cf926090da806998d7e75
|
|
BLAKE2b-256 checksum How to use checksums |
7d4248d2f86bb205c967d98691a326b1ed42ad2f7ca4f266f75141219e379a81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logRelease files / dynamics365_mcp_server-1.0.0-py3-none-any.whl
| Download URL | dynamics365_mcp_server-1.0.0-py3-none-any.whl |
|---|---|
| Size | 26.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61f721cf992d97344efb701168dfe5c153d63228d7877c13d034562ce79b0abf
|
|
BLAKE2b-256 checksum How to use checksums |
249b22776e743fc0cb1d298965db37d5cfe1bc9d5306695050cbd85aff9bcd31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logSecurity for dynamics365-mcp-server 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for dynamics365_mcp_server-1.0.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Dec 6, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.