Stdio to SSE MCP MCP server

Transforms stdio-based MCP servers into websocket-accessible servers, enabling network-based communication and simplified client development.
Back to servers
Provider
rgarcia
Release date
Dec 02, 2024
Language
TypeScript
Stats
1 star

This MCP server acts as a bridge, allowing you to access stdio-based MCP servers over WebSockets. It solves the challenges of process management when using MCP servers by transforming them into network-accessible services that can be more easily utilized in various environments.

Installation

You can install and run the MCP server wrapper using either Bun or npm. The wrapper converts a standard stdio MCP server into a WebSocket-accessible server.

Prerequisites

  • Node.js environment
  • Bun (recommended) or npm
  • An MCP server you want to expose via WebSocket

Installing with Bun

Run the wrapper directly using Bun:

bun run mcp-server-wrapper -p 3001 -- npx -y @modelcontextprotocol/server-puppeteer@latest

For faster startup times, you can install the MCP server globally first:

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

Usage

Connecting to the WebSocket Server

You can interact with the WebSocket-based MCP server programmatically using the MCP SDK:

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();

Running the Client Example

Execute the included example client to test the connection:

bun run mcp-server-wrapper-client

Or run it directly:

bun run src/mcp-server-wrapper/example-client/example-client.ts

You should see output listing the available tools:

Tools: [ "puppeteer_navigate", "puppeteer_screenshot", "puppeteer_click", "puppeteer_fill",
  "puppeteer_evaluate"
]

Containerization

You can also package your MCP server configuration into a Docker container for deployment. Create a configuration file like:

{
  "mcpServers": {
    "fetch": {
      "command": "uvx",
      "args": ["mcp-server-fetch"]
    }
  }
}

Then use the included script to generate a Dockerfile for this configuration, which will expose your MCP server over WebSockets.

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later