mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
fix(mcp): block suspicious stdio configs before probe (#46112)
This commit is contained in:
parent
13a1bd0f83
commit
a27d7e68cc
4 changed files with 141 additions and 23 deletions
|
|
@ -4837,15 +4837,15 @@ def migrate_config(interactive: bool = True, quiet: bool = False) -> Dict[str, A
|
|||
raw_mcp_servers = config.get("mcp_servers")
|
||||
if isinstance(raw_mcp_servers, dict):
|
||||
try:
|
||||
from hermes_cli.mcp_security import validate_mcp_server_entry
|
||||
from hermes_cli.mcp_security import validate_mcp_server_entry as _validate_mcp_server_entry
|
||||
except Exception:
|
||||
validate_mcp_server_entry = None
|
||||
if validate_mcp_server_entry:
|
||||
_validate_mcp_server_entry = None
|
||||
if _validate_mcp_server_entry:
|
||||
mcp_touched = False
|
||||
for server_name, entry in raw_mcp_servers.items():
|
||||
if not isinstance(entry, dict):
|
||||
continue
|
||||
issues = validate_mcp_server_entry(server_name, entry)
|
||||
issues = _validate_mcp_server_entry(server_name, entry)
|
||||
if not issues:
|
||||
continue
|
||||
entry["enabled"] = False
|
||||
|
|
|
|||
|
|
@ -221,6 +221,10 @@ def _probe_single_server(
|
|||
Returns list of ``(tool_name, description)`` tuples.
|
||||
Raises on connection failure.
|
||||
"""
|
||||
issues = validate_mcp_server_entry(name, config)
|
||||
if issues:
|
||||
raise ValueError("; ".join(issues))
|
||||
|
||||
from tools.mcp_tool import (
|
||||
_ensure_mcp_loop,
|
||||
_run_on_mcp_loop,
|
||||
|
|
@ -352,6 +356,12 @@ def cmd_mcp_add(args):
|
|||
if explicit_env:
|
||||
server_config["env"] = explicit_env
|
||||
|
||||
issues = validate_mcp_server_entry(name, server_config)
|
||||
if issues:
|
||||
for issue in issues:
|
||||
_warning(issue)
|
||||
_warning(f"Server '{name}' was NOT saved due to suspicious configuration.")
|
||||
return
|
||||
|
||||
# ── Authentication ────────────────────────────────────────────────
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue