MCP Shipyard
← Guides

MCP endpoint returns 405 or 307: transport mismatch and trailing slash

Why an MCP endpoint answers 405 Method Not Allowed or a 307 redirect, how the Streamable HTTP rules explain it, and curl checks for method, Accept header, path and slash.

transportstreamable-httpsse405307redirecttroubleshooting

A 405 on an MCP endpoint usually means the client used a method the path does not serve, or the server speaks the older HTTP+SSE transport while the client sent a Streamable HTTP POST. A 307 usually means a framework redirected /mcp to /mcp/ (or the reverse). Make the exact URL users enter answer POST directly, with no redirect.

Some 405 responses are correct. The spec requires them in two places, covered below, so check which request failed before changing anything.

What the Streamable HTTP spec says

From the MCP transports spec (2025-11-25 revision, source):

  • The server provides a single MCP endpoint that supports POST and GET.
  • The client must use POST to send JSON-RPC messages, and must send an Accept header listing both application/json and text/event-stream.
  • For a JSON-RPC notification or response, the server returns 202 Accepted with no body.
  • A client may issue GET to open an SSE stream. The server must either answer with Content-Type: text/event-stream or return 405 Method Not Allowed, which means "no SSE stream here". So a 405 on GET is valid.
  • A client may send DELETE to end a session, and the server may answer 405 to say it does not allow that.
  • A server that has expired a session must answer 404 to requests carrying that session ID.
  • For backwards compatibility, a client that gets 400, 404 or 405 to its initial POST may try a GET to the same URL, expecting an SSE stream with an endpoint event, which is how it detects the old HTTP+SSE transport.

That last rule explains many confusing logs: a POST that returns 405 makes a spec-following client treat your server as legacy SSE, then fail on the GET. The SSE-era transport is deprecated in the 2026-07-28 spec revision; see the SSE to Streamable HTTP migration guide.

Diagnosis tree

1. Which request failed?

Look at the method and path in your access log, or run each request yourself.

# POST with the required Accept header: should be 200 or 401, never 405
curl -i -X POST https://mcp.acme.example/mcp \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

# GET: 405 is acceptable, or 200 text/event-stream
curl -i -N https://mcp.acme.example/mcp -H 'Accept: text/event-stream'

# DELETE: 405 is acceptable
curl -i -X DELETE https://mcp.acme.example/mcp

If only GET or DELETE returns 405, that is spec-conformant and not your problem. Look elsewhere.

2. Does POST return 405?

Possible causes:

  • Wrong route registered. The handler is mounted on GET only, or on /sse and /messages (the old transport), with nothing on /mcp.
  • Legacy transport only. The server still runs HTTP+SSE. Add a Streamable HTTP endpoint at one path. Claude's directory policy accepts the old transport only temporarily (the scanner's rule text cites policy 5.F).
  • Proxy or CDN rule. Some gateways and static hosting layers only allow GET and HEAD on a path. Test the origin directly and compare.
  • Different path. A mount prefix, such as /api/mcp, differs from the URL you registered.
curl -i -X OPTIONS https://mcp.acme.example/mcp

An Allow header on the 405 response lists the methods the route accepts.

3. Does the endpoint return 307 or 308?

curl -si -X POST https://mcp.acme.example/mcp -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' -d '{}' | head -5
curl -si -X POST https://mcp.acme.example/mcp/ -H 'Content-Type: application/json' \
  -H 'Accept: application/json, text/event-stream' -d '{}' | head -5

If one form answers 307 with a Location that adds or removes the slash, the framework is normalising the path. Several web frameworks do this by default; this guide does not claim which, so check yours. The effects:

  • Under HTTP semantics, 307 and 308 ask the client to repeat the same method and body, but a client or library may not follow redirects on POST, and a 301 or 302 may turn the POST into a GET. Either way the sequence can end in a 405 or a hang.
  • If the redirect goes to a different host, Anthropic says Claude follows it and drops the Authorization header, so a protected server sees an unauthenticated call. See Claude says "Couldn't reach the MCP server".
  • Redirects also trigger CORS failures in browser clients (CORS guide).

4. Is the Accept header the cause?

curl -i -X POST https://mcp.acme.example/mcp \
  -H 'Content-Type: application/json' \
  -d '{"jsonrpc":"2.0","id":1,"method":"tools/list"}'

The spec requires both content types in Accept. What a server does when one is missing differs by SDK (some answer 406 or 400); this is not verified here. Clients that follow the spec always send both. If you see this only with a hand-written client or a test script, fix the script.

5. Is OAuth the real answer?

A protected server should answer an unauthenticated POST with 401 and a WWW-Authenticate header. If a gateway answers 405 or 403 instead, clients never start sign-in. See 401 without resource_metadata.

Fixes

Serve both slash forms without redirecting. Register the same handler for /mcp and /mcp/, or turn off automatic slash redirects in your framework and register exactly the URL you tell users. Then tell users one canonical URL.

// Express: accept both forms on POST, GET and DELETE
app.all(["/mcp", "/mcp/"], mcpHandler);

Return 405 for GET and DELETE on purpose if you have no SSE stream or sessions, and include an Allow: POST header.

app.get("/mcp", (_req, res) => res.status(405).set("Allow", "POST").end());

Mount Streamable HTTP at one path and keep any legacy /sse route only as a compatibility shim.

Fix the proxy. Allow POST on the MCP path, pass Authorization and Accept through, and do not buffer streaming responses.

Verify

  1. The POST in step 1 returns 200 (or 401 with the challenge for protected servers) on the exact URL you register, with no redirect: curl -sI shows no Location.
  2. GET and DELETE return either a valid stream or 405.
  3. Connect from the client and confirm tools/list works.

If the scan shows the transport as legacy SSE, the related rule is auth.transport.

Run a free scan at https://mcpshipyard.com/scan to check every rule at once.

Check your server against these rules

Scan runs the checks from this guide against a live URL and lists each failing rule with its fix.

Scan a server