CommandCodeAI / CommandCodeAI/command-code
MCP tool schemas using $ref/$defs cause 400 on every request with Moonshot/Kimi models
還沒有人認領這個 Issue。
- 主要語言
- 沒有語言資料
- 星號
- 4k
- 分支
- 350
- PR 合併指標
- 30 天內沒有已合併 PR
描述
Summary
When an MCP server exposes a tool whose input schema uses $ref + $defs (valid JSON Schema, and valid per the MCP spec), Command Code passes the schema to the Moonshot/Kimi API in a form it rejects — and because tool definitions accompany every request, every turn of the session fails with a 400, making the CLI unusable with that MCP server attached.
Error
⚠ Error: 400 Invalid request: tools.function.parameters is not a valid moonshot flavored
json schema, details: <At path 'properties.external.$ref': $defs not found for reference:
#/$defs/IdentifySessionExternalParams>
Seen on v0.51.0 and still present after updating to v0.52.1, model moonshotai/Kimi-K2.7-Code-Highspeed.
Repro
- Configure any MCP server that emits a
$ref-based tool schema. In my case: the Solo app's MCP server, whoseidentify_sessiontool declares:
{
"$defs": {
"IdentifySessionExternalParams": {
"properties": {
"agent_id": {"type": "string"},
"metadata": {"additionalProperties": true, "default": {}, "type": "object"},
"name": {"type": "string"}
},
"required": ["name"],
"type": "object"
}
},
"properties": {
"external": {
"$ref": "#/$defs/IdentifySessionExternalParams",
"description": "External actor details for callers that are not Solo-managed processes."
},
"solo_process_id": {"format": "int64", "type": "integer"},
"pid": {"format": "uint32", "minimum": 0, "type": "integer"}
},
"type": "object"
}
- Start
cmdwith a Kimi model and send any message. - Every request 400s with the error above.
Note the schema does include a top-level $defs — the Moonshot error says $defs not found, which suggests the conversion layer strips/loses $defs while leaving the $ref dangling (or Moonshot's "flavored" schema simply doesn't support refs at all).
Expected
Command Code should dereference/inline $refs when converting MCP tool schemas for providers whose "flavored" JSON Schema doesn't support them (Moonshot at minimum). Claude Code and Codex handle the same MCP server fine because the Anthropic/OpenAI APIs accept $ref schemas.
A degraded-but-better alternative: drop the offending tool from the tool list with a warning, instead of letting one incompatible schema hard-fail the entire session.
Workaround
Disable the offending MCP server in ~/.commandcode/mcp.json ("enabled": false).
貢獻指南
這個儲存庫沒有索引到貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從 cmd 進入點開始,追蹤 MCP 工具 schema 在傳送 provider 請求之前是如何轉換的;該 issue 沒有指明任何儲存庫檔案或測試。將 Moonshot 路徑與 Claude Code 和 Codex 路徑進行比較,然後驗證回報的 $ref/$defs schema 不再導致 400,並確認工作階段仍可使用。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- json
- 領域
- api, cli
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 48/100