From 6d7ccfe390195d480671ed3bf711dd02d731dcd8 Mon Sep 17 00:00:00 2001 From: Maurizio Albari Date: Mon, 26 Jan 2026 13:27:40 +0100 Subject: [PATCH 1/2] fix(qr-server): use stable mcp SDK from PyPI - Replace git-based mcp dependency with mcp>=1.26.0 from PyPI for stability - Remove TransportSecuritySettings that was blocking browser connections - Keep simple FastMCP initialization like other Python examples Fixes ModuleNotFoundError and 403 Forbidden errors when connecting from basic-host --- examples/qr-server/server.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/examples/qr-server/server.py b/examples/qr-server/server.py index 02384c7b..d2814139 100755 --- a/examples/qr-server/server.py +++ b/examples/qr-server/server.py @@ -2,7 +2,7 @@ # /// script # requires-python = ">=3.10" # dependencies = [ -# "mcp @ git+https://github.com/modelcontextprotocol/python-sdk@main", +# "mcp>=1.26.0", # "qrcode[pil]>=8.0", # "uvicorn>=0.34.0", # "starlette>=0.46.0", @@ -19,7 +19,6 @@ import qrcode import uvicorn from mcp.server.fastmcp import FastMCP -from mcp.server.transport_security import TransportSecuritySettings from mcp import types from starlette.middleware.cors import CORSMiddleware @@ -162,11 +161,7 @@ def view() -> str: mcp.run(transport="stdio") else: # HTTP mode for basic-host (default) - with CORS - # Allow Docker bridge IP for container-to-host communication - security = TransportSecuritySettings( - allowed_hosts=["127.0.0.1:*", "localhost:*", "[::1]:*", "172.17.0.1:*"] - ) - app = mcp.streamable_http_app(stateless_http=True, transport_security=security) + app = mcp.streamable_http_app() app.add_middleware( CORSMiddleware, allow_origins=["*"], From 090ef555ab2dd9017660823217c475dcd78780e4 Mon Sep 17 00:00:00 2001 From: Maurizio Albari Date: Mon, 26 Jan 2026 14:07:35 +0100 Subject: [PATCH 2/2] fix(qr-server): use stable mcp SDK from PyPI - Replace git-based mcp dependency with mcp>=1.26.0 from PyPI - Add stateless_http=True for proper HTTP transport handling - Remove TransportSecuritySettings that blocked browser connections --- examples/qr-server/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/qr-server/server.py b/examples/qr-server/server.py index d2814139..d282d1ad 100755 --- a/examples/qr-server/server.py +++ b/examples/qr-server/server.py @@ -26,7 +26,7 @@ HOST = os.environ.get("HOST", "0.0.0.0") # 0.0.0.0 for Docker compatibility PORT = int(os.environ.get("PORT", "3001")) -mcp = FastMCP("QR Code Server") +mcp = FastMCP("QR Code Server", stateless_http=True) # Embedded View HTML for self-contained usage (uv run or unbundled) EMBEDDED_VIEW_HTML = """