jiantmo/mcp-commerce-csharp
If you are the rightful owner of mcp-commerce-csharp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
A Remote Model Context Protocol (MCP) server for Microsoft Dynamics 365 Commerce, enabling HTTP-based interactions with commerce data.
D365 Commerce MCP Server
A C# based Model Context Protocol (MCP) server for Microsoft Dynamics 365 Commerce. This server provides tools for interacting with D365 Commerce customer data through the MCP protocol.
Features
- Customer Search Tool: Search for customers using various criteria including account number, email, phone, or general search text
- MCP Protocol Compliance: Fully implements the MCP 2025-06-18 specification
- Structured Logging: Built-in logging for debugging and monitoring (writes to stderr to avoid corrupting JSON-RPC messages)
- Extensible Architecture: Easy to add new tools and controllers
- Proper Error Handling: Comprehensive error handling for both protocol and tool execution errors
Tools Available
customer_search
Searches for customers in D365 Commerce based on provided search criteria.
Parameters:
customerSearchCriteria
(required): Object containing search parameterssearchText
(optional): General search text to find customersaccountNumber
(optional): Customer account numberemail
(optional): Customer email addressphone
(optional): Customer phone numberextensionProperties
(optional): Array of additional properties
queryResultSettings
(optional): Paging and sorting settingspaging
: Object withskip
(0-ā) andtop
(1-1000) propertiessorting
: Object withfield
andisDescending
properties
Returns: PageResult containing matching GlobalCustomer records with properties like:
- PartyNumber
- RecordId
- AccountNumber
- FullName
- FullAddress
- Phone
- CustomerTypeValue
- And more...
Project Structure
McpCommerceServer/
āāā Controllers/
ā āāā CustomerController.cs # Customer-related operations
āāā Models/
ā āāā CustomerDataModels.cs # D365 Commerce customer data models
āāā Mcp/
ā āāā McpModels.cs # MCP protocol models
āāā Services/
ā āāā McpServer.cs # Main MCP server implementation
āāā Program.cs # Application entry point
āāā McpCommerceServer.csproj # Project file
MCP Compliance
This server implements the MCP 2025-06-18 specification with:
- ā Protocol Version: 2025-06-18
- ā
Initialization Flow: Proper
initialize
āinitialized
notification sequence - ā
Tool Capabilities: Declares
tools
capability withlistChanged
support - ā JSON-RPC 2.0: Compliant message format
- ā
Structured Tool Definitions: Includes
name
,title
,description
, and detailedinputSchema
- ā Error Handling: Both protocol errors and tool execution errors
- ā Logging Safety: Writes only to stderr to avoid corrupting STDIO transport
Getting Started
Prerequisites
- .NET 8.0 SDK
- Visual Studio Code or Visual Studio
Building the Project
dotnet build McpCommerceServer.csproj
Running the Server
dotnet run --project McpCommerceServer.csproj
The server will start and listen for MCP protocol messages on standard input/output.
Publishing
dotnet publish McpCommerceServer.csproj -c Release -o ./publish --self-contained false
Implementation Status
- ā Basic MCP server infrastructure
- ā Customer search tool structure
- ā ļø Customer search logic (placeholder implementation)
- ā D365 Commerce API integration
- ā Authentication and authorization
- ā Additional customer tools (CreateEntity, UpdateEntity, etc.)
Next Steps
- Implement D365 Commerce Integration: Add actual API calls to D365 Commerce services
- Add Authentication: Implement proper authentication for D365 Commerce
- Expand Customer Tools: Add the remaining customer controller methods
- Error Handling: Enhance error handling and validation
- Testing: Add unit and integration tests
- Configuration: Add configuration management for connection strings and settings
Configuration
The application uses .NET's built-in configuration system. You can add configuration through:
appsettings.json
- Environment variables
- Command line arguments
Example configuration structure:
{
"D365Commerce": {
"BaseUrl": "https://your-d365-commerce-instance.com",
"ClientId": "your-client-id",
"ClientSecret": "your-client-secret",
"TenantId": "your-tenant-id"
}
}
License
This project is licensed under the MIT License.