mcpproxy-0.2.1 is not a library.
MCP Proxy
A local stdin/stdout MCP (Model Context Protocol) server that proxies requests to a remote MCP server over HTTP.
Overview
This tool acts as a bridge between MCP clients that expect a local stdin/stdout interface and remote MCP servers that communicate over HTTP. It reads JSON-RPC requests from stdin, forwards them to the configured remote server, and writes the responses back to stdout.
Features
- Local MCP Interface: Provides standard stdin/stdout JSON-RPC interface expected by MCP clients
- Remote HTTP Proxy: Forwards all requests to a remote MCP server via HTTP POST
- Multiple Response Formats: Supports both JSON and Server-Sent Events (text/event-stream) responses
- Authentication Support: Optional Bearer token authentication for remote servers
- Error Handling: Proper JSON-RPC error responses for network failures and parsing errors
- Logging: Debug information written to stderr (doesn't interfere with JSON-RPC communication)
Installation
Option 1: npm Package (Recommended)
# Global installation
# Or use with npx (no installation required)
Option 2: Cargo Install
Option 3: Build from Source
Usage
Basic Usage
With Authentication
Command Line Options
--url, -u: Remote MCP server URL to proxy to (required)--token, -t: Optional authentication token for the remote server
How It Works
- Input: Reads JSON-RPC requests from stdin (one per line)
- Forward: Sends each request to the remote server via HTTP POST with headers:
Content-Type: application/jsonAccept: application/json, text/event-streamAuthorization: Bearer <token>(if token provided)
- Response Handling:
- JSON Response: Single JSON-RPC response written to stdout
- Event Stream Response: Multiple JSON-RPC responses from Server-Sent Events, each written to stdout
- Logging: Debug information goes to stderr
Response Format Support
JSON Responses
Standard single JSON-RPC response from the remote server.
Server-Sent Events (Event Stream)
When the remote server responds with Content-Type: text/event-stream, the proxy:
- Parses the event stream format (
data: ...lines) - Extracts JSON-RPC responses from each event
- Outputs each response as a separate line to stdout
- Handles multiple responses from a single request
JSON-RPC Protocol
The proxy handles standard JSON-RPC 2.0 messages:
Request Format
Response Format
Error Format
Error Codes
-32700: Parse error (invalid JSON)-32603: Internal error (network or server errors)- HTTP status codes are passed through as error codes for remote server errors
Example Usage with MCP Client
# Using npm package
# Or if globally installed
# Test with a simple request
|
Claude Desktop Configuration
Using npx (No Installation Required)
Using Global Installation
Development
Building
Running Tests
Running with Debug Logging
RUST_LOG=debug
Dependencies
tokio: Async runtimereqwest: HTTP client with streaming supportserde/serde_json: JSON serializationclap: Command line argument parsinganyhow: Error handlingfutures-util: Stream processing for event streamstokio-util: Additional utilities for async I/O
License
This project is licensed under the MIT License.