Repository navigation
Commit 4f78231
Test GET /mcp with the Accept values that get 406 from the SDK (#4248)
## Summary
The MCP Python SDK checks the `Accept` header before the request method.
Without our 405 route, a `GET /mcp` with `Accept: application/json`, or
with no `Accept` header, gets 406 instead of 405. Clients that probe
with those headers, such as the MCP TypeScript SDK, treat only 405 as
"no stream, use POST," so a 406 aborts their handshake. Another
deployment reported this on
modelcontextprotocol/python-sdk#2474 (comment).
Our route already answers every GET before the SDK's checks run, and the
live server returns 405 for all of these `Accept` values. The existing
tests sent only `Accept: text/event-stream`, though, so they couldn't
catch a change that moved our route behind the `Accept` check, or an
upstream fix with the same ordering problem.
This adds three cases to the GET tests: `Accept: */*`, `Accept:
application/json`, and no `Accept` header. TestClient adds `Accept: */*`
to every request, so the no-`Accept` case removes the header by hand in
its own test.
No server code changes.
## Testing
- All 7 tests in `scripts/test_mcp_transport.py` pass.
- With the 405 route removed from `scripts/mcp-server.py`, all 5 GET
cases fail. `text/event-stream` and `*/*` hang until the 10-second
timeout, and `application/json` and no `Accept` fail at once with 406.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 5.5 <[email protected]>1 parent a55ba63 commit 4f78231
1 file changed
Lines changed: 26 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
84 | 89 | | |
85 | 90 | | |
86 | 91 | | |
87 | 92 | | |
88 | 93 | | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
89 | 102 | | |
90 | | - | |
91 | 103 | | |
92 | 104 | | |
93 | 105 | | |
| |||
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
103 | 128 | | |
104 | 129 | | |
105 | 130 | | |
| |||
0 commit comments