Skip to content

[Request]: full MCP transport/spec parity for @jimhoyd/urlcode-mcp (streaming, batching, pagination, resources/prompts) #626

Closed

Description

@jimhoyd

Problem or use case

#573 added @jimhoyd/urlcode-mcp (PR #625), a declarative extension that serves a bounded set of project-declared tools as an MCP JSON-RPC-over-HTTP server. It was deliberately scoped to a minimal, correct core: JSON-RPC 2.0 framing, exact request-id handling, protocol version negotiation, and initialize/ping/tools/list/tools/call.

Several parts of the MCP specification are explicitly not implemented in v1 (documented in packages/mcp/README.md under "What this does not implement"), so a client that needs them cannot be served today:

  • The Streamable HTTP transport's optional GET/SSE stream for server-initiated messages, and Mcp-Session-Id session resumption. A GET to the mount currently answers 405.
  • tools/list pagination (cursor) — the whole declared tool set is returned in one page, which is fine for the current bounded (≤64) tool cap but not spec-complete.
  • Tool outputSchema / structuredContent — a tool result is always a single text content block today.
  • The resources and prompts MCP primitives.
  • JSON-RPC batching (arrays of requests) is refused outright; note the 2025-06-18 MCP revision itself removed batching, so this one may not need fixing, just re-confirming against whatever revision is current when this is picked up.

Proposed behavior and alternatives

Prioritize based on real client needs rather than implementing the full spec speculatively — the extension's whole design goal is staying a minimal, bounded declarative surface ("MCP over HTTP becomes declarative", not a full-featured MCP server). SSE/session resumption is likely the highest-value gap for long-lived agent clients; pagination and outputSchema are lower effort. Each should get its own focused interoperability test the way packages/mcp/test/mcp.test.ts already covers the implemented subset.

See PR #625 and issue #573 for the current implementation and design record.

