Skip to content

fix(acp): load global MCP config in kimi acp server#2490

Open
nankingjing wants to merge 2 commits into
MoonshotAI:mainfrom
nankingjing:fix-acp-load-global-mcp-config
Open

fix(acp): load global MCP config in kimi acp server#2490
nankingjing wants to merge 2 commits into
MoonshotAI:mainfrom
nankingjing:fix-acp-load-global-mcp-config

Conversation

@nankingjing

@nankingjing nankingjing commented Jul 11, 2026

Copy link
Copy Markdown

Summary

kimi acp (the multi-session ACP server) never loads the user's globally-configured MCP servers, so ACP clients (Zed, JetBrains AI Assistant, orchestrators) only ever see the built-in tools — a parity gap with interactive kimi, which does load them. Fixes #2464.

Root cause

Interactive kimi seeds its MCP configs from the global config file (<share>/mcp.json) when no --mcp-config-file is passed (cli/__init__.py):

if not file_configs:
    default_mcp_file = get_global_mcp_config_file()
    if default_mcp_file.exists():
        file_configs.append(default_mcp_file)

The ACP server path (ACPServer.new_session / _setup_session) only ever built its config from the servers the ACP client passed in the request:

mcp_config = acp_mcp_servers_to_mcp_config(mcp_servers or [])
cli_instance = await KimiCLI.create(session, mcp_configs=[mcp_config], ui_mode="acp")

When the client sends no mcp_servers (the common case), acp_mcp_servers_to_mcp_config([]) returns an empty MCPConfig, so no MCP servers are ever connected. The globally-configured servers were never consulted, and the callback-level --mcp-config-file option is skipped once the acp subcommand is invoked.

Fix

Introduce _build_mcp_configs(), which merges the global MCP config (via the same get_global_mcp_config_file() used by interactive mode) with any servers the ACP client supplied, and use it in both new_session and _setup_session. KimiToolset.load_mcp_tools already iterates over a list of configs, so passing multiple MCPConfigs merges their servers; client-provided servers take precedence on name conflicts (registered last).

A malformed/unreadable global config is logged and skipped (_load_global_mcp_config returns None) so a broken file cannot abort ACP session creation.

Tests

Added tests/acp/test_server_mcp_config.py covering:

  • missing global config file -> None
  • malformed global config -> ignored, no raise
  • global servers appear in the assembled configs
  • no global config + no client servers -> no MCP servers

Verification

Verified by reading the interactive vs. ACP code paths, KimiCLI.create / load_agent / KimiToolset.load_mcp_tools signatures and merge behavior, and MCPConfig usage across the codebase. Syntax-checked both files locally with py_compile. Not executed (no test run available in this environment).


Open in Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 1 additional finding.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

kimi acp does not load MCP servers — MCP tools absent in ACP mode while they work in interactive mode (--mcp-config-file is inert under acp)

1 participant