mcpField
J
Juhe Mcp Server

Juhe Mcp Server

本地服务
github.com/juhemcp开发工具384 周前更新

关于 Juhe Mcp Server

Juhe Mcp Server(文档名称为 mcp-proxy)可双向桥接 MCP 服务传输方式。它既能让基于 stdio 的客户端连接远程 SSE 服务,也能通过 SSE 向远程客户端开放本地 stdio 服务。

主要功能

  1. 01将 stdio 客户端接入远程 SSE 服务
  2. 02通过 SSE 暴露本地 stdio 服务
  3. 03设置 SSE 主机和端口
  4. 04传递请求头和环境变量
  5. 05作为 Python 包或容器运行

适用场景

  1. 01让仅支持 stdio 的客户端连接 SSE 服务
  2. 02使远程客户端访问本地 stdio 服务
  3. 03向 SSE 端点提供认证请求头
  4. 04在 SSE 代理后运行本地 MCP 服务

MCP 相关

作为 MCP 传输代理,支持 stdio 转 SSE 和 SSE 转 stdio 两种模式,连接使用不同传输方式的 MCP 客户端与服务。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"juhe-mcp-proxy": {
"command": "uvx",
"args": [
"juhe-mcp-proxy"
],
"env": {
"LOG_LEVEL": "<LOG_LEVEL>",
"API_ACCESS_TOKEN": "<API_ACCESS_TOKEN>"
}
}
}
}
启动命令uvx juhe-mcp-proxy
需要配置的环境变量
LOG_LEVEL
API_ACCESS_TOKEN密钥

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
pypijuhe-mcp-proxy

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍

mcp-proxy

GitHub License PyPI - Python Version PyPI - Downloads codecov smithery badge

关于

mcp-proxy 是一款可在服务传输方式之间切换的工具。支持以下两种模式:

  1. stdio 转 SSE
  2. 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.1SSE 服务监听的主机 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

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。