From 4698107d6ac961b345185397f1d9ac4e668c4199 Mon Sep 17 00:00:00 2001 From: albnnc Date: Wed, 8 Jul 2026 19:51:16 +0300 Subject: [PATCH] fix: allow all hosts --- owa_mcp/server.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/owa_mcp/server.py b/owa_mcp/server.py index 361f576..da349c6 100644 --- a/owa_mcp/server.py +++ b/owa_mcp/server.py @@ -19,6 +19,7 @@ from __future__ import annotations import argparse import logging +import os from collections.abc import AsyncIterator from contextlib import asynccontextmanager from dataclasses import dataclass @@ -26,6 +27,7 @@ from dataclasses import dataclass from mcp.server.auth.provider import TokenVerifier from mcp.server.auth.settings import AuthSettings from mcp.server.fastmcp import FastMCP +from mcp.server.transport_security import TransportSecuritySettings from owa_mcp.owa_client import OWAClient from owa_mcp.server_lifecycle import ( @@ -74,7 +76,21 @@ _lifespan_cookie_file: str | None = None # ── Module-level MCP server (imported by all tool modules) ──────────────── -mcp: FastMCP = FastMCP("owa", lifespan=app_lifespan) +mcp: FastMCP = FastMCP( + "owa", + lifespan=app_lifespan, + transport_security=TransportSecuritySettings( + enable_dns_rebinding_protection=False, + allowed_hosts=[], + allowed_origins=[], + ), +) + +# Force-disable DNS rebinding protection even if FastMCP auto-config +# overwrites it (e.g. when --host is a non-localhost address). +mcp.settings.transport_security = TransportSecuritySettings( + enable_dns_rebinding_protection=False, +) def _parse_args(argv=None) -> argparse.Namespace: @@ -207,6 +223,10 @@ def main(argv=None) -> None: mcp.settings.port = args.port # ── Run transport ───────────────────────────────────────────────────── + # Allow all X-Forwarded-* headers (needed when behind a proxy or + # when clients connect with a non-default Host header). + os.environ["FORWARDED_ALLOW_IPS"] = "*" + match args.transport: case "stdio": mcp.run()