mcp-gateway
by: lightconetech
A gateway demo for MCP SSE Server
📌Overview
Purpose: The MCP Server Gateway serves as a protocol translator that allows the Claude Desktop application, which natively supports only stdio-based MCP implementations, to communicate with HTTP/SSE-based MCP servers.
Overview: This gateway addresses the compatibility gap between the stdio protocol used by Claude Desktop and the commonly utilized HTTP/SSE transport in many MCP servers. By facilitating seamless interaction between these differing protocols, the gateway expands the functionality and interoperability of Claude Desktop with a wide range of MCP servers.
Key Features:
-
Protocol Translation: Converts stdio input from Claude Desktop into HTTP/SSE requests that can be understood by MCP servers, ensuring compatibility and enhanced communication capabilities.
-
Response Handling: Translates SSE responses from the MCP servers back into stdio format, allowing Claude Desktop to process the incoming data as if it were received from a native stdio interface.
MCP Server Gateway
A gateway service that bridges the stdio-based Model Context Protocol (MCP) implementation in Claude Desktop with HTTP/SSE-based MCP servers. This resolves the protocol compatibility gap since Claude Desktop currently only supports stdio-based MCP servers. See the discussion here.
Why This Gateway?
Claude Desktop currently only supports the stdio protocol for MCP servers, while many MCP servers use HTTP with Server-Sent Events (SSE) transport. This gateway acts as a protocol translator, allowing Claude Desktop to communicate with any HTTP/SSE MCP server by:
- Accepting stdio input from Claude Desktop
- Converting and forwarding requests to HTTP/SSE MCP servers
- Converting SSE responses back to stdio format for Claude Desktop
Installation
Install the gateway globally using npm:
npm install -g @mcphub/gateway
Configuration
1. Find the Gateway Path
After installation, find where npm installed the gateway using these commands:
npm root -g
The gateway will be located at:
<npm_global_root>/@mcphub/gateway/dist/src/mcphub-gateway.js
Common global package locations:
- macOS (Homebrew Node):
/opt/homebrew/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js
- macOS (default):
/usr/local/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js
- Windows:
%AppData%\npm\node_modules\@mcphub\gateway\dist\src\mcphub-gateway.js
Verify the installation and path:
npm list -g @mcphub/gateway
2. Configure Claude Desktop
Create or update your Claude Desktop configuration file.
- macOS:
~/Library/Application Support/Claude Desktop/config.json
- Windows:
%APPDATA%\Claude Desktop\config.json
Add this configuration, replacing the path in args
with your actual gateway path:
{
"mcpServers": {
"server-name": {
"command": "node",
"args": ["/opt/homebrew/lib/node_modules/@mcphub/gateway/dist/src/mcphub-gateway.js"]
}
}
}
3. Configure MCP Server Connection
Set the MCP server URL via an environment variable:
export MCP_SERVER_URL=https://your-mcp-server.com/api/mcp
By default, the gateway connects to the MCP Hub server at https://server.mcphub.ai/api/mcp
, which provides access to various pre-configured MCP services.
4. Start Claude Desktop
Start or restart Claude Desktop to apply the changes.
Troubleshooting
-
To find the gateway path:
npm list -g npm list -g @mcphub/gateway
-
Verify Node.js and npm installations:
node --version npm --version
-
Common issues:
-
On macOS with Homebrew, ensure Node.js is properly linked:
brew doctor brew link node
-
For permission errors, consider using
sudo
during installation.
-
License
Support
If you encounter any issues or have questions, file an issue on GitHub.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.