Universal bridge between stdio-based MCP clients (like Claude Code) and HTTP-based MCP servers.
Many MCP (Model Context Protocol) clients, including Claude Code CLI, only support stdio transport. However, deploying MCP servers as HTTP services offers better scalability, monitoring, and deployment options. This bridge enables stdio-only clients to connect to HTTP-based MCP servers seamlessly.
- π Universal Compatibility - Connect any stdio MCP client to any HTTP MCP server
- π³ Docker Ready - Perfect for containerized MCP server deployments
- π Session Management - Automatic session ID handling
- π‘ Streaming Support - Handles both JSON and SSE responses
- π‘οΈ Production Ready - Comprehensive error handling and health checks
- π¦ Zero Dependencies - Only uses commander for CLI parsing
npm install -g @thefoot/mcp-stdio-http-bridge
npm install @thefoot/mcp-stdio-http-bridge
npx @thefoot/mcp-stdio-http-bridge --url http://localhost:3200/mcp
# Basic usage
mcp-bridge --url http://localhost:3200/mcp
# With options
mcp-bridge \
--url http://localhost:3200/mcp \
--timeout 60000 \
--debug
# Using environment variable
MCP_HTTP_URL=http://localhost:3200/mcp mcp-bridge
# Skip health check (useful for custom endpoints)
mcp-bridge --url http://localhost:3200/mcp --no-health-check
Option | Description | Default | Environment Variable |
---|---|---|---|
-u, --url <url> |
MCP server URL | http://localhost:3200/mcp |
MCP_HTTP_URL |
-t, --timeout <ms> |
Request timeout in milliseconds | 30000 |
|
-l, --log-level <level> |
Log level (trace/debug/info/warn/error/fatal) | info |
LOG_LEVEL |
--no-health-check |
Skip health check on startup | false |
|
-V, --version |
Display version number | ||
-h, --help |
Display help |
Configure in your project's .mcp.json
:
{
"mcpServers": {
"my-server": {
"command": "sh",
"args": [
"-c",
"node $(npm root)/@thefoot/mcp-stdio-http-bridge/src/cli.js"
],
"env": {
"MCP_HTTP_URL": "http://localhost:3200/mcp"
}
}
}
}
Or install globally and use directly:
{
"mcpServers": {
"my-server": {
"command": "mcp-bridge",
"args": ["--url", "http://localhost:3200/mcp"]
}
}
}
import { MCPBridge } from '@thefoot/mcp-stdio-http-bridge';
const bridge = new MCPBridge({
url: 'http://localhost:3200/mcp',
timeout: 30000,
logLevel: 'debug', // Set log level programmatically
});
// Listen to events
bridge.on('start', () => console.log('Bridge started'));
bridge.on('error', (error) => console.error('Error:', error));
bridge.on('session', (sessionId) => console.log('Session:', sessionId));
// Start the bridge
await bridge.start();
// Stop when done
bridge.stop();
{
url?: string, // MCP server URL (default: 'http://localhost:3200/mcp')
timeout?: number, // Request timeout in ms (default: 30000)
logLevel?: string, // Log level: trace/debug/info/warn/error/fatal (default: 'info')
logger?: Object // Custom Pino logger instance
}
start(options?)
- Start the bridgestop()
- Stop the bridgecheckHealth()
- Check if HTTP server is reachable
start
- Emitted when bridge starts successfullystop
- Emitted when bridge stopserror
- Emitted on errorssession
- Emitted when session ID is established
The bridge automatically checks the /health
endpoint before starting. Your MCP server should implement this endpoint:
app.get('/health', (req, res) => {
res.json({ status: 'healthy' });
});
To skip health checks:
mcp-bridge --url http://localhost:3200/mcp --no-health-check
- Node.js >= 18.0.0
- MCP server with HTTP/Streamable HTTP transport
- MCP server should implement
/health
endpoint (optional)
Enable detailed logging to see what's happening:
# Set log level via environment variable
LOG_LEVEL=debug mcp-bridge --url http://localhost:3200/mcp
# Or via CLI option
mcp-bridge --url http://localhost:3200/mcp --log-level debug
# Available log levels: trace, debug, info, warn, error, fatal
mcp-bridge --log-level trace # Most verbose
The bridge uses Pino for structured logging with pretty formatting in development and JSON in production.
-
"MCP server not reachable"
- Ensure your HTTP MCP server is running
- Check the URL is correct
- Verify network connectivity
-
"Parse error"
- Verify your MCP server returns valid JSON-RPC responses
- Check Content-Type headers
-
Session issues
- Ensure your server properly handles Mcp-Session-Id headers
- Check session timeout settings
# Clone repository
git clone https://github.com/wsd-team-dev/mcp-stdio-http-bridge.git
cd mcp-stdio-http-bridge
# Install dependencies
npm install
# Run tests
npm test
# Run tests with coverage
npm run test:coverage
# Run linting
npm run lint
# Format code
npm run format
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
MIT Β© WSD Team
For issues and questions, please use the GitHub issue tracker.