关于 Juhe Mcp Server
Juhe Mcp Server(文档名称为 mcp-proxy)可双向桥接 MCP 服务传输方式。它既能让基于 stdio 的客户端连接远程 SSE 服务,也能通过 SSE 向远程客户端开放本地 stdio 服务。
主要功能
- 01将 stdio 客户端接入远程 SSE 服务
- 02通过 SSE 暴露本地 stdio 服务
- 03设置 SSE 主机和端口
- 04传递请求头和环境变量
- 05作为 Python 包或容器运行
适用场景
- 01让仅支持 stdio 的客户端连接 SSE 服务
- 02使远程客户端访问本地 stdio 服务
- 03向 SSE 端点提供认证请求头
- 04在 SSE 代理后运行本地 MCP 服务
MCP 相关
作为 MCP 传输代理,支持 stdio 转 SSE 和 SSE 转 stdio 两种模式,连接使用不同传输方式的 MCP 客户端与服务。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
mcp-proxy
关于
mcp-proxy 是一款可在服务传输方式之间切换的工具。支持以下两种模式:
- stdio 转 SSE
- SSE 转 stdio
1. stdio 转 SSE
运行一个通过 stdio 启动、连接到远程 SSE 服务的代理服务。
此模式可让 Claude Desktop 等客户端通过 SSE 与远程服务通信,即使它们原生不支持这种方式。
graph LR
A["Claude Desktop"] <--> |stdio| B["mcp-proxy"]
B <--> |SSE| C["External MCP Server"]
style A fill:#ffe6f9,stroke:#333,color:black,stroke-width:2px
style B fill:#e6e6ff,stroke:#333,color:black,stroke-width:2px
style C fill:#e6ffe6,stroke:#333,color:black,stroke-width:2px
1.1 配置
此模式要求将 MCP 服务的 SSE 端点 URL 作为程序的第一个参数传入。
参数
| 名称 | 必需 | 说明 | 示例 |
|---|---|---|---|
command_or_url | 是 | 要连接的 MCP 服务 SSE 端点 | http://example.io/sse |
--headers | 否 | MCP 服务 SSE 连接使用的请求头 | Authorization 'Bearer my-secret-access-token' |
环境变量
| 名称 | 必需 | 说明 | 示例 |
|---|---|---|---|
API_ACCESS_TOKEN | 否 | 可用于替代 --headers Authorization 'Bearer <API_ACCESS_TOKEN>' | YOUR_TOKEN |
1.2 使用示例
mcp-proxy 应由 MCP 客户端启动,因此必须相应地进行配置。
对于 Claude Desktop,配置项可以如下所示:
{
"mcpServers": {
"mcp-proxy": {
"command": "mcp-proxy",
"args": ["http://example.io/sse"],
"env": {
"API_ACCESS_TOKEN": "access-token"
}
}
}
}
2. SSE 转 stdio
运行一个代理服务,对外提供 SSE 服务,并连接到本地 stdio 服务。
这可以让远程连接访问本地 stdio 服务。mcp-proxy 会开放一个端口来监听 SSE 请求,并启动一个处理 MCP 请求的本地 stdio 服务。
graph LR
A["LLM Client"] <-->|SSE| B["mcp-proxy"]
B <-->|stdio| C["Local MCP Server"]
style A fill:#ffe6f9,stroke:#333,color:black,stroke-width:2px
style B fill:#e6e6ff,stroke:#333,color:black,stroke-width:2px
style C fill:#e6ffe6,stroke:#333,color:black,stroke-width:2px
2.1 配置
此模式要求设置 --sse-port 参数。可以设置 --sse-host 参数,以指定 SSE 服务监听的主机 IP 地址。可以使用 --env 参数向本地 stdio 服务传递其他环境变量。本地 stdio 服务的命令行参数必须放在 -- 分隔符之后。
参数
| 名称 | 必填 | 描述 | 示例 |
|---|---|---|---|
command_or_url | 是 | 要启动的 MCP stdio 服务命令 | uvx mcp-server-fetch |
--sse-port | 否,随机可用端口 | SSE 服务监听的端口 | 8080 |
--sse-host | 否,默认为 127.0.0.1 | SSE 服务监听的主机 IP 地址 | 0.0.0.0 |
--env | 否 | 要传递给 MCP stdio 服务的其他环境变量 | FOO=BAR |
--pass-environment | 否 | 启动服务时传递所有环境变量 | --no-pass-environment |
--allow-origin | 否 | 启动服务时传递所有环境变量 | --allow-cors "*" |
2.2 用法示例
要启动监听端口 8080 并连接到本地 MCP 服务的 mcp-proxy 服务:
# Start the MCP server behind the proxy
mcp-proxy uvx mcp-server-fetch
# Start the MCP server behind the proxy with a custom port
mcp-proxy --sse-port=8080 uvx mcp-server-fetch
# Start the MCP server behind the proxy with a custom host and port
mcp-proxy --sse-host=0.0.0.0 --sse-port=8080 uvx mcp-server-fetch
# Start the MCP server behind the proxy with a custom user agent
# Note that the `--` separator is used to separate the `mcp-proxy` arguments from the `mcp-server-fetch` arguments
mcp-proxy --sse-port=8080 -- uvx mcp-server-fetch --user-agent=YourUserAgent
这将启动一个 MCP 服务,可通过 http://127.0.0.1:8080/sse 连接。
安装
通过 Smithery 安装
要通过 Smithery 自动为 Claude Desktop 安装 MCP Proxy:
npx -y @smithery/cli install mcp-proxy --client claude
通过 PyPI 安装
此软件包的稳定版本可在 PyPI 仓库中获取。可以使用以下命令安装:
# Option 1: With uv (recommended)
uv tool install mcp-proxy
# Option 2: With pipx (alternative)
pipx install mcp-proxy
安装后,可以使用 mcp-proxy 命令运行服务。请参阅上文中各模式的配置选项。
通过 Github 仓库安装(最新版本)
可以使用以下命令从 git 仓库安装此软件包的最新版本:
uv tool install git+https://github.com/sparfenyuk/mcp-proxy
说明
如果已安装此服务,可以使用
uv tool upgrade --reinstall命令更新。
说明
如果要删除此服务,请使用
uv tool uninstall mcp-proxy命令。
作为容器安装
从 0.3.2 版本开始,可以拉取并运行相应的容器镜像:
docker run -t ghcr.io/sparfenyuk/mcp-proxy:v0.3.2-alpine --help
扩展容器镜像
可以扩展 mcp-proxy 容器镜像以包含其他可执行文件。例如,默认情况下不包含 uv,但可以使用它创建自定义镜像:
# file: mcp-proxy.Dockerfile
FROM ghcr.io/sparfenyuk/mcp-proxy:latest
# Install the 'uv' package
RUN python3 -m ensurepip && pip install --no-cache-dir uv
ENV PATH="/usr/local/bin:$PATH" \
UV_PYTHON_PREFERENCE=only-system
ENTRYPOINT [ "mcp-proxy" ]
Docker Compose 设置
使用自定义 Dockerfile,可以在 Docker Compose 文件中定义服务:
services:
mcp-proxy-custom:
build:
context: .
dockerfile: mcp-proxy.Dockerfile
network_mode: host
restart: unless-stopped
ports:
- 8096:8096
command: "--pass-environment --sse-port=8096 --sse-host 0.0.0.0 uvx mcp-server-fetch"
说明
请务必设置
--pass-environment参数,否则会出现错误“在托管安装或搜索路径中找不到解释器”
命令行参数
usage: mcp-proxy [-h] [-H KEY VALUE] [-e KEY VALUE] [--pass-environment | --no-pass-environment] [--sse-port SSE_PORT] [--sse-host SSE_HOST]
[--allow-origin ALLOW_ORIGIN [ALLOW_ORIGIN ...]]
[command_or_url] [args ...]
Start the MCP proxy in one of two possible modes: as an SSE or stdio client.
positional arguments:
command_or_url Command or URL to connect to. When a URL, will run an SSE client, otherwise will run the given command and connect as a stdio client. See corresponding options for more details.
options:
-h, --help show this help message and exit
SSE client options:
-H KEY VALUE, --headers KEY VALUE
Headers to pass to the SSE server. Can be used multiple times.
stdio client options:
args Any extra arguments to the command to spawn the server
-e KEY VALUE, --env KEY VALUE
Environment variables used when spawning the server. Can be used multiple times.
--pass-environment, --no-pass-environment
Pass through all environment variables when spawning the server.
SSE server options:
--sse-port SSE_PORT Port to expose an SSE server on. Default is a random port
--sse-host SSE_HOST Host to expose an SSE server on. Default is 127.0.0.1
--allow-origin ALLOW_ORIGIN [ALLOW_ORIGIN ...]
Allowed origins for the SSE server. Can be used multiple times. Default is no CORS allowed.
Examples:
mcp-proxy http://localhost:8080/sse
mcp-proxy --headers Authorization 'Bearer YOUR_TOKEN' http://localhost:8080/sse
mcp-proxy --sse-port 8080 -- your-command --arg1 value1 --arg2 value2
mcp-proxy your-command --sse-port 8080 -e KEY VALUE -e ANOTHER_KEY ANOTHER_VALUE
mcp-proxy your-command --sse-port 8080 --allow-origin='*'
测试
使用 mcp-server-fetch 服务运行 mcp-proxy 服务进行检查。可以使用 检查器工具 测试目标服务。
# Run the stdio server called mcp-server-fetch behind the proxy over SSE
mcp-proxy --sse-port=8080 uvx mcp-server-fetch &
# Connect to the SSE proxy server spawned above using another instance of mcp-proxy given the URL of the SSE server
mcp-proxy http://localhost:8080/sse
# Send CTRL+C to stop the second server
# Bring the first server to the foreground
fg
# Send CTRL+C to stop the first server
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。