Skip to content

Serve the application MCP server with the official MCP SDK (#846, HTTP) - #852

Merged
jimhoyd merged 1 commit into
mainfrom
claude/mcp-http-sdk-846
Sep 28, 2026
Merged

jimhoyd merged 1 commit into
mainfrom
claude/mcp-http-sdk-846

Conversation

@jimhoyd

@jimhoyd jimhoyd commented Sep 28, 2026

Copy link
Copy Markdown
Collaborator

Problem and change

Second stage of #846: the application MCP server (packages/mcp) now uses the official SDK, like the authoring server since #850. Each HTTP request to a mount is answered by createMcpHandler from @modelcontextprotocol/server 2.1.0. It wraps a fresh SDK Server whose tools/*, resources/* and prompts/* handlers carry the declared behaviour.

The SDK owns: JSON-RPC over Streamable HTTP, initialize negotiation (currently 2025-11-25 back to 2024-11-05), the MCP-Protocol-Version header, notifications, request ids and error codes.

The extension keeps:

  • Origin/DNS-rebinding admission (403 before the SDK reads anything);
  • the bounded request.body.schema checks for tool arguments, tool output and prompt arguments;
  • trusted handler loading and calls;
  • the fixed generic failure messages;
  • McpToolError semantics;
  • onToolCall/onToolError;
  • a small adapter from the extension request to a web Request/Response, which streams the response when it's SSE and streaming is on.

Owned source: packages/mcp/src goes from 1,058 to 556 lines (−502, −47%). sessions.ts (273 lines) is deleted, along with the envelope parser, negotiation, pagination and session branches in mcp.ts.

Behaviour changes (no compatibility kept, per #841)

  • Stateless. No Mcp-Session-Id, no server-initiated GET stream, no Last-Event-ID replay; GET and DELETE answer 405. A notifications/cancelled can't reach another request's call; a client disconnect still aborts context.signal.
  • streaming is a boolean.
    • The object options (maxSessions and the rest) are gone.
    • On: SSE replies pass through live, so progress arrives before the result. Vercel is now allowed, since there's no in-memory session table; AWS still refuses it.
    • Off: the finite SSE reply is buffered, and progress does nothing.
  • SSE replies. Clients must send Accept: application/json, text/event-stream, or get 406, as the spec requires.
  • Errors:
    • Schema-failing tool arguments are an isError result under every revision, not -32602 for older ones.
    • A missing resource is -32602 (the SDK follows the current spec), not -32002.
    • Parse errors and invalid envelopes are HTTP 400 with the JSON-RPC error.
    • Batches are processed rather than refused.
    • Duplicate JSON keys are no longer refused (core's strict reader no longer parses the body).
  • Lists return every entry; there's no cursor pagination.
  • Context. Handlers always receive context.signal; tool handlers always get progress.

Verification

  • New packages/mcp/test/sdk-client.test.ts uses the official @modelcontextprotocol/client over Streamable HTTP against a served site, with streaming off and on. It covers:
    • server info and instructions;
    • tools, structuredContent, a schema-failing call returning isError, an unknown tool returning a protocol error;
    • readResource and getPrompt, including missing prompt arguments;
    • with streaming on, onprogress receiving 1, 2, 3 before the result.
  • streaming.test.ts is rewritten for the stateless model:
    • off: 405, no session id, a buffered reply, AWS allowed;
    • on: AWS refused, Vercel activates;
    • a non-boolean option is refused;
    • progress arrives before the result over a real socket;
    • a client disconnect aborts the handler.
  • mcp.test.ts and context.test.ts:
    • the helpers send the required Accept header and read the SSE reply;
    • the pagination and old-revision -32602 tests are replaced;
    • the protocol-failure and not-found tests assert the SDK's codes.
  • Package suite: 42/42. npm run verify exits 0, including core 1,100/1,100, every workspace suite, test:addons and test:proof. npm run test:package passes.
  • Docs updated: package README (transport, implemented and not-implemented), SECURITY.md (stateless, no session table), CHANGELOG, docs/EXTENSIONS.md, docs/FRAMEWORK.md, docs/OPERATIONS.md, regenerated urlcode.json and field reference.
  • Not run on Windows.

Compatibility and security

  • Breaking for MCP clients of an application server, as listed above. There's no YAML schema change, and project declarations are unchanged.

  • Authority is unchanged: handlers are still trusted operator-reviewed project code, and mounts are protected by a principal-providing extension as before. Removing sessions removes a bearer-like session id and its memory-bounded table.

  • New runtime dependency for the add-on: @modelcontextprotocol/server 2.1.0 (MIT; plus @modelcontextprotocol/core and zod), the same versions core already pins.

  • Changes match the documented portable contract; docs/examples are updated where needed.

  • Relevant tests and package checks pass, or limitations are explained above.

  • No credentials, customer data or private project material are included.

  • Runtime/starter changes remain aligned where applicable.

🤖 Generated with Claude Code

… stage 2)

packages/mcp now answers each request with @modelcontextprotocol/server's
stateless Streamable HTTP handler, built per request around the declared
tools, resources and prompts. The SDK owns JSON-RPC parsing, version
negotiation, notifications and error codes; the extension keeps Origin
admission, the declared argument/output schema checks, trusted handler
calls, the generic failure messages and onToolCall/onToolError.

Removed with no compatibility layer (#841): Mcp-Session-Id sessions, the
GET stream and Last-Event-ID replay (sessions.ts), list pagination, and the
streaming object options. `streaming` is a boolean that passes SSE replies
through as produced, so progress precedes the result; it now also serves
on vercel. packages/mcp/src: 1,058 -> 556 lines.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@jimhoyd
jimhoyd enabled auto-merge (squash) September 28, 2026 17:02
@jimhoyd
jimhoyd merged commit fea1044 into main Sep 28, 2026
31 checks passed
@jimhoyd
jimhoyd deleted the claude/mcp-http-sdk-846 branch September 28, 2026 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant