๐ MCP Bridge (STDIO โ SSE)
April 5, 2025 ยท View on GitHub
A lightweight bridge that connects Claude Desktop via STDIO to any MCP-compatible backend using SSE (Server-Sent Events).
This enables Claude to talk to modern MCP servers that expose an HTTP API using /sse and /messages, while Claude only supports STDIO.
๐ฆ Features
- ๐ Bridges STDIO and SSE for full protocol compatibility
- ๐จ Forwards all JSON-RPC requests to the backend
- ๐ Relays backend responses and events back to Claude
- ๐ง Fully compatible with the Model Context Protocol (MCP)
๐๏ธ Folder Structure
mcp-bridge/
โโโ cli.ts # ๐ง Main entry point (runs the bridge logic)
โโโ package.json # ๐ฆ Project metadata and dependencies
โโโ tsconfig.json # โ๏ธ TypeScript config
โโโ README.md # ๐ Project documentation
๐ Usage
You can run the bridge manually:
npx mcp-bridge http://localhost:4000
Or make the script executable and run it:
chmod +x cli.ts
./cli.ts http://localhost:4000
Alternatively, configure it in your mcpServers:
{
"mcpServers": {
"mcp-hub": {
"command": "npx",
"args": ["mcp-bridge", "http://localhost:4000"]
}
}
}
โ๏ธ Requirements
- Node.js v18+ (must support
fetchand top-levelawait) - TypeScript / tsx if using
.tsdirectly
Your backend must implement:
GET /sseโ SSE endpoint for responses/eventsPOST /messagesโ JSON-RPC POST endpoint for requests
๐ง How It Works
Claude Desktop
โ
โผ (STDIO)
[ MCP Bridge (cli.ts) ]
โ (SSE + POST)
โผ
Your MCP Backend (McpServer)
- Claude talks to the bridge over STDIO.
- The bridge opens an SSE connection to your backend's
/sse. - The bridge POSTs Claude's messages to
/messages. - SSE responses are streamed back and passed to Claude via STDOUT.
๐งช Dev & Debugging
Install dependencies:
npm install
Run in dev mode:
npx tsx cli.ts http://localhost:4000
Enable verbose output:
DEBUG=1 npx tsx cli.ts http://localhost:4000
๐งฏ Troubleshooting
- โ Permission denied โ Run
chmod +x cli.ts - โ Unknown file extension
.tsโ Make sure you're usingtsxorts-node - โ Claude can't connect โ Check
mcpServersconfig and stdout/stderr logs