Skip to content

Commit 3211d8b

Browse files
fix(mcp): disable dns rebinding protection
disable dns rebinding protection in transport settings and simplify host/origin config. remove unused os import and update comment to note that jwt auth middleware provides the primary security gate. this reduces brittle host/origin allowlists and avoids relying on dns rebinding checks while keeping jwt-based authentication as the protection mechanism.
1 parent b360e63 commit 3211d8b

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

  • src/plurality_mcp_server

src/plurality_mcp_server/app.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
11
import asyncio
2-
import os
32

43
from mcp.server.fastmcp import FastMCP
54
from mcp.server.transport_security import TransportSecuritySettings
65
from plurality_mcp_server.auth import JWTAuthMiddleware, prewarm_jwks
76
from plurality_mcp_server.tools import register_tools
87

98
# ── MCP app ──
10-
# host="0.0.0.0" for container networking; transport_security allows the
11-
# public domain forwarded by the reverse proxy (Traefik).
12-
_mcp_resource_url = os.getenv("MCP_RESOURCE_URL", "http://localhost:5051")
9+
# host="0.0.0.0" for container networking; DNS rebinding protection is
10+
# disabled because JWT auth middleware is the real security gate.
1311
mcp_app = FastMCP(
1412
name="mcp",
1513
stateless_http=True,
1614
json_response=True,
1715
host="0.0.0.0",
1816
port=5051,
1917
transport_security=TransportSecuritySettings(
20-
enable_dns_rebinding_protection=True,
21-
allowed_hosts=[
22-
"localhost:*",
23-
"127.0.0.1:*",
24-
_mcp_resource_url.split("//")[-1], # e.g. "dev.plurality.network"
25-
],
26-
allowed_origins=[
27-
"http://localhost:*",
28-
"http://127.0.0.1:*",
29-
_mcp_resource_url, # e.g. "https://dev.plurality.network"
30-
],
18+
enable_dns_rebinding_protection=False,
3119
),
3220
)
3321
register_tools(mcp_app)

0 commit comments

Comments
 (0)