WebSocket Protocol Converter
STDIOProof of concept server that exposes stdio MCP server over websocket.
Proof of concept server that exposes stdio MCP server over websocket.
This repo is a proof of concept MCP server that exposes another stdio MCP server over a websocket.
MCP servers are hard to use.
The primary transport mechanism for MCP servers is stdio, i.e. in your MCP client program you need to spawn a new process for the MCP server you want to use. This has downsides:
npx ...
or uvx ...
which comes with all of the slowness of these tools (2-3s spinup times are normal).What if MCP servers were actually... servers? I.e. communication with them happened over the network instead of stdio. Then you could have an easier time using them programatically.
This repo contains a wrapper program that will take an existing MCP server (here is a list of the official ones, but they're all over now) and expose it via websocket:
bun run mcp-server-wrapper -p 3001 -- npx -y @modelcontextprotocol/server-puppeteer@latest
and for faster spin up times, install it and invoke it using node
directly:
pnpm install -g @modelcontextprotocol/server-puppeteer@latest bun run mcp-server-wrapper -p 3001 -- node ~/Library/pnpm/global/5/node_modules/@modelcontextprotocol/server-puppeteer/dist/index.js
import { Client } from "@modelcontextprotocol/sdk/client/index.js"; import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js"; const transport = new WebSocketClientTransport(new URL("ws://localhost:3001")); const client = new Client( { name: "example-client", version: "1.0.0", }, { capabilities: {}, } ); await client.connect(transport); const tools = await client.listTools(); console.log( "Tools:", tools.tools.map((t) => t.name) ); await client.close();
bun run mcp-server-wrapper-client $ bun run src/mcp-server-wrapper/example-client/example-client.ts Tools: [ "puppeteer_navigate", "puppeteer_screenshot", "puppeteer_click", "puppeteer_fill", "puppeteer_evaluate" ]
For a given MCP server configuration, e.g.
{ "mcpServers": { "fetch": { "command": "uvx", "args": ["mcp-server-fetch"] } } }
We'd like to build it into a docker image that exposes a websocket, that we can run anywhere. This repo contains a script that will output a Dockerfile for a given MCP server configuration: