- Split server/chat.py, server/status.py, server/tasks.py into sub-packages
- Split utils/context_manager.py, utils/conversation_manager.py into mixin packages
- Split modules/file_manager.py, persistent_terminal.py, terminal_ops.py, mcp_client_manager.py into packages
- Split core/main_terminal_parts/context.py into base + mixins
- Split static/src/app/methods/{ui,message,upload,taskPolling,conversation} into sub-modules
- Fix flattened method exports, dynamic import paths, missing cross-module imports
- Add missing permission/network/execution mode constants and _PERMISSION_MODE_LABEL
- Update AGENTS.md, CLAUDE.md and project memories to reflect new structure
42 lines
937 B
Python
42 lines
937 B
Python
"""MCP 客户端管理:工具发现、调用与 OpenAI 工具映射。"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import select
|
|
import shutil
|
|
import subprocess
|
|
import threading
|
|
import time
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, TYPE_CHECKING
|
|
|
|
import httpx
|
|
|
|
from config import MCP_PROTOCOL_VERSION, MCP_DEFAULT_TIMEOUT_SECONDS
|
|
from modules.mcp_server_registry import MCPServerRegistry
|
|
|
|
if TYPE_CHECKING:
|
|
from modules.user_container_manager import ContainerHandle
|
|
|
|
|
|
class MCPToolBinding:
|
|
alias: str
|
|
server_id: str
|
|
server_name: str
|
|
remote_name: str
|
|
transport: str
|
|
timeout_seconds: int
|
|
class MCPClientPoolEntry:
|
|
"""长连接 MCP 客户端池条目。"""
|
|
|
|
server_id: str
|
|
signature: str
|
|
client: Any
|
|
timeout_seconds: int
|
|
created_at: float
|
|
last_used_at: float
|