fix(acp): load global MCP config in kimi acp server#2490
Open
nankingjing wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 interactivekimi, which does load them. Fixes #2464.Root cause
Interactive
kimiseeds its MCP configs from the global config file (<share>/mcp.json) when no--mcp-config-fileis passed (cli/__init__.py):The ACP server path (
ACPServer.new_session/_setup_session) only ever built its config from the servers the ACP client passed in the request:When the client sends no
mcp_servers(the common case),acp_mcp_servers_to_mcp_config([])returns an emptyMCPConfig, so no MCP servers are ever connected. The globally-configured servers were never consulted, and the callback-level--mcp-config-fileoption is skipped once theacpsubcommand is invoked.Fix
Introduce
_build_mcp_configs(), which merges the global MCP config (via the sameget_global_mcp_config_file()used by interactive mode) with any servers the ACP client supplied, and use it in bothnew_sessionand_setup_session.KimiToolset.load_mcp_toolsalready iterates over a list of configs, so passing multipleMCPConfigs 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_configreturnsNone) so a broken file cannot abort ACP session creation.Tests
Added
tests/acp/test_server_mcp_config.pycovering:NoneVerification
Verified by reading the interactive vs. ACP code paths,
KimiCLI.create/load_agent/KimiToolset.load_mcp_toolssignatures and merge behavior, andMCPConfigusage across the codebase. Syntax-checked both files locally withpy_compile. Not executed (no test run available in this environment).