razaali10 commited on
Commit
c6a92ae
·
verified ·
1 Parent(s): a152767

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -33,6 +33,7 @@ from starlette.applications import Starlette
33
  from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse
34
  from starlette.routing import Route
35
 
 
36
  from epanet_mcp.server import mcp
37
 
38
  # ---------------------------------------------------------------------------
@@ -49,6 +50,14 @@ AUTH_ENABLED = bool(API_KEY) or REQUIRE_AUTH
49
  # Keep session state so load_network -> get_summary -> run_sim share one registry.
50
  mcp.settings.stateless_http = False
51
 
 
 
 
 
 
 
 
 
52
  streamable_app = mcp.streamable_http_app() # serves /mcp (+ owns session mgr lifespan)
53
  sse_app = mcp.sse_app() # serves /sse + /messages/
54
 
 
33
  from starlette.responses import HTMLResponse, JSONResponse, PlainTextResponse
34
  from starlette.routing import Route
35
 
36
+ from mcp.server.transport_security import TransportSecuritySettings
37
  from epanet_mcp.server import mcp
38
 
39
  # ---------------------------------------------------------------------------
 
50
  # Keep session state so load_network -> get_summary -> run_sim share one registry.
51
  mcp.settings.stateless_http = False
52
 
53
+ # HF Spaces sit behind a proxy, so the inbound Host header is the public
54
+ # *.hf.space domain. FastMCP's DNS-rebinding protection allow-lists only
55
+ # localhost by default and would reject every real request with 421
56
+ # "Invalid Host header". Disable it (HF terminates TLS and controls Host).
57
+ mcp.settings.transport_security = TransportSecuritySettings(
58
+ enable_dns_rebinding_protection=False,
59
+ )
60
+
61
  streamable_app = mcp.streamable_http_app() # serves /mcp (+ owns session mgr lifespan)
62
  sse_app = mcp.sse_app() # serves /sse + /messages/
63