Skip to main content

qca-mcp-proxy

把 Qoder Cloud Agents(QCA)的远程 MCP 服务包一层 MCP 服务:只转发 session 相关工具,外加 list_agents / list_environments / list_vaults 三个只读查询和 list_files / get_file 两个文件元数据查询。其余工具(agent / environment / vault / skill / deployment 的写操作、session 资源等)既不列出也不可调用。

  • 上游:QCA 远程 MCP,Streamable HTTP + Authorization: Bearer <PAT>
  • 下游:两种跑法,同一套白名单
    • --transport stdio(默认):给 Qoder / Claude Desktop 这类拉起子进程的客户端
    • --transport http:起一个 http://127.0.0.1:8790/mcp 的服务地址,客户端填 URL 即可
  • 实现用 MCP Python SDK v2(mcp>=2,<3)
  • 工具列表每次 5 分钟内缓存一次,避免每次 tools/list 都打上游

暴露的工具(13 个)

分组 工具
session 生命周期 create_session get_session list_sessions update_session cancel_session
session 事件 send_session_events list_session_event_summaries list_session_events
只读查询 list_agents list_environments list_vaults
文件元数据 list_files(传 scope_id=<session_id> 查会话产出)get_file

工具名与参数 schema 全部原样透传上游,不做改写;返回的 content / structured_content / is_error 也原样返回。

刻意不在白名单里(tools/list 不返回,tools/call 也拒绝):

  • session 资源四件套 add_session_resource / get_session_resource / list_session_resources / delete_session_resource:文件、GitHub 仓库、memory store 只能在 create_session 的 resources 里一次性挂上,会话中途不能再挂
  • archive_session / delete_session:只能 cancel_session 停掉会话,清理交给控制台或 QCA_EXTRA_TOOLS 追加
  • agent / environment / vault / skill / deployment 的写操作全部隐藏,只留三个 list_*

安装

# 1) 直接跑源码(推荐本地开发)
uvx --from /Users/wbc/Desktop/ascend_adapter/qca-mcp-proxy qca-mcp-proxy --check

# 2) 从 git 安装
uvx --from git+https://github.com/<you>/qca-mcp-proxy qca-mcp-proxy

# 3) 装成常驻命令行
uv tool install /Users/wbc/Desktop/ascend_adapter/qca-mcp-proxy
qca-mcp-proxy --check

--check 会用当前 PAT 连一次上游,打印「上游工具数 / 已暴露 / 被隐藏」后退出,用来确认 PAT 和区域对不对。

以服务地址跑(Streamable HTTP)

cd /Users/wbc/Desktop/ascend_adapter/qca-mcp-proxy
export QCA_PAT=<你的 PAT>
export QCA_REGION=cn

# 起服务(默认监听 127.0.0.1:8790)
.venv/bin/qca-mcp-proxy --transport http
# 或者: uvx --from . qca-mcp-proxy --transport http

启动成功会打印:

[qca-proxy] INFO qca_mcp_proxy.server: serving Streamable HTTP on http://127.0.0.1:8790/mcp
[qca-proxy] INFO qca_mcp_proxy.upstream: connected to https://mcp.qoder.cn/... (cn region)
[qca-proxy] INFO qca_mcp_proxy.server: qca proxy ready: region=cn ...

然后在 agent 里把服务地址填成 http://127.0.0.1:8790/mcp;如果客户端用 mcpServers 配置,写:

{"mcpServers": {"qca": {"url": "http://127.0.0.1:8790/mcp"}}}

相关开关:

参数 默认 说明
--host 127.0.0.1 只给本机用就保持默认;要同网段访问改 0.0.0.0(SDK 只对回环地址做 DNS rebinding 防护,改后请自行加 --auth-token)
--port 8790 监听端口,端口冲突时换一个
--stateless 关 不带 mcp-session-id 的无状态模式。有些 agent 每个请求都新开连接,用它会报 “session not found”,这时加这个参数
--auth-token 空 要求请求带 Authorization: Bearer <token>,也可用 QCA_HTTP_TOKEN。只在本机测可以不加

启动前会先探一次上游:PAT 不对或区域不匹配时直接一行报错退出,不会起一个连不上上游的空服务:

[qca-proxy] cannot reach QCA: MCPError(-32603): Server returned an error response

The cn endpoint (https://mcp.qoder.cn/api/v1/mcp/servers/qca) rejected the request. ...

配置

Qoder / 兼容 mcpServers 的客户端

args 里的 --from 有两种来源,按安装方式二选一。

从 git 安装(推荐,换机器不用改路径):

{
  "mcpServers": {
    "qca": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/xiaochus/qca_mcp_proxy", "qca-mcp-proxy"],
      "env": {
        "QCA_PAT": "<你的 PAT>",
        "QCA_REGION": "cn"
      }
    }
  }
}

从本机源码安装(改代码即时生效):

{
  "mcpServers": {
    "qca": {
      "command": "uvx",
      "args": ["--from", "/Users/wbc/Desktop/ascend_adapter/qca-mcp-proxy", "qca-mcp-proxy"],
      "env": {
        "QCA_PAT": "<你的 PAT>",
        "QCA_REGION": "cn"
      }
    }
  }
}

