Content
mcpo-rs
> MCP-to-OpenAPI proxy server, rewritten in Rust
Expose any MCP Server as an OpenAPI-compliant HTTP service, with zero configuration and instant usability.
This project is a Rust rewrite of [open-webui/mcpo](https://github.com/open-webui/mcpo), with code generated with AI assistance.
## Differences from the original mcpo
| | mcpo (Python) | mcpo-rs (Rust) |
| --- | --- | --- |
| Startup speed | ~1s (including Python interpreter initialization) | <10ms |
| Memory usage | ~50MB+ | ~5MB |
| Binary size | N/A (requires Python runtime) | ~8.5MB (single file) |
| Runtime Python 3.11+, uv/pip | None |
| Cross-platform | Requires Python environment | Single works on Windows/Linux/macOS |
## Quick Start
### Installation
Download the binary for your platform from GitHub Releases:
- `mc-x86_64` —86_64
-po-linux-aarch64` — Linux ARM64
- `mcpo-linux-musl` — Linuxically linked, compatible with)
- `mcpo-m86_64` — Intel
- `mcpo-aarch64` — mac Silicon
- `mc-x86_64.exe Windows x86_64
Or source:
```bash build --release
```
###
```bash
# Proxy a stdio MCP server
mcpo --port 8000 --api-key "your-secret" -- uvx mcp-server-time --local-timezone=America/New_York
an SSE MCP server
--port 8000 sse -- http://127.0.1:8001/sse
# Proxy a Streamable HTTP MCP server
mcpo 8000 --able-http -- http://127.0.1:/mcp
```
After starting, access:
- API documentation: `http://localhost:8000- OpenAPI 3.0 specification: `http://localhost0/<server>/openapi- Swagger UI: `localhost:8000/<server`
- Health check:://localhost:8000### Configuration File Mode
-server configuration in Claude Desktop format:
```bash
mcpo --path/to/config.json --hot-reload
```
`config.jsonjson
{
"mcpServers": {
" {
"command": "npx",
"args":y", "@modelcontextprotocol"]
},
" {
"command": "uvx",
"args": ["mcp-server-time", "--local-timezone=America/New_Y "disabledTools": [""]
},
"": {
"typesse",
"urlhttp://127.0.1:8001/sse",
"headers": {
Authorization": "Bearer token"
}
},
"stream": {
"type": "streamable-http",
": "http://127.0.0.1:8002/mcp"
}
Each server has its route:
- `http://localhost:8000/memory` —
- `http://8000/time` —
- `http://8000/remote_server` — remote SSE server
- `localhost:8000/streamable_server` — Streamable HTTP server
### Hot Reload
Enabling `--hot-reload` will automatically reload the server list when the configuration file is modified:
```bash
mcpo --config config.json --hot-reload
```
- New server → automatically add route
- Deleted server → automatically unload route
- Modified server configuration → automatically reconnect
### API Key Authentication
```bash
mcpo --api-key-secret-key" --cp_command
```
must carry the Header:
```http
Authorization:-secret-key
```
Parameters
| Parameter | | Default value | Description --- | --- | --- |
| `--host`` | `0.0.0.0` | |
| `--port` | `-p` | `800 | Listen port |
|-key` | `-k — | API authentication key `--type` | —stdio` | Server typeio / sse / stream |
| `--config`c` | — | path |
| `--name` | `-n` | `MCP OpenAPI Proxy` | |
| `--description`d` | — | Server description `--cors-allowins` | — | `*` | CORS allowed origins (comma-separated) |
| `--path-prefix` | — | `/` | URL prefix |
| `--root-path` | — | — | Reverse proxy root path |
| `--header` | — | — | SSE/HTTP request headers (JSON format) |
| `--hot-reload` | — | false | Enable configuration file hot reload |
| `--log-level` | — | `info` | Log level |
| `--strict-auth` | — | false | API Key protects all endpoints |
## OpenAPI 3.0
Each MCP server automatically generates an OpenAPI 3.0 JSON specification:
```http
GET /{server}/openapi.json
```
Response format:
```json
{
"openapi": "3.0.3 "info": {
": "time MCP Server "version": "1.0"
},
paths": {
"/_current_time": {
": {
"operation "time_get_current_time "requestBody": {
content": {
"": {
"schema": {
"$ref": "#/schemas/get_current_time_params }
}
}
}
}
```
Each tool's JSON parameters come from the `` in the MCP protocol Configuration File JSON Schema configuration file follows the JSON in `config.schema see [config.schema.json.schema.json).
Supports three:
- **stdio**: communication, specify `command` and optional `args`, `env **sse**: Server Events, specify `type"` and `urlstreamable-http**: Stream, specify `typestreamable-http"` and`
## Project Structure
src/
├── main # CLI entry (clap)
├── server.rs ix-web HTTP server +
├── config.rs loading and validation
.rs # Connection manager openapi.rs # generates OpenAPI 3.0 JSON
├── auth.rs # API Key authentication middleware
├── watcher.rs # Configuration file hot reload
└── mcp/
├── mod.rs
├── types.rs # JSON-RPC 2.0 / MCP protocol types
├── client.rs # MCP client wrapper
├── stdio.rs # stdio transport layer
├── sse.rs # SSE transport layer
able_http.rs # Streamable HTTP transport layer## Building from Source
```bash
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Clone the repository
git clone https://github.com/xiaofeiTM233/mcpo-rs.git
cd mcpo-rs
# Build
cargo build --release
# Binary location
./target/release/mcpo --help
```
### Cross-Compilation
```# Linux x86_64 (statically linked build --release --target x86_64-unknown-linux
# Linux ARM64
cargo build --release --arch64-unknown-linux-gnu
# macOS (on macOS)
cargo build --release --target aarch64-apple-darwin
# Windows (on Windows or cross-compiled)
cargo build --release --target x86_64-pc-windows-msvc
```
## Notes
This README generated with AI assistance. have any issues, an issue or [contacthttps://github.com/xTM233)!