Activity

  1. added
    enhancement
    on Sep 24, 2026
  2. jimhoyd commented on Sep 24, 2026

    @jimhoyd
    CollaboratorAuthor

    Investigation: SSE/streaming transport + Mcp-Session-Id resumption

    Following up on the scope PR #654 left open. I read packages/mcp/src/mcp.ts, the
    generic extension contract (packages/core/src/extensions.ts), HandlerResult
    (packages/core/src/http-response.ts), and all three hosts that currently accept
    extensions — packages/core/server.ts, vercel.ts, aws.ts — plus
    docs/RUNTIME-IMPLEMENTATION.md and packages/core/src/capabilities.ts's
    per-target native/delegated/refused reporting. I'm not opening a PR for this;
    per the issue's own guidance I'd rather report what I found than land a
    core-seam change I'm not confident is correct on every target.

    The core gap is real, and it splits into two independent problems

    1. HandlerResult is a single buffered value, not a stream. ExtensionInstance.handle()
      returns one HandlerResult ({status, headers, body?}) that every host awaits in
      full before writing a response. There's no seam anywhere in prepareResponse/
      writeResponse for "send bytes now, more bytes later, close whenever."
    2. There is no session/connection registry anywhere in core. Every host activates
      one Runtime and calls handle() per request with no persistent per-connection
      state. Mcp-Session-Id resumption needs a live registry mapping a session id to
      pending/replayable server-initiated messages (and Last-Event-ID replay on
      reconnect) that outlives a single request — this doesn't exist today at any layer.

    Per-target feasibility is not uniform — this is the risk

    • server.ts (Node): real http.ServerResponse. Chunked, long-lived writes are
      architecturally straightforward — res.write() before res.end() already works at
      the transport level. But prepareResponse computes Content-Length up front and
      the server has requestTimeoutMs/headersTimeoutMs socket-destroy timers and an
      inFlight admission counter (maxInFlightRequests) tuned for short buffered
      requests, not long-lived SSE connections. A streaming HandlerResult variant would
      need its own admission/timeout treatment, or a long-lived SSE stream will either get
      killed by requestTimeoutMs or exhaust the in-flight budget.
    • vercel.ts: same node:http transport as server.ts (this is the Vercel Node
      function
      runtime, not Edge/Response-streaming), so the same approach applies in
      principle — but Vercel's Node function runtime has its own platform-imposed max
      execution duration, which makes a long SSE connection more of an operational caveat
      than a hard blocker. That caveat needs to be surfaced the same way
      policies.throttle's partition: route is reported delegated rather than
      native in capabilities.ts, not silently promised.
    • aws.ts: this is the real blocker. createLambdaHandler is payload-format-2.0
      classic Lambda: one JSON event in, one Promise<LambdaResponse> (a single JSON
      object, base64 body) out. That invocation model cannot stream at all — true Lambda
      response streaming needs awslambda.streamifyResponse(), only reachable via
      Function URLs with InvokeMode: RESPONSE_STREAM, which is a different handler
      export shape
      ((event, responseStream, context), writing to a Node Writable),
      not an incremental change to the existing handler. Supporting SSE on aws isn't a
      "add a stream field" change; it's effectively a second Lambda entry point with its
      own event shape, own docs, own tests. Per
      docs/RUNTIME-IMPLEMENTATION.md's own directive ("a runtime must either reproduce a
      declared capability and pass its fixtures, or refuse that capability before
      serving"), the correct near-term behavior is for aws to keep refusing the GET/SSE
      stream (as it already implicitly does — no GET support at all) while tools/call
      keeps working over POST, same as today.
    • cloudflare.ts: not actually in scope here. packages/core/src/extensions.ts's
      prepareExtensions hard-asserts registration.targets can only contain
      'node' | 'aws' | 'vercel' — Cloudflare Workers don't run RuntimeExtensions at
      all today (the Cloudflare artifact path is a separately compiled route table with
      no extension concept). So @jimhoyd/urlcode-mcp was never reachable on Cloudflare
      in the first place; no work needed there for this issue, but it means "3 runtime
      targets" for this feature is actually node + vercel (real streaming candidates) and
      aws (structural refusal), not 4.

    Why I'm not implementing this now

    Getting all of the above right in one PR — a new streaming capability on
    HandlerResult/ExtensionInstance, admission/timeout treatment for long-lived
    connections on server.ts, the Vercel caveat reported correctly through
    capabilities.ts, explicit aws refusal wired through the same native/
    delegated/refused machinery policies.throttle already uses, and a
    session-id registry with bounded memory, TTL/eviction and Last-Event-ID replay in
    packages/mcp on top of it — is a lot of new surface to land correctly and prove
    with real HTTP round-trip tests (including a reconnect-after-restart resumption
    test) in a single change. Getting the admission/timeout interaction wrong on
    server.ts risks breaking ordinary buffered requests, which matters far more than
    closing this issue today.

    Recommended scoped next step

    Split this into two pieces so the risky part is reviewable on its own:

    1. A core-only PR: add an explicitly additive streaming capability to
      HandlerResult/ExtensionInstance (e.g. an optional async-iterable/stream body
      variant), consumed only by server.ts and vercel.ts, with its own
      admission/timeout handling, refused by aws.ts, and reported through
      capabilities.ts's existing native/delegated/refused vocabulary (vercel
      likely delegated with the max-duration caveat named, aws refused). This gets
      its own RIM-* card in docs/RUNTIME-IMPLEMENTATION.md and a focused fixture,
      per the semantic-seam rule in AGENTS.md, independent of MCP.
    2. A follow-up packages/mcp-only PR that consumes that capability for the
      GET/SSE stream and adds the Mcp-Session-Id registry (bounded, in-memory,
      extension-owned — this part doesn't need a further core change beyond the
      streaming primitive itself).

    I'd suggest keeping #626 scoped to (2) and filing a new issue for (1), since (1) is
    a generic core capability with no MCP-specific content and deserves its own
    review/fixtures independent of this package. Happy to file that core-capability
    issue if that's the preferred split — flagging here first since it's a call about
    how to slice the remaining work rather than a pure implementation detail.

  3. added
    extension
    needs-decision
    on Sep 24, 2026
  4. jimhoyd commented on Sep 24, 2026

    @jimhoyd
    CollaboratorAuthor

    Decision (owner, 2026-09-24): streaming is out of scope for now. Everything else here shipped: pagination, outputSchema/structuredContent, resources and prompts (#654); Origin and MCP-Protocol-Version checks (#685); title/annotations (#687); handler request context (#691). Batching stays refused (dropped from the 2025-06-18 spec). Streaming, sessions and the GET stream remain parked under #659. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementextensionneeds-decision

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions