使用说明
MCP工具转换代理
一个Python CLI,在应用可配置的工具转换(名称、描述、参数)时代理远程MCP服务器。透明地位于MCP客户端(如Claude Desktop)和远程MCP服务器之间。
安装
pip install mcp-transform-proxy
快速开始
- 创建配置文件:
{
"mcpServers": {
"myserver": {
"url": "https://my-mcp-server.example.com/mcp",
"tools": {
"original_tool": {
"description": "Enhanced description with context about when to use this tool"
}
}
}
}
}
- 运行代理:
mcp-transform-proxy --config config.json
配置
完整配置示例
{
"proxy": {
"name": "MyToolProxy",
"transport": "stdio",
"port": 8080
},
"mcpServers": {
"weather": {
"url": "https://weather-api.example.com/mcp",
"transport": "sse",
"tools": {
"get_weather": {
"name": "check_weather",
"description": "Check current weather. Use when user asks about weather.",
"arguments": {
"units": {
"default": "metric",
"hide": true
},
"location": {
"name": "city",
"description": "City name to check"
}
}
},
"internal_tool": {
"enabled": false
}
}
}
}
}
配置参考
代理服务器设置
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
name |
string | “MCP转换代理” | 代理服务器的名称 |
transport |
“std io” | “http” | “stdio” |
port |
integer | 8080 | HTTP端口(仅用于HTTP传输) |
服务器设置
| 字段 | 类型 | 必填 | 描述 |
|---|---|---|---|
url |
string | 是 | 上游MCP服务器的URL |
transport |
“可流式传输http” | “sse” | 否 |
tools |
对象 | 否 | 工具转换(按工具名称键入) |
工具转换
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
name |
string | null | 重命名工具 |
description |
string | null | 替换工具描述 |
enabled |
boolean | true | 设置为false以隐藏工具 |
arguments |
对象 | {} | 参数转换 |
参数转换
| 字段 | 类型 | 默认值 | 描述 |
|---|---|---|---|
name |
string | null | 重命名参数 |
description |
string | null | 替换参数描述 |
default |
any | null | 设置默认值 |
hide |
boolean | false | 对客户端隐藏参数 |
工具名称前缀
FastMCP的复合代理会自动在工具名称前添加服务器名称。例如,如果您有一个名为的服务器 weather 用工具 get_forecast,前缀名称将为 weather_get_forecast.
配置工具转换时,请使用 原始的 配置中的工具名称(不带前缀)-代理在内部处理前缀。
CLI选项
Usage: mcp-transform-proxy [OPTIONS]
Options:
-c, --config PATH Path to JSON config file (required)
-t, --transport TEXT Override transport mode (stdio or http)
-p, --port INTEGER Override HTTP port
--version Show version
--help Show this message and exit
发展
# Clone the repository
git clone https://github.com/bbrowning/mcp-transform-proxy.git
cd mcp-transform-proxy
# Create virtual environment
python -m venv .venv
source .venv/bin/activate
# Install in development mode
pip install -e ".[dev]"
# Run tests
pytest
# Run linter
ruff check .
# Run type checker
mypy src
许可证
麻省理工学院
