MCP-RPC Bridge
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
MCP-RPC Bridge: Integration with RPC Runtime
An MCP (Model Context Protocol) server that bridges Claude and other MCP clients to the mcp-rpc-runtime WebSocket RPC system, enabling "Code Mode" execution where LLMs write TypeScript instead of using traditional tool calls.
How It Works
This MCP server acts as a translator between the MCP protocol and the RPC runtime's WebSocket interface:
Claude ◄──── MCP Protocol ────► MCP Bridge ◄──── WebSocket RPC ────► RPC Runtime
(stdio transport) (JSON-RPC over WS)Related MCP server: Herald
Installation
Prerequisites
Bun runtime (v1.0.0 or higher)
Running RPC runtime server at
ws://localhost:8080/ws
Method 1: One-Line Install (Recommended)
curl -fsSL https://raw.githubusercontent.com/jx-codes/mcp-rpc-bridge/main/install.sh | bashThis will:
Clone the repository
Install dependencies
Compile to standalone binary with
bun build --compileInstall to
~/.bun/bin/mcp-rpc-bridgeAdd
~/.bun/binto PATH if neededClean up temporary files
Method 2: Manual Global Install
# Clone and install globally
git clone https://github.com/jx-codes/mcp-rpc-bridge.git
cd mcp-rpc-bridge
bun install
bun run install-global
# Now you can use 'mcp-rpc-bridge' anywhere!
mcp-rpc-bridgeTo uninstall:
bun run uninstall-globalMethod 3: Direct Build and Run
# Clone the repository
git clone https://github.com/jx-codes/mcp-rpc-bridge.git
cd mcp-rpc-bridge
# Install dependencies and build
bun install
bun run build
# Run directly
bun run startMethod 4: Development Mode
# Clone for development
git clone https://github.com/jx-codes/mcp-rpc-bridge.git
cd mcp-rpc-bridge
bun install
# Run with auto-reload
bun run devQuick Start
Start your RPC runtime server (must be running on
ws://localhost:8080/ws)Configure Claude Desktop by adding to your MCP settings:
{
"mcpServers": {
"codemode": {
"command": "mcp-rpc-bridge"
}
}
}Or with custom port/hostname:
{
"mcpServers": {
"codemode": {
"command": "mcp-rpc-bridge",
"args": ["--rpc-port", "8080", "--hostname", "localhost"]
}
}
}Test the connection - Claude should now have access to these tools:
run_script- Execute TypeScript code with RPC accessget_available_rpc_tools- Get all available RPC functionshelp- Get help and examplesstatus- Check connection health
Integration Points
WebSocket Connection (src/websocket-manager.ts:12-26)
Maintains persistent connection to RPC runtime at
ws://localhost:8080/wsAuto-reconnects on connection loss with 1-second delay
Single connection with message correlation for concurrent requests
Message Correlation (src/message-correlator.ts:33-64)
Maps async RPC calls to MCP responses using unique IDs
Handles request/response matching across WebSocket boundary
Timeout management (default 30s) with proper cleanup
Tool Translation (src/rpc-mcp-server.ts:20-30)
Converts MCP
run_scriptcalls to RPC runtime script executionTranslates
get_available_rpc_toolsto HTTP client.ts fetchingProvides status checks for both WebSocket and HTTP endpoints
MCP Tools Provided
run_script
Executes TypeScript code on the RPC runtime with injected rpc client:
// Input (from Claude)
{
"code": "const result = await rpc.math.add({a: 5, b: 3}); console.log(result);",
"timeout": 30000
}
// What happens internally:
// 1. Generate unique ID: "mcp_1234567890_abc123"
// 2. Send to runtime: {"script": "...", "id": "mcp_1234567890_abc123"}
// 3. Runtime executes with injected rpc client
// 4. Return response: {"result": "8\n", "id": "mcp_1234567890_abc123"}get_available_rpc_tools
Fetches the complete TypeScript client definitions from runtime:
// Calls: GET http://localhost:8080/client.ts
// Returns: Complete TypeScript client with all type definitions
export interface RpcClient {
math: {
add(args: Math_AddArgs): Promise<number>;
multiply(args: Math_MultiplyArgs): Promise<number>;
};
pokemon: {
fetchPokemon(args: Pokemon_FetchArgs): Promise<Pokemon>;
};
}help
Provides runtime status and usage examples by combining:
Health check:
GET /health→ available functions listClient interface extraction from generated TypeScript
Usage examples and documentation
status
Health checks both communication channels:
HTTP endpoint:
GET /healthWebSocket connection: Test connectivity and response time
Configuration
Command-Line Arguments:
--rpc-port, -p # RPC server port (default: 8080)
--hostname, -h # Server hostname (default: localhost)
--timeout, -t # Request timeout in ms (default: 30000)Example Usage:
# Use defaults (localhost:8080)
mcp-rpc-bridge
# Custom port
mcp-rpc-bridge --rpc-port 9000
# Custom hostname and port
mcp-rpc-bridge --hostname 192.168.1.100 --rpc-port 9000
# Or with short flags:
mcp-rpc-bridge -h 192.168.1.100 -p 9000 -t 30000Configuration Function (src/config.ts:11-59):
export const get_config = (): McpConfig => {
const args = parseArgs({
args: process.argv.slice(2),
options: {
"rpc-port": { type: "string", short: "p" },
"hostname": { type: "string", short: "h" },
"timeout": { type: "string", short: "t" },
},
strict: false,
});
const hostname = args.values["hostname"] || "localhost";
const port = parseInt(args.values["rpc-port"] || "8080", 10);
const timeout = parseInt(args.values["timeout"] || "30000", 10);
// Construct URLs from hostname and port
const wsUrl = `ws://${hostname}:${port}/ws`;
const httpUrl = `http://${hostname}:${port}`;
return { rpcServer: { wsUrl, httpUrl }, defaultTimeout: timeout };
};Usage with Claude Desktop
MCP Configuration (using defaults):
{
"mcpServers": {
"rpc-bridge": {
"command": "mcp-rpc-bridge"
}
}
}Or with custom port/hostname:
{
"mcpServers": {
"rpc-bridge": {
"command": "mcp-rpc-bridge",
"args": ["--rpc-port", "9000", "--hostname", "192.168.1.100"]
}
}
}Claude Workflow:
Claude calls
get_available_rpc_toolsto see what functions are availableClaude writes TypeScript code using the
rpcobjectClaude calls
run_scriptwith the TypeScript codeCode executes on runtime with full access to all RPC functions
Results return to Claude as text output
Error Handling
Connection Failures (src/websocket-manager.ts:46-57):
// Auto-reconnection on unexpected WebSocket close
this.ws.onclose = () => {
console.log("WebSocket connection closed, attempting reconnect...");
setTimeout(() => {
if (!this.isConnecting) {
this.connect().catch((err) => console.error("Reconnection failed:", err));
}
}, 1000);
};Request Timeouts (src/message-correlator.ts:42-45):
const timeoutHandle = setTimeout(() => {
this.pendingRequests.delete(id);
reject(new Error(`Request timeout: ${id}`));
}, timeout);RPC Errors (src/message-correlator.ts:75-79):
if (response.error) {
request.reject(new Error(response.error));
} else {
request.resolve(response.result);
}Runtime Integration Flow
Startup Sequence
MCP Bridge starts → Connects to stdio transport for MCP communication
WebSocket connection → Connects to RPC runtime at configured URL
Health check → Verifies runtime is responding and gets function list
Ready → MCP server advertises tools to Claude
Script Execution Flow
Claude calls
run_script→ MCP request with TypeScript codeGenerate correlation ID → Unique ID for request/response matching
Send to runtime → WebSocket message
{script: "...", id: "..."}Runtime executes → Injects
rpcclient and runs TypeScriptResponse correlation → Match response ID to pending request
Return to Claude → MCP tool response with execution output
Type Discovery Flow
Claude calls
get_available_rpc_tools→ Requests available functionsHTTP fetch → GET
/client.tsfrom runtimeReturn definitions → Complete TypeScript client code with types
Development
Build and Run:
bun install
bun run build # TypeScript compilation
bun run start # Start MCP server
bun run dev # Watch mode developmentTesting Integration:
# Test WebSocket connection
echo '{"script":"console.log(\"test\")", "id":"test123"}' | websocat ws://localhost:8080/ws
# Test HTTP endpoints
curl http://localhost:8080/health
curl http://localhost:8080/client.ts
# Test MCP server (requires MCP client)
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | bun run startArchitecture Benefits
Clean Separation: MCP protocol concerns separate from RPC execution Protocol Translation: Handles impedance mismatch between MCP and WebSocket RPC Connection Management: Robust WebSocket handling with reconnection Async Correlation: Proper request/response matching for concurrent operations Error Propagation: Meaningful error messages across protocol boundary
Troubleshooting
"WebSocket connection failed": Runtime not running or wrong URL
"Request timeout": Increase RPC_TIMEOUT or check runtime performance
"Functions not appearing": Runtime /health endpoint not responding
"Script execution errors": Check runtime logs for TypeScript compilation issues
The MCP bridge handles the complexity of protocol translation so Claude can seamlessly execute TypeScript code against your RPC functions.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Talk to your public-facing AI from any MCP client — Claude, ChatGPT, Cursor, Cline, Windsurf.
Hosted MCP runtime where your agent publishes its own tools by tool call and keeps working.
Real-time chat hub for AI agents — Claude Code, Cursor, Cline, Codex over MCP or REST.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA minimal WebSocket-based MCP server implementation that enables modern tool integrations with VSCode, Claude, and other applications.MIT
- AlicenseNot gradedqualityFmaintenanceThe self-hosted MCP bridge between Claude Chat and Claude Code.46AGPL 3.0
- AlicenseNot gradedqualityDmaintenanceA local Model Context Protocol (MCP) server that exposes custom tools to Claude Desktop, enabling direct interaction with your local environment. It provides a framework for building and integrating custom TypeScript tools into the Claude interface.MIT
- AlicenseNot gradedqualityDmaintenanceProxy MCP server that translates tool calls into TypeScript code generation, enabling LLMs to orchestrate multi-tool workflows efficiently via code.50 npm14MIT