FoundationAgents/OpenManus · warning · ValueError
Server URL is required.
Error message
Server URL is required.
What it means
Raised by MCPClient.connect_sse (app/tool/mcp.py:53) when server_url is empty/None. It is a pure input-validation guard executed before any AsyncExitStack or sse_client machinery is set up, so hitting it means no connection attempt was made and no cleanup is needed.
Source
Thrown at app/tool/mcp.py:53
class MCPClients(ToolCollection):
"""
A collection of tools that connects to multiple MCP servers and manages available tools through the Model Context Protocol.
"""
sessions: Dict[str, ClientSession] = {}
exit_stacks: Dict[str, AsyncExitStack] = {}
description: str = "MCP client tools for server interaction"
def __init__(self):
super().__init__() # Initialize with empty tools list
self.name = "mcp" # Keep name for backward compatibility
async def connect_sse(self, server_url: str, server_id: str = "") -> None:
"""Connect to an MCP server using SSE transport."""
if not server_url:
raise ValueError("Server URL is required.")
server_id = server_id or server_url
# Always ensure clean disconnection before new connection
if server_id in self.sessions:
await self.disconnect(server_id)
exit_stack = AsyncExitStack()
self.exit_stacks[server_id] = exit_stack
streams_context = sse_client(url=server_url)
streams = await exit_stack.enter_async_context(streams_context)
session = await exit_stack.enter_async_context(ClientSession(*streams))
self.sessions[server_id] = session
await self._initialize_and_list_tools(server_id)
async def connect_stdio(View on GitHub (pinned to 52a13f2a57)
Solutions
- Set the missing URL in config/env (e.g. export MCP_SSE_URL=http://host:port/sse) and confirm it is non-empty before calling.
- Validate before connecting: `if not server_url: raise/fallback` in your bootstrap code with a clear config-path-naming message.
- If the URL comes from a list of servers, skip/filter empty entries instead of passing them to connect_sse.
Example fix
// before
url = os.environ.get('MCP_SSE_URL', '')
await mcp.connect_sse(url)
// after
url = os.environ.get('MCP_SSE_URL')
if not url:
raise RuntimeError('MCP_SSE_URL is not configured')
await mcp.connect_sse(url) Defensive patterns
Strategy: validation
Validate before calling
url = os.environ.get('MCP_SSE_URL')
if not url or not url.startswith(('http://', 'https://')):
raise RuntimeError(f'MCP SSE URL misconfigured: {url!r}')
await mcp.connect_sse(url, server_id='my-server') Type guard
def is_sse_url(u: str | None) -> bool:
return isinstance(u, str) and u.strip().startswith(('http://', 'https://')) Try / catch
try:
await mcp.connect_sse(url, server_id)
except ValueError as e:
if 'Server URL is required' in str(e):
fix_config_and_reload()
else:
raise Prevention
- Fail fast at startup on empty MCP URL config with a message naming the env var.
- Filter empty entries out of server lists before connecting.
- Add config smoke tests that assert every configured MCP URL is a non-empty http(s) string.
When it happens
Trigger: Calling `await mcp.connect_sse('')` or `await mcp.connect_sse(None)`; commonly the result of reading a server URL from config/env (e.g. MCP_SSE_URL unset) and passing it through without a default or check.
Common situations: Missing environment variable or empty config entry for the MCP server URL in deployment (env var not exported in the service unit/container); templating bugs producing empty strings; tests constructing the client without wiring a URL.
Related errors
- Server URL is required for SSE connection
- Command is required for stdio connection
- Unsupported connection type: {self.connection_type}
- Failed to load MCP server config: {e}
- Server command is required.
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/21f34381be522e3b.
Report an issue: GitHub.