等价命令行(先在终端验证能不能起):

uvx --from git+https://github.com/xiaochus/qca_mcp_proxy qca-mcp-proxy --check

# 固定到某个 commit / tag,避免每次拉到不一样的代码
uvx --from git+https://github.com/xiaochus/qca_mcp_proxy@v0.1.0 qca-mcp-proxy --check

uvx 会把该仓库缓存到本地 ~/.cache/uv,改了远端代码后需要 --refresh 或清缓存才会更新。

环境变量

变量 必填 默认 说明
QCA_PAT 是 – 个人访问令牌;也接受 QODER_PAT / QCA_TOKEN,带不带 Bearer 前缀都可以
QCA_REGION 否 cn cn → https://mcp.qoder.cn/api/v1/mcp/servers/qca;global → https://mcp.qoder.com/api/v1/mcp/servers/qca
QCA_MCP_URL 否 由 region 决定 直接指定上游 MCP 地址,优先于 region
QCA_EXTRA_TOOLS 否 空 在默认白名单上追加工具(逗号分隔),例如 list_accessible_workspaces
QCA_ALLOWED_TOOLS 否 默认白名单 整体替换默认白名单(逗号分隔)
QCA_TOOLS_TTL 否 300 工具列表缓存秒数
QCA_CONNECT_TIMEOUT 否 30 连接上游超时(秒)
QCA_READ_TIMEOUT 否 300 上游单次读取超时(秒)
QCA_DEBUG 否 关 1 打开 DEBUG 日志(含 SDK 与 HTTP 层)
QCA_HTTP_TOKEN 否 空 仅 --transport http 生效:要求请求带 Authorization: Bearer <值>

常用扩展例子:

# 需要工作区选择能力时
QCA_EXTRA_TOOLS=list_accessible_workspaces

# 只要读,不要写
QCA_ALLOWED_TOOLS=get_session,list_sessions,list_session_event_summaries,list_session_events,list_agents,list_environments,list_vaults,list_files,get_file

典型用法

  1. list_agents / list_environments / list_vaults 拿到 agent_xxx / env_xxx / vault_xxx
  2. create_session 传 agent + environment_id(需要凭证时再传 vault_ids,需要挂载文件/仓库/记忆库时传 resources)
  3. send_session_events 发一条 user.message 事件
  4. list_session_event_summaries 轮询进度(不带载荷,省 token),需要内容时再用 list_session_events 加 types 过滤、limit 调小
  5. 取产物:list_files 传 scope_id=<session_id> 拿到 file_id,再用 get_file 看元数据;下载走 HTTP GET /files/{id}/content(见上文)
  6. 结束:cancel_session(没有归档/删除权限)

行为约定

  • 启动即连上游:生命周期里建立一条长连接,PAT 无效或区域不匹配时启动直接失败,stderr 会给出换区域的提示(日志只走 stderr,stdout 留给协议)。这样也避免了在请求处理任务里创建 MCP 客户端任务组导致的 cancel scope 破坏。
  • 写操作不重试:create_session / send_session_events 等调用失败不再自动重放,避免上游重复执行;失败以 is_error=true 的工具结果返回,模型可自行决定下一步。
  • 未授权工具双重拦截:tools/list 不返回,tools/call 也直接拒绝并给出可调用的工具名。
  • 不暴露 resources / prompts:上游只有 tools,本代理也只声明 tools 能力。

Metadata

Release files for qca-mcp-proxy 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for qca-mcp-proxy 0.1.0
File Size Uploaded Provenance Actions
qca_mcp_proxy-0.1.0.tar.gz 17.3 kB Without provenance Details for qca_mcp_proxy-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for qca-mcp-proxy 0.1.0
File Interpreter ABI Platform Actions
qca_mcp_proxy-0.1.0-py3-none-any.whl Python 3 none any Details for qca_mcp_proxy-0.1.0-py3-none-any.whl

Total release size: 32.1 kB

Release files / qca_mcp_proxy-0.1.0.tar.gz

Download URL qca_mcp_proxy-0.1.0.tar.gz
Size 17.3 kB
Tags Source
SHA-256 checksum
How to use checksums
f2bebb7a9ef696c026ca9d4f7e8775693975df1bef2842cd7808f75f4129a1e5
BLAKE2b-256 checksum
How to use checksums
e39b03d1296d5a67ca42de725856bba2e4fbe5da1ebc39578bf8f4d9f6423133
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / qca_mcp_proxy-0.1.0-py3-none-any.whl

Download URL qca_mcp_proxy-0.1.0-py3-none-any.whl
Size 14.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
450ea0260d6e5b8b1333a01e235505555e96523726310c56ee66d5441ea29993
BLAKE2b-256 checksum
How to use checksums
10709f7910d244662fdf03cc1b845c4cfd1591cb99908a2eb909dea9afe5a959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for qca-mcp-proxy 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page