litellm gateway /mcp/ endpoint has broken routing #3908

Closed
opened 2026-02-16 17:41:54 -05:00 by yindo · 3 comments
Owner

Originally created by @kierr on GitHub (Dec 27, 2025).

Originally assigned to: @rekram1-node on GitHub.

Bug Report

litellm gateway /mcp/ endpoint has broken routing behavior

Evidence

# POST works WITH trailing slash:
curl -X POST "https://litellm.wild-hexatonic.ts.net/mcp/" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
# → HTTP 200

# POST fails WITHOUT trailing slash (redirects):
curl -X POST "https://litellm.wild-hexatonic.ts.net/mcp" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'
# → HTTP 307 redirect to /mcp/

### Issues

1. POST requests require trailing slash - /mcp/ works, /mcp redirects and fails
Originally created by @kierr on GitHub (Dec 27, 2025). Originally assigned to: @rekram1-node on GitHub. ## Bug Report litellm gateway /mcp/ endpoint has broken routing behavior ### Evidence ```bash # POST works WITH trailing slash: curl -X POST "https://litellm.wild-hexatonic.ts.net/mcp/" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}' # → HTTP 200 # POST fails WITHOUT trailing slash (redirects): curl -X POST "https://litellm.wild-hexatonic.ts.net/mcp" \ -H "Content-Type: application/json" \ -H "Accept: application/json, text/event-stream" \ -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}' # → HTTP 307 redirect to /mcp/ ### Issues 1. POST requests require trailing slash - /mcp/ works, /mcp redirects and fails ```
yindo closed this issue 2026-02-16 17:41:54 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Dec 27, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #6247: OpenCode MCP client should follow HTTP 307 redirects

The issue you're experiencing with the /mcp endpoint requiring a trailing slash is related to HTTP 307 redirect handling. Issue #6247 specifically addresses the need for OpenCode's MCP client to automatically follow HTTP 307 redirects, which would resolve this routing problem.

Feel free to ignore if this doesn't address your specific case.

@github-actions[bot] commented on GitHub (Dec 27, 2025): This issue might be a duplicate of existing issues. Please check: - #6247: OpenCode MCP client should follow HTTP 307 redirects The issue you're experiencing with the /mcp endpoint requiring a trailing slash is related to HTTP 307 redirect handling. Issue #6247 specifically addresses the need for OpenCode's MCP client to automatically follow HTTP 307 redirects, which would resolve this routing problem. Feel free to ignore if this doesn't address your specific case.
Author
Owner

@kierr commented on GitHub (Dec 27, 2025):

Analysis was flawed - need proper investigation before filing. POST redirect behavior unproven. SSE "broken" claim based only on GET requests doesn't prove gateway issue.

@kierr commented on GitHub (Dec 27, 2025): Analysis was flawed - need proper investigation before filing. POST redirect behavior unproven. SSE "broken" claim based only on GET requests doesn't prove gateway issue.
Author
Owner

@kierr commented on GitHub (Dec 27, 2025):

Tested further - curl does NOT automatically follow POST redirects. The 307 redirect to /mcp/ loses the POST request body. Without -L flag, curl stops at 307 and doesn't retry. This is a litellm gateway bug where POST redirects to same path with slash added. Only /mcp/context7 endpoint exists and works.

@kierr commented on GitHub (Dec 27, 2025): Tested further - curl does NOT automatically follow POST redirects. The 307 redirect to /mcp/ loses the POST request body. Without -L flag, curl stops at 307 and doesn't retry. This is a litellm gateway bug where POST redirects to same path with slash added. Only /mcp/context7 endpoint exists and works.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#3908