66from dataclasses import asdict , dataclass
77from datetime import datetime
88from pathlib import Path
9- from typing import TYPE_CHECKING , Any
109
11- import pydantic
1210from kaos .path import KaosPath
1311from kosong .tooling import Toolset
1412
1513from kimi_cli .agentspec import load_agent_spec
1614from kimi_cli .config import Config
17- from kimi_cli .exception import MCPConfigError
1815from kimi_cli .llm import LLM
1916from kimi_cli .session import Session
2017from kimi_cli .skill import discover_skills , get_claude_skills_dir , get_skills_dir
2522from kimi_cli .utils .logging import logger
2623from kimi_cli .utils .path import list_directory
2724
28- if TYPE_CHECKING :
29- from fastmcp .mcp_config import MCPConfig
30-
3125
3226@dataclass (frozen = True , slots = True , kw_only = True )
3327class BuiltinSystemPromptArgs :
@@ -177,21 +171,14 @@ def add_dynamic_subagent(self, name: str, agent: Agent):
177171 self .dynamic_subagents [name ] = agent
178172
179173
180- async def load_agent (
181- agent_file : Path ,
182- runtime : Runtime ,
183- * ,
184- mcp_configs : list [MCPConfig ] | list [dict [str , Any ]],
185- ) -> Agent :
174+ async def load_agent (agent_file : Path , runtime : Runtime ) -> Agent :
186175 """
187176 Load agent from specification file.
188177
189178 Raises:
190179 FileNotFoundError: When the agent file is not found.
191180 AgentSpecError(KimiCLIException, ValueError): When the agent specification is invalid.
192181 InvalidToolError(KimiCLIException, ValueError): When any tool cannot be loaded.
193- MCPConfigError(KimiCLIException, ValueError): When any MCP configuration is invalid.
194- MCPRuntimeError(KimiCLIException, RuntimeError): When any MCP server cannot be connected.
195182 """
196183 logger .info ("Loading agent: {agent_file}" , agent_file = agent_file )
197184 agent_spec = load_agent_spec (agent_file )
@@ -205,11 +192,7 @@ async def load_agent(
205192 # load subagents before loading tools because Task tool depends on LaborMarket on initialization
206193 for subagent_name , subagent_spec in agent_spec .subagents .items ():
207194 logger .debug ("Loading subagent: {subagent_name}" , subagent_name = subagent_name )
208- subagent = await load_agent (
209- subagent_spec .path ,
210- runtime .copy_for_fixed_subagent (),
211- mcp_configs = [], # Subagents don't need MCP tools, only main agent loads them
212- )
195+ subagent = await load_agent (subagent_spec .path , runtime .copy_for_fixed_subagent ())
213196 runtime .labor_market .add_fixed_subagent (subagent_name , subagent , subagent_spec .description )
214197
215198 toolset = KimiToolset ()
@@ -230,22 +213,6 @@ async def load_agent(
230213 tools = [tool for tool in tools if tool not in agent_spec .exclude_tools ]
231214 toolset .load_tools (tools , tool_deps )
232215
233- if mcp_configs :
234- validated_mcp_configs : list [MCPConfig ] = []
235- if mcp_configs :
236- from fastmcp .mcp_config import MCPConfig
237-
238- for mcp_config in mcp_configs :
239- try :
240- validated_mcp_configs .append (
241- mcp_config
242- if isinstance (mcp_config , MCPConfig )
243- else MCPConfig .model_validate (mcp_config )
244- )
245- except pydantic .ValidationError as e :
246- raise MCPConfigError (f"Invalid MCP config: { e } " ) from e
247- await toolset .load_mcp_tools (validated_mcp_configs , runtime )
248-
249216 return Agent (
250217 name = agent_spec .name ,
251218 system_prompt = system_prompt ,
0 commit comments