Answer MCP notifications with 202 Accepted

Merged
JO
1mo ago
+32-10

Problem

Sure answers an MCP notification (a JSON-RPC message without an id, such as notifications/initialized) with 204 No Content. MCP's Streamable HTTP transport says a server that accepts one "MUST return HTTP status code 202 Accepted with no body".

Pipelock's MCP reverse proxy enforces that. Behind it, a client's handshake fails right after initialize, so the agent never sees Sure's tools. That is the setup compose.example.ai.yml and docs/hosting/ai.md recommend for external agents (port 8889).

  • Reproduced on 2026-11-07 with Pipelock 3.6.0 and OpenClaw 2026.10.8.
    • Pipelock logs upstream POST returned unexpected HTTP 204.
    • openclaw mcp probe fails with "Streamable HTTP error: Error POSTing to endpoint", and tools/list never reaches Sure.
    • With 202, the probe lists all 35 tools.
  • Reported on #3580 by others on a released version (v0.7.5-hotfix.2 behind Pipelock 3.4.0), and behind another reverse proxy, where Claude Code dropped the connection.

What changes

  • McpController#handle answers a notification with 202 Accepted, still with no body and still without running anything. A tools/call sent as a notification doesn't execute, as before.
  • The three notification tests expect 202.
  • docs/hosting/mcp.md says what a notification gets.

Relation to #3580

The same one-line change is part of #3580 by @buzzromain, and of #4182, which is stacked on it. #3580's other changes (least-privilege OAuth scopes, protocol 2025-06-18/2026-07-28 support) are still in review. On #3580, Pipelock's maintainer asked for "that piece in even if the rest needs more time". This PR carries only the status code, so the Pipelock setup works now. #3580 rebases over it without conflict in intent; if #3580 lands first, this can be closed.

Not changed here: DELETE /mcp (session termination) still has no route, and returns 404 where the spec suggests 405. Clients carry on regardless.

Validation

  • test/controllers/mcp_controller_test.rb: 38 runs, 0 failures.
  • bin/rails test: 14,822 runs, 13 failures, all of which also fail on main in this environment: Wise ×10, BinanceItems, Budget, Demo::FinancekitGenerator.
  • RuboCop and Brakeman: clean.
  • Live: Pipelock 3.6.0's MCP proxy in front of Sure, with OpenClaw 2026.10.8 as the client. With 204, the handshake fails. With 202, tools/list and tools/call go through.

🤖 Generated with Claude Code

https://claude.ai/code/session_016zAWUV2Sxn9CgsmcUqojAZ


Summary by cubic

Answers MCP notifications with 202 Accepted instead of 204 No Content so the handshake works behind Pipelock's MCP reverse proxy, which rejects 204 and drops the connection before the client sees Sure's tools.

  • Notifications still get an empty body and still run nothing; a tools/call sent as a notification doesn't execute.
  • Updates the notification tests (one replays the handshake with its negotiated session) and docs/hosting/mcp.md to document the 202 response.

Summary by CodeRabbit

  • Bug Fixes
    • JSON-RPC notifications now receive HTTP 202 Accepted with an empty response body instead of HTTP 204 No Content.
    • Notification-style tools/call requests remain unexecuted. Unknown notifications and notifications/initialized requests with the negotiated protocol version and session ID are accepted.
  • Documentation
    • Updated hosting documentation to describe notification responses and clarify that notification-style tool calls do not execute.