From ecc4ad0770773fd98bb5e661b591a569683f778e Mon Sep 17 00:00:00 2001 From: Novice Date: Thu, 26 Jun 2025 13:54:18 +0800 Subject: [PATCH] fix: the mcp server disable status --- api/controllers/mcp/mcp.py | 3 +++ api/core/mcp/client/streamable_client.py | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/controllers/mcp/mcp.py b/api/controllers/mcp/mcp.py index 78cd4f66ac..110283c630 100644 --- a/api/controllers/mcp/mcp.py +++ b/api/controllers/mcp/mcp.py @@ -2,6 +2,7 @@ from flask_restful import Resource, reqparse from pydantic import ValidationError from werkzeug.exceptions import NotFound +from controllers.console.app.mcp_server import AppMCPServerStatus from controllers.mcp import api from controllers.web.error import ( AppUnavailableError, @@ -33,6 +34,8 @@ class MCPAppApi(Resource): server = db.session.query(AppMCPServer).filter(AppMCPServer.server_code == server_code).first() if not server: raise NotFound("Server Not Found") + if server.status != AppMCPServerStatus.ACTIVE: + raise NotFound("Server is not active") app = db.session.query(App).filter(App.id == server.app_id).first() if not app: raise NotFound("App Not Found") diff --git a/api/core/mcp/client/streamable_client.py b/api/core/mcp/client/streamable_client.py index 495b56201b..ea8fe15831 100644 --- a/api/core/mcp/client/streamable_client.py +++ b/api/core/mcp/client/streamable_client.py @@ -322,7 +322,7 @@ class StreamableHTTPTransport: jsonrpc_error = JSONRPCError( jsonrpc="2.0", id=request_id, - error=ErrorData(code=32600, message="Session terminated"), + error=ErrorData(code=32600, message="Session terminated by server"), ) session_message = SessionMessage(JSONRPCMessage(jsonrpc_error)) server_to_client_queue.put(session_message)