nginx: match the MCP location with or without a trailing slash
claude.ai strips the trailing slash from the connector URL, so a location of /mcp/<secret>/ missed and fell to the 301 catch-all. Use a regex (^/mcp/<secret>/?(.*)$) that matches both and normalises onto the FastMCP root. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
77b42a8758
commit
25a73fe416
@@ -33,10 +33,11 @@ server {
|
||||
}
|
||||
|
||||
# --- MCP server (claude.ai cooking-mode connector) ---
|
||||
# Trailing slashes on both sides strip the secret prefix, so the FastMCP
|
||||
# service (serving at "/") sees clean paths.
|
||||
location /mcp/REPLACE_WITH_LONG_SECRET/ {
|
||||
proxy_pass http://127.0.0.1:8765/;
|
||||
# Regex so it matches with OR without a trailing slash — claude.ai stores
|
||||
# the connector URL without one. Whatever follows the secret is normalised
|
||||
# onto the FastMCP root (the service serves at "/").
|
||||
location ~ ^/mcp/REPLACE_WITH_LONG_SECRET/?(?<mcp_rest>.*)$ {
|
||||
proxy_pass http://127.0.0.1:8765/$mcp_rest$is_args$args;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
|
||||
Reference in New Issue
Block a user