mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-09 14:57:59 -05:00
Co-authored-by: Tejas Goyal <tejas@Tejass-MacBook-Pro.local>
This commit is contained in:
@@ -189,8 +189,17 @@ class MCPStdioServerConfig(BaseModel):
|
||||
|
||||
|
||||
class MCPSHTTPServerConfig(BaseModel):
|
||||
"""Configuration for a MCP server that uses SHTTP.
|
||||
|
||||
Attributes:
|
||||
url: The server URL
|
||||
api_key: Optional API key for authentication
|
||||
timeout: Timeout in seconds for tool calls (default: 60s)
|
||||
"""
|
||||
|
||||
url: str
|
||||
api_key: str | None = None
|
||||
timeout: int | None = 60
|
||||
|
||||
@field_validator('url', mode='before')
|
||||
@classmethod
|
||||
@@ -198,6 +207,17 @@ class MCPSHTTPServerConfig(BaseModel):
|
||||
"""Validate URL format for MCP servers."""
|
||||
return _validate_mcp_url(v)
|
||||
|
||||
@field_validator('timeout')
|
||||
@classmethod
|
||||
def validate_timeout(cls, v: int | None) -> int | None:
|
||||
"""Validate timeout value for MCP tool calls."""
|
||||
if v is not None:
|
||||
if v <= 0:
|
||||
raise ValueError('Timeout must be positive')
|
||||
if v > 3600: # 1 hour max
|
||||
raise ValueError('Timeout cannot exceed 3600 seconds')
|
||||
return v
|
||||
|
||||
|
||||
class MCPConfig(BaseModel):
|
||||
"""Configuration for MCP (Message Control Protocol) settings.
|
||||
|
||||
Reference in New Issue
Block a user