MCP Server Runner is a WebSocket server implementation that bridges WebSocket clients with Model Context Protocol (MCP) servers. It manages connections between clients and MCP servers, handles bidirectional communication, and supports various configuration options to adapt to different deployment scenarios.
To install and run the MCP Server Runner, follow these steps:
cargo build --release
target/release
directoryThe MCP Server Runner can be configured through environment variables or a JSON configuration file.
PROGRAM= # Path to the MCP server executable (required if no config file)
ARGS= # Comma-separated list of arguments for the MCP server
HOST=0.0.0.0 # Host address to bind to (default: 0.0.0.0)
PORT=8080 # Port to listen on (default: 8080)
CONFIG_FILE= # Path to JSON configuration file
Any additional environment variables will be passed to the MCP server process.
For more complex setups, you can use a JSON configuration file:
{
"servers": {
"filesystem": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-filesystem",
"/path/to/workspace"
]
},
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "your_token_here"
}
}
},
"default_server": "filesystem",
"host": "0.0.0.0",
"port": 8080
}
The server uses the following priority order when determining configuration:
CONFIG_FILE
environment variablePROGRAM
, ARGS
, etc.)export PROGRAM=npx
export ARGS=-y,@modelcontextprotocol/server-github
export PORT=8080
export GITHUB_PERSONAL_ACCESS_TOKEN=github_pat_***
cargo run --release
# Specify the config file as an argument
cargo run --release config.json
# Or use the CONFIG_FILE environment variable
CONFIG_FILE=config.json cargo run --release
To connect to the MCP Server Runner from a client application:
const ws = new WebSocket("ws://localhost:8080");
// Set up event handlers
ws.onopen = () => {
console.log("Connected to MCP server");
};
ws.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log("Received message:", message);
};
ws.onerror = (error) => {
console.error("WebSocket error:", error);
};
ws.onclose = () => {
console.log("Disconnected from MCP server");
};
// Send a message to the server
ws.send(JSON.stringify({
type: "your-message-type",
// Add message payload here
}));
The MCP Server Runner can be easily deployed using Docker:
docker-compose up --build
You can create your own Docker configuration by using the provided Dockerfile:
FROM rust:latest as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bullseye-slim
COPY --from=builder /app/target/release/mcp-server-runner /usr/local/bin/
EXPOSE 8080
ENTRYPOINT ["mcp-server-runner"]
For more detailed logs to troubleshoot issues:
RUST_LOG=debug cargo run --release
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.
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"
]
}
}
}
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.
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.