- 新增 MCP client 配置加载,支持 CLI/chat 通过配置文件接入 MCP - 完善 chat 交互命令,支持参数查看、事件查看、checkpoint 列表与加载 - 增加 LLM action 后诊断能力,支持真实 LLM 和本地规则兜底 - 将 chat 人工确认点接入 LangGraph interrupt/checkpointer - 更新 README、流程图、待办文档和打包说明 - 补充相关单元测试
29 lines
987 B
Python
29 lines
987 B
Python
"""根据配置文件构造 MCP runner。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from .mcp_client import McpClientConfig, StdioMcpToolClient, load_mcp_client_config
|
|
from .mcp_runner import McpActionRunner
|
|
|
|
|
|
def build_mcp_runner_from_config(path: str | Path) -> McpActionRunner:
|
|
"""读取 MCP 配置文件,并构造可直接给 Agent 使用的 runner。"""
|
|
config = load_mcp_client_config(path)
|
|
client = build_mcp_client(config)
|
|
return McpActionRunner(client=client, tool_names=config.tool_names or None)
|
|
|
|
|
|
def build_mcp_client(config: McpClientConfig):
|
|
"""根据 transport 类型创建 MCP client。"""
|
|
if config.transport == "stdio":
|
|
return StdioMcpToolClient(
|
|
command=config.command,
|
|
args=config.args,
|
|
env=config.env,
|
|
cwd=config.cwd or None,
|
|
timeout_seconds=config.timeout_seconds,
|
|
)
|
|
raise ValueError(f"不支持的 MCP transport: {config.transport}")
|