feat(zhipu): passthrough for Zhipu Coding Plan remote MCP servers - #6359
Open
alfadb wants to merge 8 commits into
Open
feat(zhipu): passthrough for Zhipu Coding Plan remote MCP servers#6359alfadb wants to merge 8 commits into
alfadb wants to merge 8 commits into
Conversation
alfadb
force-pushed
the
feature/zhipu-mcp-passthrough
branch
from
August 29, 2026 02:40
3e1e602 to
e39c539
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概述
智谱 GLM Coding Plan 订阅附带三个专属远程 MCP Server(Streamable HTTP,端点
https://open.bigmodel.cn/api/mcp/{slug}/mcp):web_search_prime— 联网搜索(webSearchPrime)zread— 开源仓库检索(search_doc / get_repo_structure / read_file)web_reader— 网页读取(webReader)本 PR 让用户用 sub2api 自己的 API key 透明访问这些 MCP server:平台从 zhipu 账号池调度选号、重写认证头后透传(含 SSE 流式),并对
tools/call按次计费。使用方式
实现
账号级开关(默认关,合并即安全)
accounts.extra.zhipu_mcp_enabled(bool);仅 Coding Plan 模式账号可开启,payg 拒绝(400)透传链路(
/api/mcp/zhipu/{slug}/mcp,POST/DELETE;GET 显式 405)Session 粘性:
Mcp-Session-Id → account_idRedis 粘表(TTL 30min,防 key 注入的 session id 校验);带 session 的请求路由回绑定账号;账号失效自动清粘表回退调度换号重试:上游 429/402 或传输层错误换号(最多 4 次);协议级 4xx/5xx 原样透传(不重试非幂等调用)
计费:仅
tools/call(带 id 的 JSON-RPC Request)按次计费,batch 计数;复用既有SearchCount→search_price_per_1k通道(zhipu 分组该字段语义即 MCP 每千次价格),零 schema 改动;usage 以伪模型名zhipu-mcp-{slug}落库测试
slug ↔ 工具名对照(接入方必读)
上游 MCP 工具命名与路径 slug 风格不统一,勿按 slug 推断工具名,以
tools/list实时返回为准:web_search_primeweb_search_primezreadsearch_doc/read_file/get_repo_structureweb_readerwebReader踩坑案例:对
web_readerslug 按路径推断调用"web_reader"→ 上游-32603 "Tool not found"。网关只透传,不做任何工具名映射。后续修复(含在本 PR)
设计决策:不引入 slug ↔ 工具名映射层
上游命名不统一(
web_reader→webReader)是美观问题而非正确性问题:zread一对多(search_doc/read_file/get_repo_structure)说明 slug(server 标识)与 tool(能力标识)本就是两个概念,"同名化"在概念上不成立。规范 MCP 客户端必经tools/list发现工具、按返回名调用,不会踩坑;网关侧映射层会破坏字节透传语义、造成直连/转发环境间的行为漂移,并随上游工具新增/改名产生持续维护负担,收益不成比例,故明确不做。