Skip to content

Commit ee5d3f8

Browse files
authored
fix: Python server dependency resolution and Docker host validation (#333)
* fix(say-server): add --index flag to uv run for PyPI resolution The pocket-tts dependency wasn't resolving without explicit --index flag when invoked via npm scripts. * fix(qr-server): allow Docker bridge IP in transport security Add 172.17.0.1:* to allowed_hosts to fix 421 Misdirected Request errors when the server is accessed from Docker containers.
1 parent cfcbc96 commit ee5d3f8

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

examples/qr-server/server.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import qrcode
2020
import uvicorn
2121
from mcp.server.fastmcp import FastMCP
22+
from mcp.server.transport_security import TransportSecuritySettings
2223
from mcp import types
2324
from starlette.middleware.cors import CORSMiddleware
2425

@@ -161,7 +162,11 @@ def view() -> str:
161162
mcp.run(transport="stdio")
162163
else:
163164
# HTTP mode for basic-host (default) - with CORS
164-
app = mcp.streamable_http_app(stateless_http=True)
165+
# Allow Docker bridge IP for container-to-host communication
166+
security = TransportSecuritySettings(
167+
allowed_hosts=["127.0.0.1:*", "localhost:*", "[::1]:*", "172.17.0.1:*"]
168+
)
169+
app = mcp.streamable_http_app(stateless_http=True, transport_security=security)
165170
app.add_middleware(
166171
CORSMiddleware,
167172
allow_origins=["*"],

examples/say-server/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
},
1111
"license": "MIT",
1212
"scripts": {
13-
"start": "uv run server.py",
14-
"dev": "uv run server.py",
13+
"start": "uv run --index https://pypi.org/simple server.py",
14+
"dev": "uv run --index https://pypi.org/simple server.py",
1515
"build": "echo 'No build step needed for Python server'"
1616
},
1717
"dependencies": {

0 commit comments

Comments
 (0)