From 2b9858e3153454a99ea14e0c9ef9e69db78e76c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vignir=20M=C3=A1r=20L=C3=BD=C3=B0sson?= Date: Mon, 9 Mar 2026 19:10:40 +0100 Subject: [PATCH 1/2] Fix BC MCP proxy protocol version mismatch (HTTP 400) Override MCP SDK's default protocol version ("2025-11-25") to "2024-11-05" during the initialize handshake, since Business Central's MCP server only accepts the older protocol version. Bump version to 0.1.3. Co-Authored-By: Claude Opus 4.6 --- samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py | 15 ++++++++++++++- samples/BcMCPProxyPython/pyproject.toml | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py b/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py index 23c4aa50..6c6496dd 100644 --- a/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py +++ b/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py @@ -6,12 +6,18 @@ from urllib.parse import unquote import httpx +import mcp.types from mcp.client.session import ClientSession from mcp.client.streamable_http import streamablehttp_client from mcp.server import Server from mcp.server.stdio import stdio_server from mcp.types import Implementation +# Business Central's MCP server only accepts protocol version "2024-11-05". +# Newer versions of the MCP SDK default to a later protocol version which BC +# rejects with HTTP 400. We override the version before calling initialize(). +_BC_PROTOCOL_VERSION = "2024-11-05" + from .auth import TokenProvider, create_token_provider from .config import ProxyConfig @@ -56,7 +62,14 @@ async def run_proxy(config: ProxyConfig) -> None: remote_write, client_info=client_info, ) as remote_session: - init_result = await remote_session.initialize() + # Temporarily override the protocol version so BC accepts the + # initialize handshake (it only supports "2024-11-05"). + original_protocol_version = mcp.types.LATEST_PROTOCOL_VERSION + mcp.types.LATEST_PROTOCOL_VERSION = _BC_PROTOCOL_VERSION + try: + init_result = await remote_session.initialize() + finally: + mcp.types.LATEST_PROTOCOL_VERSION = original_protocol_version logger.debug("Connected to remote MCP server (protocol %s)", init_result.protocolVersion) instructions = config.instructions or ( diff --git a/samples/BcMCPProxyPython/pyproject.toml b/samples/BcMCPProxyPython/pyproject.toml index 17cd0b5e..eafe1a89 100644 --- a/samples/BcMCPProxyPython/pyproject.toml +++ b/samples/BcMCPProxyPython/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "bc-mcp-proxy" -version = "0.1.2" +version = "0.1.3" description = "Python-based MCP stdio proxy for Microsoft Dynamics 365 Business Central" readme = "README.md" requires-python = ">=3.10" From f7e497a445b77f5debb4a6bdaba107dabe4b2361 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vignir=20M=C3=A1r=20L=C3=BD=C3=B0sson?= Date: Mon, 9 Mar 2026 19:18:42 +0100 Subject: [PATCH 2/2] Add clarifying comment for mcp.types module import Co-Authored-By: Claude Opus 4.6 --- samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py b/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py index 6c6496dd..b1dd2a0f 100644 --- a/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py +++ b/samples/BcMCPProxyPython/bc_mcp_proxy/proxy.py @@ -6,7 +6,7 @@ from urllib.parse import unquote import httpx -import mcp.types +import mcp.types # module-level import so we can patch LATEST_PROTOCOL_VERSION in-place from mcp.client.session import ClientSession from mcp.client.streamable_http import streamablehttp_client from mcp.server import Server