feat(mcp-server): add Streamable HTTP transport support - #230
Open
Marlin-Phone wants to merge 1 commit into
Open
feat(mcp-server): add Streamable HTTP transport support#230Marlin-Phone wants to merge 1 commit into
Marlin-Phone wants to merge 1 commit into
Conversation
Add a new --http mode using StreamableHTTPServerTransport so standard MCP clients (official SDK) can connect. The existing SSE mode fails the initialize handshake with 400 on POST /message because it uses a single global transport and calls server.connect() repeatedly. Multi-session support: each sessionId gets its own Server(Protocol) + Transport stored in a Map, dispatched by the mcp-session-id header on POST/GET/DELETE /mcp. transport.onclose cleans up the session. stdlib/SSE modes are unchanged. Closes wechatsync#229
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.
Summary
Add Streamable HTTP transport support to the MCP server via a new
--httpmode.Standard MCP clients (official SDK) could not complete the SSE handshake
(
POST /messagereturned 400) because the existing SSE implementation uses asingle global transport and calls
server.connect()repeatedly.Closes #229
Changes
packages/mcp-server/src/index.ts:StreamableHTTPServerTransport, add--httpmode detectionexpress.json()middlewarehandleRequest(req, res, req.body)(SDK convention)Server+Transportin a Map keyed bymcp-session-id, handled in POST/GET/DELETE/mcptransport.onclosecleans up the sessionTesting
pnpm --filter mcp-server buildpasses (ESM + DTS clean)initializehandshake verified with curl: returns protocolVersion + serverInfo + capabilities(list_platforms / check_auth / sync_article / extract_article / upload_image_file)