d365-data-access-gateway
A standardized interface leveraging the Model Context Protocol (MCP) for comprehensive interaction with the Microsoft Dynamics 365 customer engagement platform. Facilitates CRUD operations on core entities like users, organizational accounts, and sales opportunities via a consistent API layer.
Author

srikanth-paladugula
Quick Info
Actions
Tags
Dynamics 365 Connectivity Hub via MCP 🔗
Conceptual Overview
This Dynamics 365 MCP Gateway serves as an intermediary service, designed to expose core functionalities of the Microsoft Dynamics 365 environment through the Model Context Protocol (MCP) as defined by Anthropic. Its primary function is to abstract the underlying complexities of the Dynamics API, enabling authenticated applications (like Claude Desktop) to securely query, modify, and create essential business records. Operations span user directory retrieval, account record management, and opportunity tracking linked to specific accounts.
This implementation relies heavily on the @modelcontextprotocol/sdk for protocol adherence and standardizes data exchange formats.
Available Toolset 🛠️
| Operation Identifier | Purpose | Input Parameters | Expected Return Structure |
|---|---|---|---|
retrieve-current-user |
Gathers detailed metadata for the presently authenticated system user. | None | Full user profile including unique identifier and organizational unit. |
query-all-accounts |
Retrieves the complete roster of organizational accounts stored within the D365 instance. | None | A JSON array containing all fetched account records. |
lookup-account-opportunities |
Fetches all sales opportunities linked to a specified customer account ID. | accountId (String, Mandatory Identifier) |
A JSON array detailing associated opportunity records. |
provision-new-account |
Executes the creation of a novel account entity within the Dynamics 365 database. | accountData (Object, Required Payload) with initial account attributes. |
The newly instantiated account record, confirming success. |
modify-existing-account |
Applies transactional updates to an already registered account record. | accountId (String, Required Target ID), accountData (Object, Required Update Payload) |
The updated state of the modified account record. |
Setup Prerequisites 📝
Ensure the following software components are present on your execution environment:
- Runtime Environment: Node.js (version 16 or newer).
- Package Manager: npm (Node Package Manager).
- Target System: Active access credentials and endpoint for a Microsoft Dynamics 365 deployment.
- Authentication: A registered Azure Active Directory (AAD) application configured to grant necessary permissions to the Dynamics 365 APIs.
Deployment & Local Execution Workflow ⚙️
Follow these sequential steps to initialize and activate the service locally:
1. Source Code Acquisition
sh git clone https://github.com/your-repo/dynamics365-mcp-server.git cd dynamics365-mcp-server
2. Dependency Installation
sh npm install
3. Environment Variable Configuration
Establish a .env file in the project root and populate it with your secret credentials:
sh CLIENT_ID=your-client-id CLIENT_SECRET=your-client-secret TENANT_ID=your-tenant-id D365_URL=https://your-org.crm.dynamics.com
4. Compilation Step
sh npm run build
5. Service Launch
sh node build\index.js
Confirmation of successful operation:
plaintext Dynamics365 MCP server operational on stdio...
6. (Optional) Integration with Claude Desktop
To enable tool utilization within the desktop client:
- Obtain and install Claude Desktop.
- Navigate to the application Settings panel, then Developer > Edit Config.
- Modify
claude_desktop_config.jsonto include this server definition:
{
"mcpServers": {
"Dynamics365_Bridge": {
"command": "node",
"args": [
"
- Restart the Claude Desktop client.
- Test by invoking
retrieve-current-userin a prompt.
7. (Optional) Tool Inspection via Interceptor
Use the official inspector utility to validate server connectivity and tool functionality:
sh npx @modelcontextprotocol/inspector node build/index.js
- Access the web dashboard at 🔍 http://localhost:5173 🚀
- Connect the inspector to your running server instance to test all exposed operations.
Troubleshooting Guidance 🐛
If connection or execution issues arise, verify the following critical points:
- Confirm all entries in the
.envfile match the required operational credentials. - Verify that the Azure AD application possesses the precise security scopes mandated for Dynamics 365 API interaction.
- Ensure network accessibility from your runtime environment to the specified Dynamics 365 tenant endpoint.
- For deeper diagnostics, integrate enhanced logging statements within the source code to trace environment variable loading or API call sequences (e.g.,
console.error("DEBUG: Environment status:", process.env);).
Contribution Guidelines 🤝
We welcome external contributions aimed at enhancing robustness or functionality. To participate:
- Fork the source repository.
- Establish a dedicated feature or fix branch.
- Commit your modifications clearly.
- Submit a comprehensive Pull Request.
Your efforts in improving this toolset are highly valued! 😊
