Skip to content

Commit 60c7475

Browse files
committed
Disable MCP DNS rebinding protection for k8s ingress
1 parent 552b3c1 commit 60c7475

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

server.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,16 @@
44
import uvicorn
55
from contextlib import contextmanager
66
from mcp.server.fastmcp import FastMCP
7-
from starlette.middleware.trustedhost import TrustedHostMiddleware
7+
from mcp.server.transport_security import TransportSecuritySettings
88

9-
# Initialize MCP Server
10-
mcp = FastMCP("DuckDB-S3-Geo-Isolated")
9+
# Initialize MCP Server with disabled DNS rebinding protection
10+
# (we're behind a k8s ingress with its own security)
11+
mcp = FastMCP(
12+
"DuckDB-S3-Geo-Isolated",
13+
transport_security=TransportSecuritySettings(
14+
enable_dns_rebinding_protection=False
15+
)
16+
)
1117

1218
# -------------------------------------------------------------------------
1319
# 1. LOAD CONFIG (Read-Only Global State)
@@ -99,10 +105,6 @@ def query(sql_query: str) -> str:
99105
# It supports both GET (handshake) and POST (messages) on the same URL.
100106
app = mcp.streamable_http_app()
101107

102-
# Disable host header validation for k8s ingress
103-
# The app has built-in host validation that needs to be disabled
104-
app.allowed_hosts = ["*"]
105-
106108
uvicorn.run(
107109
app,
108110
host="0.0.0.0",

0 commit comments

Comments
 (0)