From 331f9a9cfb3ad064e04364cc9f7f34c9105529a8 Mon Sep 17 00:00:00 2001 From: zxstty Date: Wed, 10 Sep 2025 20:58:55 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=E5=AE=89=E8=A3=85&=E6=9C=AA=E5=AE=89=E8=A3=85=E7=9A=84mcp?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/services/mcp_service.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/apps/services/mcp_service.py b/apps/services/mcp_service.py index 0b72e074..f6fec0eb 100644 --- a/apps/services/mcp_service.py +++ b/apps/services/mcp_service.py @@ -97,12 +97,15 @@ class MCPServiceManager: filters["activated"] = {"$in": [user_sub]} else: filters["activated"] = {"$nin": [user_sub]} - if not is_install: - user_info = await UserManager.get_userinfo_by_user_sub(user_sub) - if not user_info.is_admin: - filters["status"] = MCPInstallStatus.READY.value - else: + user_info = await UserManager.get_userinfo_by_user_sub(user_sub) + if not user_info.is_admin: filters["status"] = MCPInstallStatus.READY.value + else: + if is_install is not None: + if is_install: + filters["status"] = MCPInstallStatus.READY.value + else: + filters["status"] = {"$ne": MCPInstallStatus.READY.value} mcpservice_pools = await MCPServiceManager._search_mcpservice(filters, page) return [ MCPServiceCardItem( -- Gitee From b4f37ca9cf203f9694e8833f979cbdef4d1c2192 Mon Sep 17 00:00:00 2001 From: zxstty Date: Wed, 10 Sep 2025 21:13:03 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E7=9A=84=E6=97=B6?= =?UTF-8?q?=E5=80=99stdio=E6=9B=B4=E6=96=B0env=EF=BC=8Csse=E6=9B=B4?= =?UTF-8?q?=E6=96=B0headers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/scheduler/pool/loader/mcp.py | 5 ++++- apps/schemas/mcp.py | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/scheduler/pool/loader/mcp.py b/apps/scheduler/pool/loader/mcp.py index 79e7bc38..bb4cb8a1 100644 --- a/apps/scheduler/pool/loader/mcp.py +++ b/apps/scheduler/pool/loader/mcp.py @@ -430,7 +430,10 @@ class MCPLoader(metaclass=SingletonMeta): symlinks=True, ) if mcp_env is not None: - mcp_config.config.env.update(mcp_env) + if mcp_config.type == MCPType.STDIO: + mcp_config.config.env.update(mcp_env) + else: + mcp_config.config.headers.update(mcp_env) if mcp_config.type == MCPType.STDIO: index = None for i in range(len(mcp_config.config.args)): diff --git a/apps/schemas/mcp.py b/apps/schemas/mcp.py index f740713a..23c89aa3 100644 --- a/apps/schemas/mcp.py +++ b/apps/schemas/mcp.py @@ -44,7 +44,7 @@ class MCPBasicConfig(BaseModel): auto_install: bool = Field(description="是否自动安装MCP服务器", default=True) timeout: int = Field(description="MCP 服务器超时时间(秒)", default=60, alias="timeout") description: str = Field(description="MCP 服务器自然语言描述", default="") - headers: dict[str, str] = Field(description="MCP 服务器请求头", default={}, alias="headers") + headers: dict[str, str] = Field(description="MCP 服务器请求头", default={}) class MCPServerStdioConfig(MCPBasicConfig): -- Gitee From c9cda0db9a2f5b677894528118b7310f1c4779e0 Mon Sep 17 00:00:00 2001 From: zxstty Date: Wed, 10 Sep 2025 21:17:02 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=B0=86env=E7=A7=BB=E5=88=B0stdio?= =?UTF-8?q?=E7=9A=84config=EF=BC=8Cheaders=E7=A7=BB=E5=88=B0sse=E7=9A=84co?= =?UTF-8?q?nfig?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/scheduler/pool/mcp/client.py | 1 - apps/schemas/mcp.py | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/scheduler/pool/mcp/client.py b/apps/scheduler/pool/mcp/client.py index fb3c2da0..b6726905 100644 --- a/apps/scheduler/pool/mcp/client.py +++ b/apps/scheduler/pool/mcp/client.py @@ -55,7 +55,6 @@ class MCPClient: """ # 创建Client if isinstance(config, MCPServerSSEConfig): - env = config.env or {} headers = config.headers or {} client = sse_client( url=config.url, diff --git a/apps/schemas/mcp.py b/apps/schemas/mcp.py index 23c89aa3..718726e1 100644 --- a/apps/schemas/mcp.py +++ b/apps/schemas/mcp.py @@ -38,25 +38,24 @@ class MCPType(str, Enum): class MCPBasicConfig(BaseModel): """MCP 基本配置""" - env: dict[str, Any] = Field(description="MCP 服务器环境变量", default={}) auto_approve: list[str] = Field(description="自动批准的MCP工具ID列表", default=[], alias="autoApprove") disabled: bool = Field(description="MCP 服务器是否禁用", default=False) auto_install: bool = Field(description="是否自动安装MCP服务器", default=True) timeout: int = Field(description="MCP 服务器超时时间(秒)", default=60, alias="timeout") description: str = Field(description="MCP 服务器自然语言描述", default="") - headers: dict[str, str] = Field(description="MCP 服务器请求头", default={}) class MCPServerStdioConfig(MCPBasicConfig): """MCP 服务器配置""" + env: dict[str, Any] = Field(description="MCP 服务器环境变量", default={}) command: str = Field(description="MCP 服务器命令") args: list[str] = Field(description="MCP 服务器命令参数") class MCPServerSSEConfig(MCPBasicConfig): """MCP 服务器配置""" - + headers: dict[str, str] = Field(description="MCP 服务器请求头", default={}) url: str = Field(description="MCP 服务器地址", default="http://example.com/sse", pattern=r"^https?://.*$") -- Gitee From 1491e5aec3e0cfb559c000ebc1a2f8d133bf8a87 Mon Sep 17 00:00:00 2001 From: zxstty Date: Thu, 11 Sep 2025 10:28:06 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=AE=8C=E5=96=84Agent=20app=E7=9A=84?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=92=8C=E5=88=9B=E5=BB=BA=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/services/appcenter.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/apps/services/appcenter.py b/apps/services/appcenter.py index 15411623..0a72e465 100644 --- a/apps/services/appcenter.py +++ b/apps/services/appcenter.py @@ -482,12 +482,9 @@ class AppCenterManager: # 在预期的条件下,如果在 data 或 app_data 中找不到 mcp_service,则默认回退为空列表。 metadata.mcp_service = [] # 处理llm_id字段 - if data is not None and hasattr(data, "llm") and data.llm: + if data is not None and hasattr(data, "llm"): # 创建应用场景,验证传入的 llm_id 状态 (create_app) metadata.llm_id = data.llm if data.llm else "empty" - elif data is not None and hasattr(data, "llm_id"): - # 更新应用场景,使用 data 中的 llm_id (update_app) - metadata.llm_id = data.llm if data.llm else "empty" elif app_data is not None and hasattr(app_data, "llm_id"): # 更新应用发布状态场景,使用 app_data 中的 llm_id (update_app_publish_status) metadata.llm_id = app_data.llm_id if app_data.llm_id else "empty" -- Gitee From 5394380276fe707f11fe6dbe2f2f2babe392a1d0 Mon Sep 17 00:00:00 2001 From: zxstty Date: Thu, 11 Sep 2025 14:50:43 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=80=9D=E8=80=83?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=E4=B8=8B=E5=A4=A7=E6=A8=A1=E5=9E=8B=E7=9A=84?= =?UTF-8?q?=E6=8E=A8=E7=90=86=E9=80=BB=E8=BE=91=EF=BC=8C=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E5=88=A4=E6=96=ADreasoning=5Fcontent=E4=B8=BAnone=E8=A1=A8?= =?UTF-8?q?=E7=A4=BA=E5=BD=93=E5=89=8D=E6=8E=A8=E7=90=86=E7=BB=93=E6=9D=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/llm/reasoning.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/llm/reasoning.py b/apps/llm/reasoning.py index 58c3fd71..79768783 100644 --- a/apps/llm/reasoning.py +++ b/apps/llm/reasoning.py @@ -61,15 +61,16 @@ class ReasoningContent: return reason, text if self.reasoning_type == "args": - if hasattr(chunk.choices[0].delta, "reasoning_content"): + if hasattr( + chunk.choices[0].delta, "reasoning_content") and chunk.choices[0].delta.reasoning_content is not None: # type: ignore[attr-defined] + # 仍在推理中,继续添加推理内容 reason = chunk.choices[0].delta.reasoning_content or "" # type: ignore[attr-defined] else: # 推理结束,设置标志并添加结束标签 self.is_reasoning = False reason = "" # 如果当前内容不是推理内容标签,将其作为文本返回 - if content and not content.startswith(""): - text = content + text = content.lstrip("") elif self.reasoning_type == "tokens": for token in REASONING_END_TOKEN: if token == content: -- Gitee