Fix MCP endpoint for Claude.ai connector (serve at root path)

FastMCP defaults to /mcp but Claude.ai sends requests to /.
Add MCP_PATH env var to configure the endpoint path, set to /
in docker-compose for the connector subdomain.
This commit is contained in:
Ryan Malloy 2026-02-23 18:25:14 -07:00
parent baab9abab2
commit 77ad2a6bd1
3 changed files with 5 additions and 3 deletions

View File

@ -5,7 +5,7 @@ dev:
@echo "Starting mcnoaa-tides in development mode..." @echo "Starting mcnoaa-tides in development mode..."
APP_ENV=dev docker compose up -d --build APP_ENV=dev docker compose up -d --build
@echo "Docs: https://$(shell grep DOMAIN .env | head -1 | cut -d= -f2)" @echo "Docs: https://$(shell grep DOMAIN .env | head -1 | cut -d= -f2)"
@echo "MCP: https://mcp.$(shell grep DOMAIN .env | head -1 | cut -d= -f2)/mcp" @echo "MCP: https://mcp.$(shell grep DOMAIN .env | head -1 | cut -d= -f2)/"
@sleep 2 @sleep 2
docker compose logs -f docker compose logs -f
@ -13,7 +13,7 @@ prod:
@echo "Starting mcnoaa-tides in production mode..." @echo "Starting mcnoaa-tides in production mode..."
APP_ENV=prod docker compose up -d --build APP_ENV=prod docker compose up -d --build
@echo "Docs: https://$(shell grep DOMAIN .env | head -1 | cut -d= -f2)" @echo "Docs: https://$(shell grep DOMAIN .env | head -1 | cut -d= -f2)"
@echo "MCP: https://mcp.$(shell grep DOMAIN .env | head -1 | cut -d= -f2)/mcp" @echo "MCP: https://mcp.$(shell grep DOMAIN .env | head -1 | cut -d= -f2)/"
@sleep 3 @sleep 3
docker compose logs --tail=20 docker compose logs --tail=20

View File

@ -39,6 +39,7 @@ services:
- MCP_TRANSPORT=streamable-http - MCP_TRANSPORT=streamable-http
- MCP_HOST=0.0.0.0 - MCP_HOST=0.0.0.0
- MCP_PORT=8000 - MCP_PORT=8000
- MCP_PATH=/
networks: networks:
- caddy - caddy
labels: labels:

View File

@ -73,6 +73,7 @@ def main():
if transport == "streamable-http": if transport == "streamable-http":
host = os.environ.get("MCP_HOST", "0.0.0.0") host = os.environ.get("MCP_HOST", "0.0.0.0")
port = int(os.environ.get("MCP_PORT", "8000")) port = int(os.environ.get("MCP_PORT", "8000"))
mcp.run(transport="streamable-http", host=host, port=port) path = os.environ.get("MCP_PATH", "/mcp")
mcp.run(transport="streamable-http", host=host, port=port, path=path)
else: else:
mcp.run() mcp.run()