diff --git a/application/agents/tools/mcp_tool.py b/application/agents/tools/mcp_tool.py index b21e1363..201e3d0b 100644 --- a/application/agents/tools/mcp_tool.py +++ b/application/agents/tools/mcp_tool.py @@ -169,6 +169,8 @@ class MCPTool(Tool): transport_type = "http" else: transport_type = self.transport_type + if transport_type == "stdio": + raise ValueError("STDIO transport is disabled") if transport_type == "sse": headers.update({"Accept": "text/event-stream", "Cache-Control": "no-cache"}) return SSETransport(url=self.server_url, headers=headers) @@ -454,6 +456,12 @@ class MCPTool(Tool): def get_config_requirements(self) -> Dict: """Get configuration requirements for the MCP tool.""" + transport_enum = ["auto", "sse", "http"] + transport_help = { + "auto": "Automatically detect best transport", + "sse": "Server-Sent Events (for real-time streaming)", + "http": "HTTP streaming (recommended for production)", + } return { "server_url": { "type": "string", @@ -463,14 +471,11 @@ class MCPTool(Tool): "transport_type": { "type": "string", "description": "Transport type for connection", - "enum": ["auto", "sse", "http", "stdio"], + "enum": transport_enum, "default": "auto", "required": False, "help": { - "auto": "Automatically detect best transport", - "sse": "Server-Sent Events (for real-time streaming)", - "http": "HTTP streaming (recommended for production)", - "stdio": "Standard I/O (for local servers)", + **transport_help, }, }, "auth_type": { diff --git a/application/api/user/tools/mcp.py b/application/api/user/tools/mcp.py index f34115bb..0db2700f 100644 --- a/application/api/user/tools/mcp.py +++ b/application/api/user/tools/mcp.py @@ -43,6 +43,16 @@ class TestMCPServerConfig(Resource): return missing_fields try: config = data["config"] + transport_type = (config.get("transport_type") or "auto").lower() + allowed_transports = {"auto", "sse", "http"} + if transport_type not in allowed_transports: + return make_response( + jsonify({"success": False, "error": "Unsupported transport_type"}), + 400, + ) + config.pop("command", None) + config.pop("args", None) + config["transport_type"] = transport_type auth_credentials = {} auth_type = config.get("auth_type", "none") @@ -115,6 +125,16 @@ class MCPServerSave(Resource): return missing_fields try: config = data["config"] + transport_type = (config.get("transport_type") or "auto").lower() + allowed_transports = {"auto", "sse", "http"} + if transport_type not in allowed_transports: + return make_response( + jsonify({"success": False, "error": "Unsupported transport_type"}), + 400, + ) + config.pop("command", None) + config.pop("args", None) + config["transport_type"] = transport_type auth_credentials = {} auth_type = config.get("auth_type", "none")