🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org
Python agentai-societiesartificial-intelligencecommunicative-aicooperative-aideep-learninglarge-language-modelsmulti-agent-systemsnatural-language-processing
enhancement: support type:sse in MCP client argument (#2781)
Xiaotian Jincb3a5009ae4e
diff --git a/camel/utils/mcp_client.py b/camel/utils/mcp_client.pyindex 5f1f6911a..7df3d861c 100644--- a/camel/utils/mcp_client.py+++ b/camel/utils/mcp_client.py@@ -113,7 +113,11 @@ class ServerConfig(BaseModel):# Advanced optionssse_read_timeout: float = 300.0 # 5 minutesterminate_on_close: bool = True- # For HTTP URLs, prefer SSE over StreamableHTTP++ # New transport type parameter+ type: Optional[str] = None++ # Legacy parameter for backward compatibilityprefer_sse: bool = False@model_validator(mode='after')@@ -128,11 +132,43 @@ class ServerConfig(BaseModel):if self.command and self.url:raise ValueError("Cannot specify both 'command' and 'url'")+ # Validate type if provided+ if self.type is not None:+ valid_types = {"stdio", "sse", "streamable_http", "websocket"}+ if self.type not in valid_types:+ raise ValueError(+ f"Invalid type: "+ f"'{self.type}'. "+ f"Valid options: {valid_types}"+ )++ # Issue deprecation warning if prefer_sse is used+ if self.prefer_sse and self.type is None:+ import warnings++ warnings.warn(+ "The 'prefer_sse' parameter is deprecated. "+ "Use 'type=\"sse\"' instead.",+ DeprecationWarning,+ stacklevel=2,+ )+return self@propertydef transport_type(self) -> TransportType:r"""Automatically detect transport type based on configuration."""+ # Use explicit transport type if provided+ if self.type is not None:+ transport_map = {+ "stdio": TransportType.STDIO,+ "sse": TransportType.SSE,+ "streamable_http": TransportType.STREAMABLE_HTTP,+ "websocket": TransportType.WEBSOCKET,+ }+ return transport_map[self.type]++ # If no type is provided, fall back to automatic detectionif self.command:return TransportType.STDIOelif self.url: