MoonshotAI / MoonshotAI/kimi-cli

Kimi Code CLI auto-discovers MCP server after user deleted it, causing unfixable 400 errors

Open
#2,457 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

What version of Kimi Code CLI is running?

0.15.0

Which open platform/subscription were you using?

kimi-code

Which model were you using?

K2.7 Code (kimi-for-coding)

What platform is your computer?

Windows 10 Build 26200.8655 x64

What issue are you seeing?

Kimi Code CLI automatically discovers and connects to a local MCP server (AgentChatBus on 127.0.0.1:39765) even after the user manually deleted it from ~/.kimi-code/mcp.json. This causes a 400 API error on every agent turn because the discovered server's JSON Schema is incompatible with Kimi's strict "Moonshot Flavored JSON Schema" validation.

Error message:
Error: [provider.api_error] 400 tools.function.parameters is not a valid moonshot flavored json schema, details: <At path 'required': required property 'agent_id' is not defined in properties>

The same AgentChatBus MCP server works fine with Claude Code CLI and KILO, confirming the schema issue is minor but Kimi's validation is stricter than other clients.

Worse, since the CLI auto-re-adds the server on every restart, the user has no way to permanently disable it except for the workaround of explicitly setting "enabled": false.

What steps can reproduce the bug?
  1. Install AgentChatBus VS Code extension (v0.1.113), which starts a local MCP server on http://127.0.0.1:39765/mcp
  2. Kimi Code CLI auto-discovers it and adds it to MCP list
  3. User tries to remove it by deleting the "agentchatbus" entry from ~/.kimi-code/mcp.json entirely
  4. User kills all Kimi processes: taskkill /F /IM kimi.exe
  5. User restarts Kimi Code CLI
  6. Observe: agentchatbus is still listed as "connected · 27 tools (http)" despite being deleted from config
  7. Any agent turn triggers the 400 schema error
  8. User tries disabledTools: ["bus_connect", "msg_post", "msg_wait", "thread_create"] — error just moves to another tool
  9. Only workaround: explicitly add back "agentchatbus": { "enabled": false, ... } to override auto-discovery
What is the expected behavior?

Option A (preferred): If a user manually deletes an MCP server from mcp.json, Kimi Code CLI should NOT auto-rediscover and re-add it on restart. Auto-discovery should only apply to never-before-seen servers.

Option B: Provide a global config flag like auto_discover_mcp = false to disable auto-discovery entirely.

Option C: Auto-discovered servers should be added with "enabled": false by default, requiring explicit user opt-in before activation.

Additional information
  • AgentChatBus bundled server path: ~/.vscode/extensions/agentchatbus.agentchatbus-0.1.113/resources/bundled-server/dist/cli/index.js
  • The schema bug in AgentChatBus: multiple tools have fields like "agent_id" and "template_id" in their "required" array but these fields are not defined in "properties"
  • Claude Code CLI connects to the same endpoint (http://127.0.0.1:39765/mcp) without errors because Claude's API is more tolerant of minor schema inconsistencies
  • KILO connects via SSE (http://127.0.0.1:39765/mcp/sse) also without issues
  • Current workaround: explicitly declare "enabled": false in mcp.json to block auto-discovery

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the restart sequence with ~/.kimi-code/mcp.json and the AgentChatBus endpoint at 127.0.0.1:39765. Trace MCP auto-discovery during Kimi Code CLI startup and determine how deleted servers are remembered; done means a manually deleted server stays absent, or auto-discovery can be disabled, without requiring an enabled:false workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.