Skip to content

Commit 09a3614

Browse files
committed
Add TrustedHostMiddleware to accept ingress host headers
1 parent c7c5630 commit 09a3614

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

server.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import uvicorn
55
from contextlib import contextmanager
66
from mcp.server.fastmcp import FastMCP
7+
from starlette.middleware.trustedhost import TrustedHostMiddleware
78

89
# Initialize MCP Server
910
mcp = FastMCP("DuckDB-S3-Geo-Isolated")
@@ -97,6 +98,10 @@ def query(sql_query: str) -> str:
9798
# Streamable HTTP uses a single endpoint (default: /mcp)
9899
# It supports both GET (handshake) and POST (messages) on the same URL.
99100
app = mcp.streamable_http_app()
101+
102+
# Allow requests from ingress with any host header
103+
app.add_middleware(TrustedHostMiddleware, allowed_hosts=["*"])
104+
100105
uvicorn.run(
101106
app,
102107
host="0.0.0.0",

0 commit comments

Comments
 (0)