vscode-as-mcp-server
v0.0.13
Published
VSCode MCP relay that supports multiple servers
Readme
VSCode as MCP Relay
This is a Node.js implementation of an MCP (Mechanism, Control, Policy) relay for VSCode extensions. It's based on the Go implementation in ../mcp-relay/main.go but adds the following features:
Features
- Multiple Server Support: Scans ports from the specified port to +10 to discover and connect to multiple MCP servers.
- Custom Protocol Extensions: Implements custom protocol messages for:
- Client notifying server: "You are now the main server"
- Server requesting to client: "I want to be the main server"
- Fallback Capability: Can switch between available servers if the primary becomes unresponsive.
Installation
cd packages/relay
npm install -gUsage
vscode-as-mcp-relay --server-url http://localhost:60100 --listen-port 6011Command Line Options
--server-url: Base URL of the MCP server (default: http://localhost:60100)--listen-port: Starting port to listen for incoming JSON-RPC messages (default: 6011)
Custom Protocol
The relay implements a custom protocol for communication between clients and servers:
Registration:
{ "clientUrl": "http://localhost:PORT", "features": ["relay_protocol_v1"] }Set Main Server (Client to Server):
{ "jsonrpc": "2.0", "method": "$relay", "params": { "type": "set_main", "clientPort": PORT } }Request to be Main (Server to Client):
{ "jsonrpc": "2.0", "method": "$relay", "params": { "type": "request_main", "serverUrl": "http://localhost:PORT" } }
How It Works
- The relay scans ports to discover available MCP servers.
- It registers with all discovered servers.
- It establishes the first discovered server as the primary.
- It processes stdin and relays messages to the active server.
- If a server requests to be the main server, the relay can switch its active connection.
- If the active server becomes unresponsive, the relay can fail over to another server.
