Model Context Protocol server for Microsoft Dynamics 365 Business Central via WebUI protocol
Features β’ Quick Start β’ Tools β’ Documentation β’ Architecture
BC WebClient MCP is a Model Context Protocol (MCP) server that enables AI assistants like Claude to interact with Microsoft Dynamics 365 Business Central through a clean, intuitive interface. Built by reverse-engineering BC's WebUI WebSocket protocol, it provides real-time access to ERP data, business logic, and operations.
The Model Context Protocol is an open standard that enables AI assistants to securely connect with external data sources and tools. This server implements MCP to bridge Claude with Business Central's internal APIs.
Business Central's web client uses an undocumented WebSocket protocol for all UI operations. This project reverse-engineers the WebUI protocol (not official APIs) to:
- β Enable AI-driven ERP automation - Let Claude interact with BC data naturally
- β No custom extensions required - Works with vanilla BC installations
- β Real-time operations - Leverage BC's live WebSocket connection
- β Production-ready - Built on BC's actual internal protocol (the same one the web UI uses)
- Workflow Tracking - Track multi-step business processes with
start_workflow,get_workflow_state,end_workflow - Dialog Handling - Full
handle_dialogtool for template selection, confirmations, and prompts - Document Line Items - Write to subpages/repeaters with
subpage,lineBookmark,lineNoparameters - Document Pages - Full support for Sales Orders, Purchase Orders with header + line items
- MCP Resources - Access BC schema, workflows, and session state
- MCP Prompts - Guided workflows for common operations
- Multi-Page Support - Card, List, and Document pages all work reliably
|
|
|
|
Get up and running with BC WebClient MCP in 5 minutes.
- Node.js 18 or higher (Download)
- Business Central v27.0 (other versions may work but are not tested - protocol specifics are BC 27)
- Valid BC credentials with web client access
- Claude Desktop (Download) or any MCP-compatible client
The MCP server runs directly via npx - no installation needed. Just configure Claude Desktop in the next step.
Find your Claude Desktop config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json - Linux:
~/.config/Claude/claude_desktop_config.json
Edit the config file and add the MCP server (replace with your BC credentials):
{
"mcpServers": {
"business-central": {
"command": "cmd",
"args": [
"/c",
"npx",
"bc-webclient-mcp@latest"
],
"env": {
"BC_BASE_URL": "http://your-bc-server/BC/",
"BC_USERNAME": "your-username",
"BC_PASSWORD": "your-password",
"BC_TENANT_ID": "default"
}
}
}
}Note: On macOS/Linux, use
"command": "sh"and"args": ["-c", "npx bc-webclient-mcp@latest"]instead.
Why npx?
- β No installation required - runs directly from npm
- β Always uses the latest version automatically
- β No need to manage global packages
Important notes:
- Use
BC_USERNAME=username, NOTdomain\username - The tenant is handled automatically in the URL parameter
- For BC Online, use your full BC URL (e.g.,
https://businesscentral.dynamics.com/...)
Restart Claude Desktop completely to load the MCP server.
Open a new chat in Claude Desktop and try:
Search for customer pages
You should see Claude using the search_pages tool and returning BC pages. If the MCP server appears in the tools list (π§ icon), you're all set!
Try these commands to explore v2 capabilities:
Document Pages with Line Items:
Read Sales Order 101001 with all line items
Smart Search:
Find all pages related to inventory management
Resources (Schema Discovery):
What BC pages are available?
(Uses the bc://schema/pages resource)
Guided Workflows (Prompts):
Create a new customer named Acme Corporation
(Uses the create_bc_customer prompt for step-by-step guidance)
Data Operations:
Show me customers where balance is over 10000
Field Updates:
Update customer 10000's credit limit to 50000
MCP server not showing up in Claude Desktop?
- Check the config file syntax is valid JSON
- Restart Claude Desktop completely (close all windows)
- Verify Node.js is installed:
node --version(requires 18+) - Check Claude Desktop logs: View β Developer β Toggle Developer Tools β Console
Connection failed?
- Verify BC is accessible: Open
http://your-bc-server/BC/in a browser - Check
BC_BASE_URLincludes the/BC/path - Ensure firewall allows WebSocket connections
Authentication error?
- Test login in browser first
- Use username WITHOUT domain prefix (just
username) - Verify tenant ID matches your BC installation (
defaultfor on-prem)
"TypeScript errors" when building?
- Run
npx tsc --noEmitto see detailed errors - Ensure Node.js version is 18 or higher:
node --version
For more troubleshooting, see CLAUDE.md
For development, testing unreleased features, or contributing to the project:
# Clone the repository
git clone https://github.com/SShadowS/bc-webclient-mcp-server.git
cd bc-webclient-mcp-server
# Install dependencies
npm install
# Build the TypeScript project
npm run buildThen in Claude Desktop config, use the local path:
{
"mcpServers": {
"business-central": {
"command": "node",
"args": ["C:\\path\\to\\bc-webclient-mcp-server\\dist\\index.js"],
"env": {
"BC_BASE_URL": "http://your-bc-server/BC/",
"BC_USERNAME": "your-username",
"BC_PASSWORD": "your-password",
"BC_TENANT_ID": "default"
}
}
}
}Note: Use full absolute paths with double backslashes on Windows.
The MCP server provides 10 tools for AI interaction:
| Tool | Description | Level |
|---|---|---|
search_pages |
Search for pages using Tell Me (Alt+Q) | Discovery |
get_page_metadata |
Get page structure, fields, and actions | Discovery |
read_page_data |
Read data from a page (with server-side filtering) | Read |
write_page_data |
Write field values with validation, supports subpage/line operations | Write |
execute_action |
Execute page actions (New, Edit, Post, etc.) | Action |
select_and_drill_down |
Navigate between pages via drill-down | Navigation |
handle_dialog |
Handle BC dialogs (template selection, confirmations) | Dialog |
| Tool | Description |
|---|---|
start_workflow |
Begin tracking a multi-step business process |
get_workflow_state |
Query workflow state, history, and unsaved changes |
end_workflow |
Complete workflow with final status |
| Tool | Description |
|---|---|
create_record_by_field_name |
Create records using field names (convenience wrapper) |
The MCP server provides tools at multiple levels:
Core Tools - Essential primitives for BC interaction:
write_page_data- Write fields with immediate validation, subpage/line supportexecute_action- Execute any page action with auto-resolved controlPathhandle_dialog- Handle dialogs with row selection and button clicks
Workflow Tools - Track multi-step business processes:
start_workflowβ perform operations withworkflowIdβend_workflow- Tracks unsaved changes, operation history, and errors
Convenience Tools - Higher-level wrappers:
create_record_by_field_name- Simplified record creation using field names
Once connected, you can interact with Business Central through Claude:
You: "Search for customer-related pages"
Claude: [Uses search_pages tool]
Found 21 customer pages:
- Page 21: Customer Card
- Page 22: Customer List
...
You: "Show me customers where balance is over 10000"
Claude: [Uses read_page_data with filters]
Found 5 customers with balance > 10000:
1. Contoso Ltd - Balance: 15,234.50
2. Fabrikam Inc - Balance: 12,890.00
...
You: "Update customer 10000's credit limit to 50000"
Claude: [Uses get_page_metadata, execute_action("Edit"), write_page_data, execute_action("Save")]
Updated customer successfully:
- Opened Customer Card for customer 10000
- Switched to Edit mode
- Updated Credit Limit: 50,000.00
- Saved changes
You: "Add a line to Sales Order 101001"
Claude: [Uses write_page_data with subpage parameter]
Added line to Sales Order:
- Item No.: 1000
- Quantity: 5
- Line created successfully
This MCP server implements the MCP 2025 user consent requirement to ensure users maintain control over all data-modifying operations.
-
Tool Classification: Each tool is classified by risk level:
- π’ Low Risk (read-only) - No consent required
- π‘ Medium Risk (writes) - User approval required
- π΄ High Risk (irreversible) - User approval + warning
-
Consent Enforcement: Claude Desktop shows approval dialog before executing write operations:
β οΈ Tool Execution Request Claude wants to execute: create_record Create a new record in Business Central? This will add data to your Business Central database. [Deny] [Allow] -
Audit Trail: All approved operations are logged with:
- Timestamp
- Tool name
- Input summary (sanitized)
- Execution result
| Tool | Requires Consent | Risk Level | Reason |
|---|---|---|---|
| search_pages | No | Low | Read-only discovery |
| get_page_metadata | No | Low | Read metadata only |
| read_page_data | No | Low | Read-only data access |
| start_workflow | No | Low | Creates tracking state only |
| get_workflow_state | No | Low | Read workflow state |
| end_workflow | No | Low | Marks workflow complete |
| write_page_data | Yes | Medium | Direct field writes |
| select_and_drill_down | Yes | Medium | Navigation with selection |
| handle_dialog | Yes | Medium | Can bypass safety prompts |
| create_record_by_field_name | Yes | Medium | Creates new data |
| execute_action | Yes | High | Can trigger Post/Delete |
Audit logs are available via structured logging (Pino). Example log entry:
{
"level": "info",
"msg": "Tool execution audit",
"toolName": "create_record",
"userApproved": true,
"result": "success",
"timestamp": "2025-11-08T10:30:45.123Z",
"inputSummary": {
"pageId": "21",
"fields": "[Object]"
}
}Sensitive Data Protection: The audit logger automatically redacts passwords, tokens, API keys, secrets, and other credential fields.
For more details, see docs/TOOL-CONSENT-CLASSIFICATION.md and docs/USER-CONSENT-GUIDE.md.
βββββββββββββββββββββββββββββββββββββββ
β Claude Desktop (AI Client) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β MCP Protocol
β (JSON-RPC over stdio)
ββββββββββββββββΌβββββββββββββββββββββββ
β MCP Server (Node.js) β
β ββββββββββββββββββββββββββββββ β
β β Tool Registry β β
β β - search_pages β β
β β - filter_list β β
β β - get_page_metadata β β
β β - ... β β
β ββββββββββββββ¬ββββββββββββββββ β
β β β
β ββββββββββββββΌββββββββββββββββ β
β β BCRawWebSocketClient β β
β β - Session management β β
β β - Event-driven handlers β β
β β - Gzip compression β β
β ββββββββββββββ¬ββββββββββββββββ β
βββββββββββββββββΌββββββββββββββββββββββ
β WebSocket + JSON-RPC
β (BC Internal Protocol)
βββββββββββββββββΌββββββββββββββββββββββ
β Business Central Web Service β
β /BC/csh endpoint (WebSocket) β
βββββββββββββββββββββββββββββββββββββββ
BCRawWebSocketClient- Core WebSocket client that mimics browser behaviorMCPServer- MCP protocol implementation (JSON-RPC over stdio)BaseMCPTool- Base class for all MCP tools with error handling- Protocol Parsers - Decode BC's internal handler arrays
- Event Emitters - Handle asynchronous BC responses
- Authentication: Web login flow β Session cookies + CSRF token
- WebSocket Connection: Connect to
/cshwith session credentials - Session Opening: OpenSession request β Extract session identifiers
- Event-Driven Operations: Send Invoke requests β Wait for handler arrays
- Response Parsing: Decompress gzip β Parse handler structures β Extract data
For deep technical details, see:
ARCHITECTURE.md- Complete architecture analysisBC-COPILOT-IMPLEMENTATION.md- BC's internal Copilot protocoldocs/FILTER_METADATA_SOLUTION.md- Filter implementation
- CLAUDE.md - Essential guide for development and troubleshooting
- SETUP.md - Step-by-step setup instructions
- ARCHITECTURE.md - System architecture and design decisions
- BC-COPILOT-IMPLEMENTATION.md - π₯ Must Read! - BC's exact Copilot protocol
- BC-AI-AGENT-ANALYSIS.md - BC's built-in AI agent framework
- docs/FILTER_METADATA_SOLUTION.md - Filter tool implementation
- docs/current/TELLME-SEARCH-STATUS.md - Tell Me search implementation
- Business Central API Documentation
- Model Context Protocol Specification
- WebSocket Protocol RFC 6455
- JSON-RPC 2.0 Specification
bc-poc/
βββ src/
β βββ core/ # Core infrastructure
β β βββ errors.ts # Error types and handling
β β βββ result.ts # Result monad for error handling
β β βββ interfaces.ts # TypeScript interfaces
β βββ services/ # Business logic
β β βββ BCRawWebSocketClient.ts # β Main WebSocket client
β β βββ mcp-server.ts # MCP protocol server
β β βββ stdio-transport.ts # stdin/stdout JSON-RPC transport
β βββ tools/ # MCP tool implementations
β β βββ search-pages-tool.ts
β β βββ filter-list-tool.ts
β β βββ get-page-metadata-tool.ts
β β βββ ...
β βββ protocol/ # BC protocol parsers
β β βββ logical-form-parser.ts
β β βββ handler-types.ts
β βββ types/ # TypeScript type definitions
βββ test/ # Test scripts
βββ docs/ # Detailed documentation
βββ dist/ # Compiled JavaScript (generated)
# Type checking (run frequently!)
npx tsc --noEmit
# Build the project
npm run build
# Run in development mode
npm run dev
# Run tests
npm test
npm run test:coverage
# Test specific functionality
npm run test:invoke # Test Invoke method
npm run test:mcp # Test MCP server- Stub implementations
- Mock functions that don't actually work
- Placeholder code with "not yet implemented" errors
- Tools that are registered but non-functional
Every feature MUST be fully implemented and functional before being committed.
# Run all tests
npm test
# Run specific test suites
npm run test:mcp:client # MCP client integration tests
npm run test:mcp:real # Real BC integration tests
# Test Tell Me search
npx tsx test-tellme-search.ts "customer"
# Test MCP server with real BC connection
npm run test:mcp:real:clientContributions are welcome! Please:
- Read the architecture documentation first
- Follow the existing code style and patterns
- Ensure TypeScript compilation passes (
npx tsc --noEmit) - Add tests for new functionality
- Update documentation as needed
- Use Windows paths when working on Windows
- Run type checking regularly with
npx tsc --noEmit - No stubs or mocks - all implementations must be fully functional
- Read
CLAUDE.mdfor development guidelines - Check existing docs before implementing new features
- β Business Central v27.0 (fully tested and supported)
β οΈ Other versions (v24-v26, v28+) may work but are not tested- Protocol specifics are hardcoded for BC 27
- Older/newer versions may have different WebSocket protocol implementations
- Use at your own risk - contributions for other versions welcome!
- β On-Premises installations (BC 27)
- β Business Central Online (BC 27)
- β NavUserPassword (username/password)
- β Windows Authentication
- β Azure AD (via web login)
No special BC configuration required! The server mimics browser login behavior.
# Test BC connectivity
curl http://your-server/BC/
# Check BC service status (on-prem)
docker exec Cronus27 powershell "Get-Service 'MicrosoftDynamicsNavServer*'"
# Verify WebSocket endpoint
wscat -c ws://your-server/BC/csh"WebSocket connection failed"
- Verify
BC_BASE_URLis correct and includes/BC/path - Ensure BC web client is accessible in browser first
- Check firewall rules
"Authentication failed"
- Test login in browser:
http://your-server/BC/ - Use username WITHOUT domain prefix (just
username, notdomain\username) - Verify tenant ID is correct
"CSRF token not found"
- Ensure BC web client is accessible
- Check if BC requires different authentication
- Clear BC cache and restart services
"OpenSession timeout"
- Verify tenant ID matches your BC installation
- Check BC server logs for errors
- Increase timeout in BCRawWebSocketClient
For more troubleshooting tips, see CLAUDE.md.
This project is licensed under the MIT License - see the LICENSE file for details.
- Built on Microsoft Dynamics 365 Business Central
- Implements the Model Context Protocol by Anthropic
- Inspired by BC's internal Copilot implementation
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: Project Wiki
Made with β€οΈ for the Business Central community