Files
hyprland-headless-stream-pl…/tests
HermenixandClaude Opus 5 b2a683a560 fix(mcp): the endpoint is the exact path, and nothing redirects
`Starlette(routes=[Mount("/mcp", app=handle)])` serves `/mcp/` and
answers `/mcp` with a **307** -- or a 404 with `redirect_slashes` off.
Measured both ways.  Every MCP client configuration spells the URL
without the trailing slash, and a redirected POST has to be re-sent with
its body: `urllib` will not do that at all, and some clients get it
wrong.

So the routing is three lines of its own (`http.Endpoint`) instead: both
spellings are the endpoint, neither is a redirect to the other, and
anything else is a 404.  Starlette's router is gone from the request
path; the lifespan protocol is handled directly, which `manager.run()`
needs anyway because its task group must be exited by the task that
entered it.

This got through the unit suite once, and that is the more useful half of
this commit.  `starlette.testclient` follows redirects by default, so
every assertion in `test_mcp_http.py` passed against a server a real
client could not talk to -- the 307 only surfaced in
`checks/vm-mcp-http.nix`, from a `urllib` client over a real socket.
`post()` now passes `follow_redirects=False`, and
`test_the_exact_path_does_not_redirect` asserts both spellings answer
200 directly.  A test client that papers over a redirect is a test client
that cannot see one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KchcvnbfhhZhUHy83YL3Ya
2026-10-11 22:41:01 +00:00
..