The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(mcp): isolate unsupported inferred app labels
brooklyn!d5b3cad7b98b
diff --git a/hermes_cli/web_routers/mcp.py b/hermes_cli/web_routers/mcp.pyindex f07fe3b178c..f15c27ffc69 100644--- a/hermes_cli/web_routers/mcp.py+++ b/hermes_cli/web_routers/mcp.py@@ -413,15 +413,22 @@ async def list_mcp_catalog(profile: Optional[str] = None, detect_apps: bool = Faimport systry:- from hermes_cli.mcp_app_detection import discover_catalog_apps+ from hermes_cli.mcp_app_detection import discover_catalog_apps, validate_applications- # Discovery is read-only and backend-local. Keep filesystem work off the- # event loop and OUTSIDE the profile/skills lock used for config reads.- detected = await asyncio.to_thread(discover_catalog_apps, {- entry["name"]: (entry["suggest"] or {}).get("applications") or [+ applications = {}+ for entry in entries:+ labels = (entry["suggest"] or {}).get("applications") or [entry["name"].replace("-", " ").replace("_", " ")- ] for entry in entries- })+ ]+ try:+ applications[entry["name"]] = validate_applications(labels)+ except ValueError:+ # Catalog identifiers allow more than app labels; one unusable+ # inference must not suppress valid observations for other entries.+ applications[entry["name"]] = []++ # Keep backend-local filesystem work off the event loop and profile lock.+ detected = await asyncio.to_thread(discover_catalog_apps, applications)except Exception:_log.warning("Backend application discovery unavailable")detected = {"matches": {}, "discovery": {diff --git a/tests/hermes_cli/test_mcp_catalog_discovery.py b/tests/hermes_cli/test_mcp_catalog_discovery.pyindex b34e3e08fd8..dc790e09091 100644--- a/tests/hermes_cli/test_mcp_catalog_discovery.py+++ b/tests/hermes_cli/test_mcp_catalog_discovery.py@@ -114,6 +114,17 @@ def test_catalog_detection_is_opt_in_and_preserves_profile_state(catalog_client,added = next(entry for entry in fresh["entries"] if entry["name"] == "fixture-paint")assert added["suggest"] is Noneassert added["detected_apps"] == ["fixture paint"]+ unusual_names = ("_fixture-paint", "fixture-paint-", "x" * 81)+ for name in unusual_names:+ directory = tmp_path / "catalog" / name+ directory.mkdir()+ (directory / "manifest.yaml").write_text(yaml.safe_dump({+ "manifest_version": 1, "name": name, "description": "Valid catalog name, unusable inferred app label",+ "transport": {"type": "stdio", "command": "must-not-run"},+ }), encoding="utf-8")+ mixed = {entry["name"]: entry for entry in client.get("/api/mcp/catalog?detect_apps=true").json()["entries"]}+ assert mixed["fixture-paint"]["detected_apps"] == ["fixture paint"]+ assert all(mixed[name]["detected_apps"] == [] for name in unusual_names)manifest.unlink()assert all(entry["name"] != "fixture-paint" for entry in client.get("/api/mcp/catalog?detect_apps=true").json()["entries"])assert client.get("/api/mcp/catalog", params={"profile": "missing", "detect_apps": True}).status_code == 404