stagenth file-relay 的本地 stdio MCP 代理壳 (shim),桥接到远端 HTTPS MCP 服务
Project description
stagenth-mcp-shim
把 stagenth file-relay 这个远端 HTTPS MCP 服务
装进一个跑在你本机的 stdio MCP server, 让 Cline / Claude Desktop / Cursor 等只支持
stdio 的客户端能无痛接入, 并且 让 download_file 真正把文件下到你本地磁盘而不是让
AI 在上下文里读一堆 base64 再自己写代码解码。
为什么存在
直接用远端 HTTPS MCP (type: "http" / url: "https://...") 配置, 在 VS Code Cline
等客户端上握手/鉴权经常踩坑。本地 stdio 形态是所有客户端最稳定支持的方式。
本 shim 做两件事:
- 透明代理 —— Cline 发的 JSON-RPC 用 stdio 收进来, 转成 HTTPS POST 打到
https://stagenth.com/mcp/file-relay/, 响应按 SSE 解析后写回 stdio。 download_file劫持 —— 在远端原参数基础上多一个save_to字段。AI 调用后, 字节在 shim 进程里流式写到你本机磁盘, AI 的上下文只看到{"saved_to": "/abs/path", "size_bytes": ..., "sha256": "..."}, 不再拉 base64, 也不需要 AI 自己 curl。
安装
# 需要 Python >= 3.10
pip install stagenth-mcp-shim
开发版 (本仓库):
cd mcp-shim
pip install -e .
装完应当拿到 stagenth-mcp CLI:
stagenth-mcp --help # (目前无参数, 直接跑就是 stdio server)
拿 API Token
- 浏览器打开 https://stagenth.com/mcp/file-relay/console/tokens
NEW TOKEN→ 复制明文 (mcp_xxxxxxxx...47 字符, 只会显示一次)- 下一步把它填进客户端配置的
env
在 VS Code Cline 里接入
打开 Cline 的 MCP 配置 (Cline 图标 → Settings → MCP Servers → Edit), 加:
{
"mcpServers": {
"stagenth-file-relay": {
"command": "stagenth-mcp",
"env": {
"STAGENTH_TOKEN": "mcp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
保存 → Cline 会自动重启这个 server → 应当看到 10 个工具 (绿灯)。
在 Claude Desktop 里
~/Library/Application Support/Claude/claude_desktop_config.json (macOS)
或 %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"stagenth-file-relay": {
"command": "stagenth-mcp",
"env": {
"STAGENTH_TOKEN": "mcp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
在 Cursor 里
~/.cursor/mcp.json:
{
"mcpServers": {
"stagenth-file-relay": {
"command": "stagenth-mcp",
"env": {
"STAGENTH_TOKEN": "mcp_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
可选环境变量
| 变量 | 默认 | 说明 |
|---|---|---|
STAGENTH_TOKEN |
(必填) | file-relay API Token |
STAGENTH_ENDPOINT |
https://stagenth.com/mcp/file-relay/ |
远端 MCP endpoint, 末尾 / 必须 |
STAGENTH_TIMEOUT |
600 |
单请求超时 (秒); 大文件上传可能要久 |
STAGENTH_DOWNLOAD_DIR |
~/Downloads |
默认下载目录 (没传 save_to 时) |
10 个工具
跟远端完全对齐, 唯一区别是 download_file 多了两个参数:
save_to(string, optional) —— 落地路径, 相对路径基于$STAGENTH_DOWNLOAD_DIRoverwrite(boolean, default false) —— 已存在时是否覆盖, false 时加(1)(2)后缀
其它工具 (list_files / upload_file / get_user_quota / create_share_link /
download_shared_file / import_shared_file / search_files / get_file_info /
delete_file) 100% 透传, 文档见
https://stagenth.com/mcp/file-relay 或仓库里的 docs/MCP.md。
Troubleshooting
客户端显示 "connection closed" / "server crashed"
stderr 日志里有线索 (Cline 里点 MCP server 卡片能看到 stderr):
FATAL: STAGENTH_TOKEN 环境变量未设置→ 检查env块拼写远端 HTTP 401: mcp_invalid_token→ Token 错/过期, 重新生成远端 HTTP 403: feature_not_in_plan→ 档位不够, 去 https://stagenth.com/mcp/file-relay?tab=plans 升级SSE 响应里没找到 data: 行→ 网络中间件吞了 SSE (公司网关常见), 换网络或联系运维
下载后文件在哪
默认 ~/Downloads。想改: 配置里加 env.STAGENTH_DOWNLOAD_DIR,
或让 AI 调用时传 save_to 绝对路径。
同名文件不想被覆盖
默认不覆盖, shim 会自动加 (1) / (2) 后缀。想覆盖: AI 传 overwrite: true。
开发
pip install -e ".[dev]"
# 手动跑一下, 用 stdin/stdout 跟它对话
STAGENTH_TOKEN=mcp_xxx stagenth-mcp
# 粘一个 initialize 请求:
# {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"manual","version":"0"}}}
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stagenth_mcp_shim-0.1.0.tar.gz.
File metadata
- Download URL: stagenth_mcp_shim-0.1.0.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
524d5033a2a720ca5440120056d68ec181f7defc157874550267dad4171f0034
|
|
| MD5 |
af5db1412d8313b64431909b180dbf83
|
|
| BLAKE2b-256 |
463cbcde84599395b1d06744db8b2948464dd407787958a69e4bde19028cafa2
|
File details
Details for the file stagenth_mcp_shim-0.1.0-py3-none-any.whl.
File metadata
- Download URL: stagenth_mcp_shim-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0d3eb022b4b904d97a67e83debf7d386a54440e5ca89c7ec2309e217dda58b0e
|
|
| MD5 |
33fa87e7fafa81d8e96b9baef15ffba0
|
|
| BLAKE2b-256 |
9fc6a28f72b0f1664e3dc69ad0258cea8f2e9f5cd80dda19d6061811b3d2ad0e
|