CommandCodeAI / CommandCodeAI/command-code

MCP tool schemas using $ref/$defs cause 400 on every request with Moonshot/Kimi models

オープン
#566 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
言語のデータがありません
スター
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

  1. Configure any MCP server that emits a $ref-based tool schema. In my case: the Solo app's MCP server, whose identify_session tool 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"
}
  1. Start cmd with a Kimi model and send any message.
  2. 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).

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

cmdエントリポイントから開始し、providerリクエストが送信される前にMCPツールスキーマがどのように変換されるかを追跡します。このissueではリポジトリのファイルやテストは指定されていません。MoonshotのパスをClaude CodeおよびCodexのパスと比較し、報告された$ref/$defsスキーマによって400が発生しなくなり、セッションが引き続き使用可能であることを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
json
領域
api, cli
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。