chore(deps): 批量升级 15 个依赖,适配 mcp 2.x

源 PR: #3426 #3427 #3428 #3429

剔除 4 项:
- edge-tts 7.3.1->7.2.8 是降级
- powermem >=1.1.7 要求 Python>=3.11
- openai 3.29.0 与 powermem 冲突(powermem 要求 openai<3.0.0)
- ruamel.yaml 0.19.1 与 hyperpyyaml 冲突

mcp 2.x 适配: streamablehttp_client 更名为 streamable_http_client,headers/timeout
改由 http_client 承载,产出从 3 元组变 2 元组,ProgressFnT 移到 mcp.shared.dispatcher
This commit is contained in:
Sakura-RanChen 2026-10-23 15:15:50 +08:00
parent 24fbf7eee2
commit be75e7bd39
2 changed files with 34 additions and 23 deletions

View file

@ -10,12 +10,13 @@ import concurrent.futures
from contextlib import AsyncExitStack
from typing import Optional, List, Dict, Any
import httpx2
from mcp import ClientSession, StdioServerParameters, Implementation
from mcp.client.session import SamplingFnT, ElicitationFnT, ListRootsFnT, LoggingFnT, MessageHandlerFnT
from mcp.client.stdio import stdio_client
from mcp.client.sse import sse_client
from mcp.client.streamable_http import streamablehttp_client
from mcp.shared.session import ProgressFnT
from mcp.client.streamable_http import streamable_http_client
from mcp.shared.dispatcher import ProgressFnT # mcp 2.x:从 mcp.shared.session 移来
from config.logger import setup_logging
from core.utils.util import sanitize_tool_name
@ -203,13 +204,21 @@ class ServerMCPClient:
if transport_type == "streamable-http" or transport_type == "http":
# 使用 Streamable HTTP 传输
http_r, http_w, get_session_id = await stack.enter_async_context(
streamablehttp_client(
# mcp 2.x:headers/timeout 改由 http_client 承载,产出从 3 元组变为 2 元组
http_client = httpx2.AsyncClient(
headers=headers,
timeout=httpx2.Timeout(
self.config.get("timeout", 30),
read=self.config.get("sse_read_timeout", 60 * 5),
),
)
stack.push_async_callback(http_client.aclose)
http_r, http_w = await stack.enter_async_context(
streamable_http_client(
url=self.config["url"],
headers=headers,
timeout=self.config.get("timeout", 30),
sse_read_timeout=self.config.get("sse_read_timeout", 60 * 5),
terminate_on_close=self.config.get("terminate_on_close", True)
http_client=http_client,
terminate_on_close=self.config.get("terminate_on_close", True),
)
)
read_stream, write_stream = http_r, http_w

View file

@ -7,36 +7,38 @@ numpy==1.26.4
websockets==14.2
#--------- 以下是可升级的依赖
pyyml==0.0.2
silero_vad==6.2.1
silero_vad==6.2.3
opuslib_next==1.3.1
pydub==0.25.1
funasr==1.2.7
funasr==1.4.16
# transformers>=5 要求 torch>=2.6,与本项目 torch 2.2.2 冲突(会禁用 PyTorch,fun_local 加载不了模型)
transformers<5
openai==2.8.1
google-generativeai==0.8.5
google-generativeai==0.8.6
edge_tts==7.3.1
httpx==0.28.1
aiohttp==3.13.2
aiohttp==3.14.5
aiohttp_cors==0.8.1
ormsgpack==1.12.0
ormsgpack==1.12.2
ruamel.yaml==0.18.16
loguru==0.7.3
requests==2.32.5
requests==2.34.2
cozepy==0.20.0
mem0ai==1.0.0
mem0ai==2.2.1
powermem>=0.3.1
bs4==0.0.2
modelscope==1.39.1
sherpa_onnx==1.12.29
mcp==1.22.0
cnlunar==0.2.4
modelscope==1.40.2
sherpa_onnx==1.13.8
mcp==2.3.0
cnlunar==0.2.5
PySocks==1.7.1
dashscope==1.25.2
dashscope==1.27.7
baidu-aip==4.16.13
aioconsole==0.8.2
markitdown==0.1.3
markitdown==0.1.8
mcp-proxy==0.12.0
PyJWT==2.10.1
psutil==7.1.3
PyJWT==2.15.1
psutil==7.2.2
portalocker==3.2.0 # 暂留 3.x:4.x 与 qdrant-client<1.20 的 portalocker<4.0 约束冲突 (PR #3360)
Jinja2==3.1.6
vosk==0.3.45