一个TypeScript可流取的HTTP和SSE代理,用于使用stdio迁移的MCP服务器.
概览
一个TypeScript可流取的HTTP和SSE代理,用于使用stdio迁移的MCP服务器. 默认启用可配置选项的 CORS 。 详情见 CORS 配置 。 反向的——给远程MCP服务器提供只使用stdio的客户端访问,包括交互式OAuth流——参见mcp-remote. MCP代理是FastMCP用来启用可流HTTP和SSE的. MCP代理服务协议修订 2026-07-28 和2025-时代的修订(2024-10-07至2025-11-25)来自同一端点. 每到可流的HTTP端点的POST都是按自己的内容分类的——2026-07-28修订版在每个请求上都设置了 meta信封,没有一个请求则由2025年时代的会话机制服务——所以新旧客户端共享一个URL,不需要知道另一个存在. 进度通知和取消在两个时代都跨过代理:一个转发的呼叫带有呼叫者的中止信号,而转发的进度被重新标记为与呼叫者发送的令牌.
概述(AI 翻译)
用于使用 [[T0] 传输的 MCP 服务器的可流式 HTTP 和 SSE 代理 。
[注]
默认启用了可配置选项的 CORS。 详情见 CORS 配置 。
[注]
对于倒数——给一个远程MCP服务器,包括交互式OAuth流,只提供stdio客户端访问权限——参见mcp-remote.
[注]
MCP代理是FastMCP用来使可流的HTTP和SSE能够被使用.
□ 议定书修订
MCP代理协议修订2026-07-28和2025-时代的修订
([[T2]至[T3]从同一端出. 每一个职位到
可流的HTTP端点按自身内容分类——2026-07-28
修订后,每一份请求都有一个[T4]]信封,没有一份请求的要求
由2025年代的会话机制服务——如此新老客户共享一个URL
也不必知道对方的存在。
QQ 2025-时代客户QQ 2026-07-28客户QQ ————————————————————————————————————————.
startStdioServer =======================================================================================
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
MCP Proxy
A TypeScript streamable HTTP and SSE proxy for MCP servers that use stdio transport.
[!NOTE] CORS is enabled by default with configurable options. See CORS Configuration for details.
[!NOTE] For the inverse — giving a stdio-only client access to a remote MCP server, including the interactive OAuth flow — see mcp-remote.
[!NOTE] MCP Proxy is what FastMCP uses to enable streamable HTTP and SSE.
Protocol revisions
MCP Proxy serves protocol revision 2026-07-28 and the 2025-era revisions
(2024-10-07 through 2025-11-25) from the same endpoint. Every POST to the
streamable HTTP endpoint is classified by its own content — the 2026-07-28
revision puts a _meta envelope on every request, and requests without one are
served by the 2025-era session machinery — so old and new clients share one URL
and neither has to know the other exists.
| 2025-era clients | 2026-07-28 clients | |
|---|---|---|
/mcp (streamable) |
yes, sessionful | yes, per-request |
/sse (HTTP+SSE) |
yes | n/a — no SSE transport exists |
stdio (startStdioServer) |
yes | not yet — see below |
| Change notifications | unsolicited | subscriptions/listen stream |
Progress notifications and cancellation cross the proxy in both eras: a forwarded call carries the caller’s abort signal, and relayed progress is re-tagged with the token the caller sent.
Use --no-modern to serve only 2025-era clients; a 2026-07-28 client is then
answered by the 2025-era machinery, which does not recognise its request. The
modern leg lives on the streamable HTTP endpoint, so it is also absent when that
endpoint is disabled (--server sse, or streamEndpoint: null).
The upstream connection — the server MCP Proxy spawns — negotiates its own
revision independently, so any combination works. It uses the 2025 initialize
handshake by default; pass --upstreamProtocol auto to probe with
server/discover first (needed to front a 2026-07-28 server) or
--upstreamProtocol modern to require it.
# front a 2026-07-28 stdio server, serving both eras downstream
npx mcp-proxy --upstreamProtocol auto -- my-modern-mcp-server
What does not cross the proxy
These are consequences of one design decision — the proxy multiplexes every downstream connection onto a single upstream connection — and are called out rather than half-solved.
- Anything that asks the client for input (elicitation, sampling, roots). A 2025-era server pushes its request out of band, carrying nothing that says which caller it belongs to, so relaying it means guessing whose screen to put the prompt on. A 2026-07-28 upstream is not ambiguous that way — the request
安装
npx mcp-proxy --upstreamProtocol auto -- my-modern-mcp-server