Fix transport_security blocking non-localhost bindings
When binding to a non-localhost host, FastMCP's auto-set restrictive transport_security causes external connections to be rejected with 421. Reset it to None so hosts like host.docker.internal are accepted.
This commit is contained in:
@@ -532,6 +532,11 @@ if __name__ == "__main__":
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
if args.host:
|
if args.host:
|
||||||
mcp.settings.host = args.host
|
mcp.settings.host = args.host
|
||||||
|
if args.host not in ("127.0.0.1", "localhost", "::1"):
|
||||||
|
# FastMCP auto-sets restrictive transport_security for localhost at init time.
|
||||||
|
# Reset it when binding to a non-localhost address so external hosts
|
||||||
|
# (e.g. host.docker.internal) are not rejected with 421.
|
||||||
|
mcp.settings.transport_security = None
|
||||||
if args.port:
|
if args.port:
|
||||||
mcp.settings.port = args.port
|
mcp.settings.port = args.port
|
||||||
mcp.run(transport=args.transport)
|
mcp.run(transport=args.transport)
|
||||||
|
|||||||
Reference in New Issue
Block a user