Skip to content

Conversation

@xiaoju111a
Copy link
Contributor

Summary

Fix duplicate MCP server initialization when loading agents with subagents.

Closes #518

Problem

When kimi-cli starts, it loads main agent + subagents. Both received the same mcp_configs, causing:

  • Each MCP server initialized twice
  • Duplicate startup logs
  • Resource waste

Solution

Move MCP loading logic from load_agent() to KimiCLI.create():

  • load_agent() no longer handles MCP configs
  • MCP tools loaded once after main agent is created
  • Subagents don't trigger MCP initialization

This aligns with Claude Code's approach: MCP is a shared resource, configured once globally.

Files Changed

  • src/kimi_cli/soul/agent.py - Remove mcp_configs parameter
  • src/kimi_cli/app.py - Add MCP loading after agent creation
  • tests/ and examples/ - Update load_agent() calls

@xiaoju111a xiaoju111a changed the title fix: duplicate MCP server initialization when loading agents with subagents. fix: load MCP tools only for main agent Dec 28, 2025
@xiaoju111a xiaoju111a force-pushed the fix/mcp-duplicate-init branch from 351974b to 1e9454c Compare December 28, 2025 03:35
Move MCP loading from load_agent() to KimiCLI.create() to ensure
MCP servers are initialized only once, regardless of subagent count.

Closes MoonshotAI#518
@xiaoju111a xiaoju111a force-pushed the fix/mcp-duplicate-init branch from 1e9454c to 14b410a Compare December 28, 2025 03:41
@xiaoju111a xiaoju111a closed this Jan 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant