Skip to content

Make hosted MCP HTTP stateless#383

Merged
kvz merged 4 commits intomainfrom
kvz/mcp-server-stateless-http-20260414
Apr 14, 2026
Merged

Make hosted MCP HTTP stateless#383
kvz merged 4 commits intomainfrom
kvz/mcp-server-stateless-http-20260414

Conversation

@kvz
Copy link
Copy Markdown
Member

@kvz kvz commented Apr 14, 2026

Summary

  • serve hosted Streamable HTTP MCP requests statelessly instead of relying on in-memory session maps
  • keep isolated transport/server instances per request so concurrent clients still do not share a singleton transport
  • add a non-sticky routing regression test that reproduces the production Session not found failure mode

Validation

  • yarn lint:changesets
  • yarn workspace @transloadit/mcp-server build
  • yarn workspace @transloadit/mcp-server check
  • yarn workspace @transloadit/mcp-server test:e2e

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6d604c696b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines 197 to 199
handler.close = async () => {
const closePromises = [...transports.values()].map((t) => t.close())
await Promise.all(closePromises)
transports.clear()
return Promise.resolve()
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Restore transport cleanup in handler.close

handler.close() was changed to a no-op, so the HTTP handler no longer has any way to terminate in-flight stateless transports/servers during shutdown. This regresses graceful stop behavior because packages/mcp-server/src/cli.ts:161-163 calls await handler.close() before server.close(), and long-lived SSE/slow requests can keep sockets open indefinitely when no transport is explicitly closed. Please keep a registry of active per-request transports (and servers) and close them in handler.close() so shutdown can reliably drain.

Useful? React with 👍 / 👎.

@kvz kvz merged commit cd662b0 into main Apr 14, 2026
10 checks passed
@kvz kvz deleted the kvz/mcp-server-stateless-http-20260414 branch April 14, 2026 15:20
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