
来自 STDIO<->SSE 的 C# MCP 代理
概览
MCPProxy-STDIO-to-SSE 一种轻量级.NET控制台桥,允许任何基于STDIO的客户端与SSE支持的MCP服务器通信。它: 打开一个长寿命的SSE连接BASE_URL/sse,发现/message?sessionId=...端点。 将从 STDIN 读取的每一行 JSON-RPC 转发为 HTTP POST 到 BASE_URL?message?sessionId=.... 将每个SSE数据:有效载荷(除终端事件外)流向STDOUT。 将发送和接收的每条消息(带有时间戳和漂亮打印的JSON)记录到你的临时目录MCPProxy-STDIO.log。 具备双向桥接功能:STDIN→HTTP POST 和 SSE→STDOUT。 通过事件端点帧实现自动会话发现。 结构化日志(时间戳,“已发送”/“已接收”标记,缩进JSON)。
概述(AI 翻译)
使MCP SSE服务器能够兼容WindSurf和Claude桌面
MCPProxy-STDIO到SSE 一个轻量级的.NET控制台桥接器,允许任何基于STDIO的客户端与SSE支持的MCP服务器通信。 它:
打开一个长寿命的SSE连接BASE_URL/sse,发现/message?sessionId=…端点。
将从 STDIN 读取的每一行 JSON-RPC 转发为 HTTP POST 到 BASE_URL?message?sessionId=…
将每个SSE数据:有效载荷(除终端事件外)流向STDOUT。
将发送和接收的每条消息(带有时间戳和漂亮打印的JSON)记录到你的临时目录MCPProxy-STDIO.log。
特色 双向桥接:STDIN→HTTP POST 和 SSE→STDOUT。
通过事件端点帧实现自动会话发现。
结构化日志(时间戳,“已发送”/“已接收”标记,缩进JSON)。
SSE 订阅请求和 POST 请求均可配置首部。
前提条件 .NET 6.0 SDK 或更高版本
一个兼容MCP的服务器,暴露:
GET /sse(带有事件的SSE流:端点帧)
POST /message?sessionId={id} (接受 JSON-RPC payloads)
建筑
用途
一旦上线,应用将: 用接受打开 GET http://localhost:3001/sse 文本/事件流。 等待事件:端点框架——例如:
本页由 AI 翻译,技术细节请以原文为准。
README
MCPProxy-STDIO-to-SSE
Makes a MCP SSE server compatiable with WindSurf and Claude Desktop
MCPProxy-STDIO-to-SSE A lightweight .NET console bridge that lets any STDIO-based client speak to an SSE-backed MCP server. It:
Opens a single long-lived SSE connection to BASE_URL/sse, discovers the /message?sessionId=… endpoint.
Forwards every JSON-RPC line read from STDIN as an HTTP POST to BASE_URL/message?sessionId=….
Streams each SSE data: payload (other than the endpoint event) to STDOUT.
Logs every message sent and received (with timestamps and pretty-printed JSON) to MCPProxy-STDIO.log in your temp directory.
Features Bidirectional bridge: STDIN→HTTP POST and SSE→STDOUT.
Automatic session discovery via the event: endpoint frame.
Structured logging (timestamps, “Sent”/“Received” markers, indented JSON).
Configurable headers on both SSE subscribe and POST requests.
Prerequisites .NET 6.0 SDK or later
An MCP-compatible server exposing:
GET /sse (SSE stream with an event: endpoint frame)
POST /message?sessionId={id} (accepts JSON-RPC payloads)
Building
git clone https://github.com/yourorg/MCPProxy-STDIO-to-SSE.git
cd MCPProxy-STDIO-to-SSE
dotnet build -c Release
Usage
# Basic (no extra headers):
dotnet run --project src/Program.cs http://localhost:3001
# With additional HTTP headers:
dotnet run --project src/Program.cs http://localhost:3001 ApiKey 12345
Once launched, the app will: Open GET http://localhost:3001/sse with Accept: text/event-stream. Wait for an event: endpoint frame—e.g.:
event: endpoint
data: /message?sessionId=Wp6wxiY6PyBRoTtCNyLucw
Read lines from your STDIN and POST each one as JSON to:
POST http://localhost:3001/message?sessionId=Wp6wxiY6PyBRoTtCNyLucw
Content-Type: application/json
{"jsonrpc":"2.0","id":1, ...}
Print every other SSE data: payload to STDOUT, for example:
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2024-11-05", ...}}
Write a detailed log of “Sent” and “Received” messages (with timestamps and formatted JSON) into:
%TEMP%\MCPProxy-STDIO.log
Use this bridge to connect any STDIO-driven LSP/JSON-RPC client (including Claude Desktop) to a web-based SSE/MCP backend seamlessly. Sample Claude JSON configuration
{
"mcpServers": {
"Local CNET Debug": {
"command": "C:\\Users\\User\\source\\repos\\MCPProxy-STDIO-to-SSE\\MCPProxy-STDIO-to-SSE\\bin\\Debug\\net6.0\\MCPProxy-STDIO-to-SSE.exe",
"args": ["http://localhost:4858/McpHandler.ashx/sse"],
"env": {
"BRAVE_API_KEY": "your-api-key"
}
}
}
}
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →