feat(transport): add modern Streamable HTTP endpoint POST /mcp - #2
Open
TumGovic wants to merge 1 commit into
Open
feat(transport): add modern Streamable HTTP endpoint POST /mcp#2TumGovic wants to merge 1 commit into
TumGovic wants to merge 1 commit into
Conversation
Legacy SSE keeps a long-lived stream and a server-side sessionId. Behind a reverse proxy (Cloudflare tunnel, mcpproxy) that stream gets dropped, and every following tools/call fails with 404 Session not found even though the server is healthy and tools/list still works. Add a stateless Streamable HTTP transport: - POST /mcp handles a JSON-RPC message or batch, spinning up a fresh MCP server per request, so there is no session to expire and no stream to drop. - Notification-only payloads answer 202 with no body, per spec. - GET /mcp answers 405 with Allow, DELETE /mcp answers 204. - src/streamable.ts adds an in-process Transport implementation, so no node IncomingMessage/ServerResponse mocks are needed. - Legacy GET /sse + POST /messages are untouched for older clients. - Startup banner and README document both transports, /mcp recommended.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что добавлено
Современный транспорт MCP Streamable HTTP — эндпоинт
POST /mcp, в дополнение к текущему legacy SSE.Зачем
Legacy SSE держит долгоживущий стрим и серверный
sessionId. За реверс-прокси (Cloudflare-туннель, mcpproxy и т.п.) этот стрим рвётся:После обрыва сервер выглядит здоровым и
tools/listработает, но любойtools/callпадает с404 Session not found. Современные клиенты уже ждут/mcp, а не/sse.Как сделано
POST /mcp— stateless Streamable HTTP: на каждый запрос поднимается свой MCP-сервер, поэтому нет сессии, которая может протухнуть, и нет стрима, который может оборваться.202без тела, по спеке.GET /mcp→405с заголовкомAllow,DELETE /mcp→204.src/streamable.ts— реализацияTransportвнутри процесса, без моковIncomingMessage/ServerResponse.GET /sse+POST /messagesне тронуты, старые клиенты продолжают работать./mcpпомечен как рекомендуемый.Проверка
bunx tsc --noEmit— чисто. Живой прогон противPOST /mcpс Bearer-токеном:initialize200,protocolVersion 2025-03-26notifications/initialized202tools/list200, 31 тулtools/call→notcode_status200, корректный JSON