mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-29 06:31:32 +00:00
fix(mcp): raise ImportError instead of NameError when stdio SDK missing (#31450)
When the 'mcp' Python SDK isn't installed, _run_stdio leaked a bare 'NameError: name StdioServerParameters is not defined' because the top-level 'from mcp import ...' fails inside try/except ImportError, leaving the names unbound at module scope. Mirror the _MCP_HTTP_AVAILABLE gate that _run_http already had: raise a clear ImportError with install instructions instead. Fixes #30904
This commit is contained in:
parent
6cafcf9c77
commit
5acaeba2bb
2 changed files with 30 additions and 0 deletions
|
|
@ -1255,6 +1255,15 @@ class MCPServerTask:
|
|||
|
||||
async def _run_stdio(self, config: dict):
|
||||
"""Run the server using stdio transport."""
|
||||
if not _MCP_AVAILABLE:
|
||||
raise ImportError(
|
||||
f"MCP server '{self.name}' requires the 'mcp' Python SDK, but "
|
||||
"it is not installed. Install with:\n"
|
||||
" pip install 'hermes-agent[mcp]'\n"
|
||||
"or (full install):\n"
|
||||
" pip install 'hermes-agent[all]'"
|
||||
)
|
||||
|
||||
command = config.get("command")
|
||||
args = config.get("args", [])
|
||||
user_env = config.get("env")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue