feat: 重构 MCP 配置管理,移除旧配置文件,更新为使用全局配置
This commit is contained in:
@@ -5,7 +5,7 @@ from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from time import perf_counter
|
||||
from typing import Any, Dict, List, Optional
|
||||
from typing import Any, Dict, List, Optional, Sequence
|
||||
|
||||
import asyncio
|
||||
import random
|
||||
@@ -133,14 +133,14 @@ class MaisakaChatLoopService:
|
||||
|
||||
self._prompts_loaded = True
|
||||
|
||||
def set_extra_tools(self, tools: List[ToolDefinitionInput]) -> None:
|
||||
def set_extra_tools(self, tools: Sequence[ToolDefinitionInput]) -> None:
|
||||
"""设置额外工具定义。
|
||||
|
||||
Args:
|
||||
tools: 兼容旧接口的额外工具定义列表。
|
||||
"""
|
||||
|
||||
self._extra_tools = normalize_tool_options(tools) or []
|
||||
self._extra_tools = normalize_tool_options(list(tools)) or []
|
||||
|
||||
def set_tool_registry(self, tool_registry: ToolRegistry | None) -> None:
|
||||
"""设置统一工具注册表。
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
"""Maisaka 非 CLI 运行时。"""
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Literal, Optional
|
||||
|
||||
import asyncio
|
||||
@@ -91,7 +90,7 @@ class MaisakaHeartFlowChatting:
|
||||
self._ensure_background_tasks_running()
|
||||
return
|
||||
|
||||
if global_config.maisaka.enable_mcp:
|
||||
if global_config.mcp.enable:
|
||||
await self._init_mcp()
|
||||
|
||||
self._running = True
|
||||
@@ -386,8 +385,7 @@ class MaisakaHeartFlowChatting:
|
||||
|
||||
async def _init_mcp(self) -> None:
|
||||
"""初始化 MCP 工具并注册到统一工具层。"""
|
||||
config_path = Path(__file__).resolve().parents[2] / "config" / "mcp_config.json"
|
||||
self._mcp_manager = await MCPManager.from_config(str(config_path))
|
||||
self._mcp_manager = await MCPManager.from_app_config(global_config.mcp)
|
||||
if self._mcp_manager is None:
|
||||
logger.info(f"{self.log_prefix} MCP 管理器不可用")
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user