Skip to content

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

Description

@xavier2sy8827-cmyk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions