Skip to content

fix(web): return 405 for GET /api/mcp instead of hanging connection#1064

Merged
brendan-kellam merged 2 commits intomainfrom
brendan-kellam/fix-SOU-827
Mar 31, 2026
Merged

fix(web): return 405 for GET /api/mcp instead of hanging connection#1064
brendan-kellam merged 2 commits intomainfrom
brendan-kellam/fix-SOU-827

Conversation

@brendan-kellam
Copy link
Copy Markdown
Contributor

@brendan-kellam brendan-kellam commented Mar 31, 2026

Summary

  • The GET /api/mcp handler opened an SSE stream that never flushed its HTTP response headers, causing clients to hang until timeout (0 bytes received)
  • Sourcebot does not send server-initiated messages, so the GET SSE stream serves no purpose
  • Per the MCP Streamable HTTP spec, servers that do not offer a GET SSE stream MUST return 405 Method Not Allowed

Fixes #1061

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Fixed an issue where the MCP API endpoint would hang when processing certain requests; it now properly returns a 405 Method Not Allowed response per the MCP Streamable HTTP specification.

The GET SSE stream is only used for server-initiated messages, which
Sourcebot does not send. Per the MCP Streamable HTTP spec, servers that
do not offer a GET SSE stream MUST return 405 Method Not Allowed.
Previously the handler opened an SSE stream that never flushed its HTTP
headers, causing clients to hang until timeout.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@github-actions

This comment has been minimized.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5a899a03-a11f-460e-9298-64f61b3dca1e

📥 Commits

Reviewing files that changed from the base of the PR and between f8e21d6 and 4920101.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • packages/web/src/app/api/(server)/mcp/route.ts

Walkthrough

The changes fix a bug where GET requests to /api/mcp were hanging indefinitely without sending an HTTP response. The GET handler has been replaced to return a 405 Method Not Allowed status with proper HTTP headers, conforming to the MCP Streamable HTTP transport specification.

Changes

Cohort / File(s) Summary
Changelog Documentation
CHANGELOG.md
Added entry in Unreleased section documenting the fix: GET requests to /api/mcp now return HTTP 405 Method Not Allowed instead of hanging.
Route Handler
packages/web/src/app/api/(server)/mcp/route.ts
Replaced GET handler implementation that was causing hangs. Old handler performed session validation and auth checks; new handler returns fixed 405 response with Allow: POST, DELETE header, removing all session lookup and authorization logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan-kellam/fix-SOU-827

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@brendan-kellam brendan-kellam merged commit 470360d into main Mar 31, 2026
7 checks passed
@brendan-kellam brendan-kellam deleted the brendan-kellam/fix-SOU-827 branch March 31, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] GET /api/mcp does not return HTTP response when valid session ID is provided (Streamable HTTP transport violation)

1 participant