Add Streamable HTTP MCP transport with CORS, Auth passthrough, and env-based config#59
Open
milichev wants to merge 4 commits into
Open
Add Streamable HTTP MCP transport with CORS, Auth passthrough, and env-based config#59milichev wants to merge 4 commits into
milichev wants to merge 4 commits into
Conversation
This was referenced Mar 11, 2026
5b0ac31 to
23ef956
Compare
23ef956 to
003d296
Compare
…verability; tools annotations added
…, potential memory leak fixed, readme updated, tests fixed, console noise removed
…eading version fixed; minor fixes/improvements
003d296 to
9736b33
Compare
|
Any update on this? |
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.
Description
This PR adds an optional Streamable HTTP MCP transport alongside the existing stdio transport.
When
MCP_TRANSPORT=httpis set, the server listens on a configurable host/port and serves MCP over HTTP, enabling browser-based clients such as MCP Inspector to connect without subprocess management.Why?
Important
Stdio transport binds the MCP server's lifecycle to the client process.
The client spawns the server as a subprocess and owns its stdin/stdout, making it impossible to attach a debugger, use watch/hot-reload (npm run dev), or reconnect without restarting the client. HTTP transport decouples the two: the server runs independently, the client connects over the network. This also enables cross-host connectivity (e.g. server in a container, client on the host) without an additional reverse proxy layer.
Key changes:
src/mcp/http-transport.ts— HTTP server, stateless per-request clone+transport, CORS with origin reflection,res.on("close")cleanup.src/mcp/proxy.ts—clone(requestHeaders?)factory; sharedstateobject (operations log flag + serverInfo) across clones; opaque error wrapping; deadPathItemObject/getContentTypestill present (next PR).src/client/http-client.ts—withHeaders()clones by value, injectsbaseHeadersatrequestConfiglevel; structured Axios error logging; debugconsole.errors removed.src/utils/proxy-config.ts— Zod schema for all env vars; discriminated union transport config;passthroughHeaderswhitelist.README.md— env vars table + HTTP mode dev section.proxy-config,base-url,http-clienttests updated/fixed.Pending / next PR candidates:
pinologging migration replacing remainingconsole.errorcalls.serverInfo.versionsourced from OpenAPI spec date string — arguably should be npm package version.Tip
Items 1 & 3 are implemented/fixed in milichev#2, which waits till this PR is merged
To start in HTTP mode:
Then connect MCP Inspector to
http://127.0.0.1:3666/mcp.What type of PR is this? (check all applicable)
Related Tickets & Documents
N/A
Mobile & Desktop Screenshots/Recordings
N/A — server-side only, no visual changes.
Added tests?
Added to documentation?
📜 README.md
🙅 no documentation needed
I understand that contributing to this repository will require me to agree with the CLA