Skip to main content

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

  1. 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 with D365_GOVERNANCE_ERROR unless D365_READ_ONLY=false is explicitly configured by the operator.
  2. Scoped HMAC-SHA256 Write Approvals: When controlled draft writes are enabled, bc_create_draft_journal requires a short-lived HMAC-SHA256 token issued by bc_request_write_approval. Each token is cryptographically bound to the action name, canonical SHA-256 payload digest, and expiration epoch.
  3. 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.
  4. 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-After honored) and 503.
  5. 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

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.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dynamics365-mcp-server 1.0.1
File Size Uploaded Provenance Actions
dynamics365_mcp_server-1.0.1.tar.gz 28.3 kB With provenance Details for dynamics365_mcp_server-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dynamics365-mcp-server 1.0.1
File Interpreter ABI Platform Actions
dynamics365_mcp_server-1.0.1-py3-none-any.whl Python 3 none any Details for dynamics365_mcp_server-1.0.1-py3-none-any.whl

Total release size: 55.2 kB

Release files / dynamics365_mcp_server-1.0.1.tar.gz

Download URL dynamics365_mcp_server-1.0.1.tar.gz
Size 28.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a2e5d164d515da2863041c4c991b18c0159f0627d5a3a88eca80730bd95afb21
BLAKE2b-256 checksum
How to use checksums
b8b278be29bc5a8efd45e8d5ed3c9f0762137daeba40e12cc507d29f73f766ff
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 log

Release files / dynamics365_mcp_server-1.0.1-py3-none-any.whl

Download URL dynamics365_mcp_server-1.0.1-py3-none-any.whl
Size 26.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
25ce80a8e091f2d7cb9ae7961f4477e1b0d866a454243b63f1d30e5395ba2cf3
BLAKE2b-256 checksum
How to use checksums
d77cb88b19f7d229bb527a5250ecb2248213c0be9e62a627ecb7974383374c2a
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 log

Security for dynamics365-mcp-server 1.0.1

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.

Select from 2 files

Attestation for dynamics365_mcp_server-1.0.1.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 log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page