Fix BC MCP proxy to target current MCP server endpoint#354
Open
DmitryKatson wants to merge 1 commit into
Open
Conversation
Microsoft moved the Business Central MCP server from api.businesscentral.dynamics.com/v2.0/<env>/mcp to a dedicated host at mcp.businesscentral.dynamics.com, with environment routing via HTTP headers (TenantId, EnvironmentName, Company). The previous proxy URL returns 400 Bad Request after a successful sign-in, even when the Azure app registration is correctly configured. Update both the Python (bc-mcp-proxy) and .NET (BcMCPProxy) samples: - Default Url/BaseUrl -> https://mcp.businesscentral.dynamics.com - Default scope -> https://mcp.businesscentral.dynamics.com/.default - Drop the /v2.0/<env>/mcp path suffix from the request URL - Send TenantId and EnvironmentName headers in addition to Company Verified end-to-end against a sandbox environment: the proxy completes the MCP initialize handshake, lists tools, and successfully invokes List_Customers / List_Items via bc_actions_invoke.
4a3a6e4 to
652727b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Business Central MCP proxy samples (Python
bc-mcp-proxyand .NETBcMCPProxy) currently fail with HTTP 400 Bad Request as soon as they try to talk to Business Central, even when device-code sign-in succeeds and the Azure app registration is configured exactly as documented.Root cause: Microsoft moved the BC MCP server. The proxies still call the old preview URL pattern, which BC no longer accepts.
https://api.businesscentral.dynamics.com/v2.0/<env>/mcphttps://mcp.businesscentral.dynamics.comCompanyheader onlyTenantId,EnvironmentName,CompanyHTTP headershttps://api.businesscentral.dynamics.com/.defaulthttps://mcp.businesscentral.dynamics.com/.defaultThis matches the official guidance in Connect to Business Central MCP server with non-Microsoft clients and the connection string emitted by the Model Context Protocol (MCP) Server Configurations page in BC.
Changes
samples/BcMCPProxyPython/bc_mcp_proxy/config.py— updatebase_urlandtoken_scopedefaultssamples/BcMCPProxyPython/bc_mcp_proxy/proxy.py— drop/v2.0/<env>/mcppath suffix, addTenantId/EnvironmentNameheaderssamples/BcMCPProxyPython/README.md— update parameter table defaults to matchsamples/BcMCPProxy/Models/ConfigOptions.cs— updateUrlandTokenScopedefaultssamples/BcMCPProxy/Runtime/MCPServerProxy.cs— same URL/header changes for the .NET proxyTest plan
Verified end-to-end against a sandbox BC environment:
mcp.businesscentral.dynamics.comresourceinitializehandshake completes againstmcp.businesscentral.dynamics.com(HTTP 200, server identifies itself asMicrosoft Dynamics 365 Business Centralv28.0)tools/listreturns the BC dynamic tools (bc_actions_search,bc_actions_describe,bc_actions_invoke)bc_actions_searchreturns matching action namesbc_actions_describereturns the action schemabc_actions_invokeonList_Customers_PAG30009returns real CRONUS customer data (3 of 5 records)bc_actions_invokeonList_Items_PAG30008returns real CRONUS item data (3 of 80 records)Existing app registrations that already have
Dynamics 365 Business Central→user_impersonation(delegated) continue to work — no Azure changes are required for end users.Reproduction
Before this PR (with valid app registration and successful device-code sign-in):
After this PR:
Notes for maintainers
pyproject.tomlversion is unchanged (0.1.2). Once this PR is merged, the package will need a version bump and a PyPI release so end users get the fix without rebuilding from source.BcMCPProxy.exepublished artifact will likewise need a rebuild.