About Mcpgate
Mcpgate is an MCP server published by 54rt1n in the Browser category: a simple stdio-to-HTTP tunnel to shuttle JSON-RPC requests to SSE endpoints.
The repository has 2 stars and 2 forks, with the last commit a year ago. Six months or more without a commit doesn't mean the server is broken, but check the open issues before depending on it in production.
Install
git clone https://github.com/54rt1n/mcpgateThis server has no ConduID identity, so agent calls to it are not receipted. Pin the version you install and review the source before granting it credentials.
Ask AI
Ask AI about Mcpgate
Powered by Claude · Grounded in docs
Security checks
Static checks derived from the repository 2 hours ago. Heuristics on the source, not an audit.
- ✓README presentThe repository ships documentation.
- !License declaredNo license file. Legally you have no right to use it in a product.
- !Tests presentNo tests found. Behaviour changes may go unnoticed between versions.
- !Dependencies pinnedNo lockfile. Installs can pull different code over time.
- ✓No dynamic code executionSource scan found no eval, dynamic Function, or shell execution.
- !Scoped permissionsDoesn't declare a permission scope. Assume it can do anything its process can.
README
MCPGate
What is MCPGate?
MCPGate creates a resilient bidirectional bridge between standard I/O and HTTP, enabling any application to communicate with MCP servers. It handles all the complexity of connection management, session persistence, and error recovery.
Built on the official @modelcontextprotocol/sdk, MCPGate provides a robust implementation of the MCP client specification with enhanced reliability features.
graph LR
A[Your Application] -->|JSON-RPC via stdin| B[MCPGate]
B -->|HTTP POST| C[MCP Server]
C -->|Server-Sent Events| B
B -->|JSON-RPC via stdout| A
style B fill:#f9f,stroke:#333,stroke-width:2px
Features
- ⚡ Reliable Communication - Stable bridge between stdin/stdout and HTTP/SSE
- 🔄 Smart Reconnection - Automatic recovery from network issues and session timeouts
- 🔐 Session Management - Preserves sessions when possible, graceful fallbacks when not
- 📋 Message Queuing - No messages lost during connection interruptions
- 🚦 Intelligent Error Handling - Different strategies for different error types
- 📦 Lightweight - Minimal dependencies, focused functionality
Installation
# Install globally via npm
npm install -g mcpgate
# Or use without installation via npx
npx mcpgate http://example.com:8000/sse
Usage
Basic Command
mcpgate <server-url>
With Options
mcpgate http://example.com:8000/sse --debug --reconnect-delay=2000 --max-reconnects=10
In an MCP Client Configuration
{
"mcpServers": {
"your-servername": {
"command": "npx",
"args": ["-y", "mcpgate", "http://example.com:8000/sse"]
}
}
}
How It Works
MCPGate establishes and maintains the complex bidirectional connection required by the Model Context Protocol:
-
Connection Setup
- Creates an SSE connection to receive server messages
- Obtains the endpoint URL for sending messages via POST
-
Message Handling
- Reads JSON-RPC messages from stdin
- Queues messages when connection isn't ready
- Sends messages to server via HTTP POST
- Receives responses via SSE and forwards to stdout
-
Advanced Reconnection
- Detects connection failures through multiple signals
- Uses exponential backoff for reconnection attempts
- Preserves original session ID when possible
- Falls back to new session when necessary
- Re-executes handshake sequence after reconnection
Examples
Simple Pipe
echo '{"jsonrpc":"2.0","method":"chat","params":{"message":"Hello"},"id":1}' | mcpgate http://localhost:8000/sse
Integration with Tools
# Use with a custom client
my-mcp-client | mcpgate http://example.com:8000/sse | result-processor
Debugging
# Save logs to a file while using the bridge
mcpgate http://example.com:8000/sse 2> mcpgate.log
Technical Details
Architecture
MCPGate uses a clean module pattern with clear separation of concerns:
- Connection Management - Transport and session lifecycle
- Message Processing - Queue and send messages
- Event Handling - Process SSE events
- Error Management - Classify and respond to errors
Dependencies
MCPGate builds upon three key libraries:
- @modelcontextprotocol/sdk - Core MCP client implementation
- eventsource - Server-Sent Events client for node.js
- node-fetch - Lightweight fetch implementation
These dependencies should be automatically installed when you install mcpgate, so there's no need to install them separately.
Session Persistence Strategy
- Initial connection establishes a unique session ID
- On disconnection, attempts to reconnect with the same session ID
- After multiple failures, falls back to a new session
- Properly executes handshake sequence to reinitialize connection
Troubleshooting
Common Issues
| Problem | Possible Solution |
|---|---|
| Connection Refused | Ensure MCP server is running and URL is correct |
| Authentication Failures | Verify session credentials are valid |
| Frequent Disconnections | Check network stability and server timeout settings |
| Delayed Responses | Examine server logs for performance bottlenecks |
Logs
All debug information is sent to stderr:
# Filter logs for specific events
mcpgate http://example.com:8000/sse 2>&1 | grep "reconnect"
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Author
Martin Bukowski
README fetched from the repository 2 hours ago. The original is authoritative.