@boilingdata/mcp-server-and-gw: MCP Gateway, Server, and Client
MCP Gateway, Server, and Client enables remote server connectivity for Claude Desktop by bridging stdio to HTTP SSE transport, facilitating seamless communication and resource discovery.
Author
boilingdata
README
MCP Gateway, Server, and Client
As long as Claude Desktop does not support connecting to remote servers, you can use this script to run a bridge from stdio to HTTP SSE (Server-Sent Events) endpoint.
The bridge script is node javasscript, but your server code can be whatever you use.
A Model Context Protocol gateway src/claude_gateway.ts from stdio to HTTP SSE transport.
shell## 1. Build yarn install yarn build ## 2. Copy the code or update the claude_desktop_config.json to match the script location ## (You many need to set the node path to full path) cp build/claude_gateway.js /tmp echo '{ "mcpServers": { "Claude Gateway Example": { "command": "node", "args": [ "/tmp/claude_gateway.js" ] } } }' > ~/Library/Application\ Support/Claude/claude_desktop_config.json ## 3. Start server so that claude can connect to it for discoverying its resources, tools, etc. node build/server.js ## 4. Start Claude Desktop
Example Server and Client
You can also develop the SSE server independently from Claude Desktop so you get faster iterations. For example, run the src/server.ts
and use the src/client.ts
as the client.
Start server, once you start the client on another terminal, you see the server output.
shell% node build/server.js Server is running on port 8808 --> Received connection: /sse New SSE connection. --> Received message (post) { jsonrpc: '2.0', id: 0, method: 'initialize', params: { protocolVersion: '2024-11-05', capabilities: {}, clientInfo: { name: 'example-client', version: '1.0.0' } } } <-- 202 Accepted --> Received message (post) { jsonrpc: '2.0', method: 'notifications/initialized' } <-- 202 Accepted --> Received message (post) { jsonrpc: '2.0', id: 1, method: 'resources/list' } <-- 202 Accepted --> Received message (post) { jsonrpc: '2.0', id: 2, method: 'tools/list' } <-- 202 Accepted --> Received message (post) { jsonrpc: '2.0', id: 3, method: 'tools/call', params: { name: 'query', arguments: { sql: 'SELECT 42;' } } } <-- 202 Accepted
Start the client
shell% node build/client.js Connecting... Connected: { resources: {}, tools: {}, templates: {} } { resources: [] } { tools: [ { name: 'query', description: 'Run a read-only SQL query on a DuckDB database', inputSchema: { type: 'object', properties: { sql: { type: 'string' } } } }, { name: 'visualise', description: 'Visualise SQL query results as an Apache ECharts chart. Provide the SQL clause that produces the data for the visualisation. Provide chart JSON configuration for Apache ECharts.', inputSchema: { type: 'object', properties: { sql: { type: 'string' }, chart: { type: 'string' } } } } ] } { content: [ { type: 'text', text: '[\n {\n "42": 42\n }\n]' } ], isError: false }