Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.
Python agent-orchestrationai-agentai-coding-assistantclaude-codecoding-agentcomputer-usedesktop-applocal-firstmcppersonal-jarvisvoice-assistantvoice-coding
fix(routing): resolve MCP capabilities in every supported language
Ruben Lütke9a7841e06d42
diff --git a/jarvis/mcp/adapter.py b/jarvis/mcp/adapter.pyindex 662a51228b..688f6f4399 100644--- a/jarvis/mcp/adapter.py+++ b/jarvis/mcp/adapter.py@@ -8,6 +8,7 @@ Side-effect on construction: each MCPToolAdapter also registers a``Capability`` with the global CapabilityRegistry so that the voice pathknows this MCP tool exists."""+from __future__ import annotationsimport logging@@ -24,22 +25,174 @@ from .registry import MCPRegistrylog = logging.getLogger(__name__)+# Speech-input verb forms per supported language for each detectable English+# verb (matching DATA, not prose — umlauts pre-normalised like every registry+# verb). MCP tool descriptions are English, so verbs extracted from them alone+# could never match a German/Spanish phrasing: ``resolve_intent`` returned None+# for "alle meine Notebooks auflisten", the registry reported "action intent,+# no capability", and the deterministic force-spawn dispatched a heavy mission+# for a plain read-only MCP lookup — before the LLM router ever saw the turn+# (live realtime voice bug 2026-07-14, trace c82aa1a6). Expanding at+# registration time keeps ``resolve_intent`` language-equal (de/en/es) per the+# runtime-output-language contract: no supported language may route worse than+# English.+_VERB_SYNONYMS: dict[str, tuple[str, ...]] = {+ "send": (+ *("sende", "senden", "schicke", "schicken", "verschicke"), # i18n-allow: input vocabulary+ *("envia", "enviar", "manda", "mandar"),+ ),+ "create": (+ *("erstelle", "erstellen", "anlege", "anlegen"), # i18n-allow: input vocabulary+ *("erzeuge", "erzeugen"), # i18n-allow: input vocabulary+ *("crea", "crear"),+ ),+ "delete": (+ *("loesche", "loeschen", "entferne", "entfernen"), # i18n-allow: input vocabulary+ *("borra", "borrar", "elimina", "eliminar"),+ ),+ "update": (+ *("aktualisiere", "aktualisieren"), # i18n-allow: input vocabulary+ *("actualiza", "actualizar"),+ ),+ "list": (+ *("liste", "auflisten", "auflistung"), # i18n-allow: input vocabulary+ *("zeig", "zeige", "zeigt"), # i18n-allow: input vocabulary (show-family)+ *("lista", "listar", "muestra", "mostrar"),+ ),+ "get": (+ *("hole", "holen", "abrufen", "gib"), # i18n-allow: input vocabulary+ *("zeig", "zeige", "zeigt"), # i18n-allow: input vocabulary (show-family)+ *("obten", "obtener", "muestra", "mostrar"),+ ),+ "fetch": (+ *("hole", "holen", "abrufen"), # i18n-allow: input vocabulary+ *("recupera", "recuperar"),+ ),+ "read": (+ *("lies", "lese", "lesen", "vorlesen"), # i18n-allow: input vocabulary+ *("lee",),+ ),+ "write": (+ *("schreibe", "schreiben"), # i18n-allow: input vocabulary+ *("escribe", "escribir"),+ ),+ "search": (+ *("suche", "suchen", "durchsuche"), # i18n-allow: input vocabulary+ *("busca", "buscar"),+ ),+ "query": (+ *("abfrage", "abfragen"), # i18n-allow: input vocabulary+ *("consulta", "consultar"),+ ),+ "insert": (+ *("einfuege", "einfuegen"), # i18n-allow: input vocabulary+ *("inserta", "insertar"),+ ),+ "execute": (+ *("ausfuehren", "fuehre"), # i18n-allow: input vocabulary+ *("ejecuta", "ejecutar"),+ ),+ "run": (+ *("starte", "starten", "ausfuehren"), # i18n-allow: input vocabulary+ *("inicia", "iniciar"),+ ),+ "upload": (+ *("hochlade", "hochladen", "lade"), # i18n-allow: input vocabulary+ *("sube", "subir"),+ ),+ "download": (+ *("herunterlade", "herunterladen"), # i18n-allow: input vocabulary+ *("runterlade", "runterladen", "lade"), # i18n-allow: input vocabulary+ *("descarga", "descargar"),+ ),+ "publish": (+ *("veroeffentliche", "veroeffentlichen"), # i18n-allow: input vocabulary+ *("publica", "publicar"),+ ),+ "schedule": (+ *("plane", "planen", "einplane", "einplanen"), # i18n-allow: input vocabulary+ *("programa", "programar"),+ ),+ "post": (+ *("poste", "posten"), # i18n-allow: input vocabulary+ *("publica", "publicar"),+ ),+ "set": (+ *("setze", "setzen"), # i18n-allow: input vocabulary+ *("configura", "configurar"),+ ),+ "add": (+ *("fuege", "hinzufuege", "hinzufuegen"), # i18n-allow: input vocabulary+ *("agrega", "agregar"),+ ),+ "remove": (+ *("entferne", "entfernen", "loesche", "loeschen"), # i18n-allow: input vocabulary+ *("quita", "quitar"),+ ),+ "edit": (+ *("bearbeite", "bearbeiten"), # i18n-allow: input vocabulary+ *("edita", "editar"),+ ),+ "modify": (+ *("aendere", "aendern"), # i18n-allow: input vocabulary+ *("modifica", "modificar"),+ ),+ "retrieve": (+ *("hole", "holen", "abrufen"), # i18n-allow: input vocabulary+ *("recupera", "recuperar"),+ ),+ "find": (+ *("finde", "finden", "suche", "suchen"), # i18n-allow: input vocabulary+ *("encuentra", "encontrar", "busca", "buscar"),+ ),+}++def _verbs_from_description(description: str) -> tuple[str, ...]:"""Best-effort extraction of action verbs from an MCP tool description.Scans the description for known English imperative verbs that indicate- the tool performs an action. Returns a small tuple; never empty (falls- back to a generic "use" verb so resolve_intent can still match).+ the tool performs an action, then expands every hit with its German and+ Spanish speech-input forms (``_VERB_SYNONYMS``) so ``resolve_intent``+ matches the same request in every supported language, not only English.+ Returns a small de-duplicated tuple; never empty (falls back to a generic+ "use" verb so resolve_intent can still match)."""_KNOWN_VERBS = (- "send", "create", "delete", "update", "list", "get", "fetch",- "read", "write", "search", "query", "insert", "execute", "run",- "upload", "download", "publish", "schedule", "post", "set",- "add", "remove", "edit", "modify", "retrieve", "find",+ "send",+ "create",+ "delete",+ "update",+ "list",+ "get",+ "fetch",+ "read",+ "write",+ "search",+ "query",+ "insert",+ "execute",+ "run",+ "upload",+ "download",+ "publish",+ "schedule",+ "post",+ "set",+ "add",+ "remove",+ "edit",+ "modify",+ "retrieve",+ "find",)desc_lower = description.lower()- found = tuple(v for v in _KNOWN_VERBS if re.search(r"\b" + v + r"\b", desc_lower))- return found if found else ("use",)+ found: list[str] = []+ for verb in _KNOWN_VERBS:+ if re.search(r"\b" + verb + r"\b", desc_lower):+ found.append(verb)+ found.extend(_VERB_SYNONYMS.get(verb, ()))+ return tuple(dict.fromkeys(found)) if found else ("use",)def _objects_from_tool_name(namespaced_name: str) -> tuple[str, ...]:@@ -104,9 +257,7 @@ class MCPToolAdapter:except Exception: # noqa: BLE001log.debug("MCPToolAdapter: capability registration failed for %s", _cap_id)- async def execute(- self, args: dict[str, Any], ctx: ExecutionContext- ) -> ToolResult:+ async def execute(self, args: dict[str, Any], ctx: ExecutionContext) -> ToolResult:"""Call the MCP tool and map the result to a `ToolResult`.The supervisor/orchestrator is responsible for publishing@@ -158,6 +309,7 @@ def _normalize_mcp_result(raw: Any) -> Any:# Registry-Helper# ----------------------------------------------------------------------+async def register_mcp_tools_in_registry(mcp_registry: MCPRegistry,tool_registry: Any,diff --git a/tests/unit/brain/test_routing.py b/tests/unit/brain/test_routing.pyindex a0852babba..aa51a5a28a 100644--- a/tests/unit/brain/test_routing.py+++ b/tests/unit/brain/test_routing.py@@ -625,6 +625,65 @@ def test_open_app_intent_does_not_force_spawn_with_seeded_registry(reg._caps.update(snapshot) # noqa: SLF001+ "utterance",+ [+ # The exact live transcript (realtime voice turn 2026-07-14 09:05,+ # trace c82aa1a6): force-spawned a heavy mission that then FAILED,+ # while the realtime model hallucinated a notebook list.+ "Kannst du mir bitte mal gucken, alle all meine Notebooks auflisten?",+ "Liste bitte alle meine Notebooks auf.",+ "Zeig mir alle meine Notebooks",+ "Can you list all my notebooks?",+ ],+)+def test_mcp_covered_request_does_not_force_spawn(utterance: str) -> None:+ """A request an installed MCP tool covers stays INLINE in every supported+ language — the router/tool model calls the MCP tool directly; a mission+ spawn for a plain read-only lookup is the 2026-07-14 live bug. German+ phrasings used to slip past ``resolve_intent`` because MCP capability+ verbs were extracted from the English tool description only, while the+ generic CLI verb "gucken" tripped ``has_action_intent`` — together the+ exact ``_is_generic_subagent_work`` spawn predicate."""+ from jarvis.core.capabilities import Capability, get_registry+ from jarvis.mcp.adapter import _objects_from_tool_name, _verbs_from_description++ reg = get_registry()+ snapshot = dict(reg._caps) # noqa: SLF001 — test fixture state restore+ reg.register(+ Capability(+ id="cli.gcloud",+ source="cli",+ verbs=("zeig", "list", "guck", "gucke", "gucken"), # i18n-allow: input vocabulary+ objects=("gcp", "gcloud", "projekt", "projekte"), # i18n-allow: input vocabulary+ description="Google Cloud CLI.",+ risk_tier="safe",+ requires_evidence=False,+ )+ )+ reg.register(+ Capability(+ id="mcp.notebooklm-mcp/notebook_list",+ source="mcp",+ verbs=_verbs_from_description(+ "List all notebooks in the user's NotebookLM account."+ ),+ objects=_objects_from_tool_name("notebooklm-mcp/notebook_list"),+ description="List all notebooks.",+ risk_tier="monitor",+ requires_evidence=True,+ )+ )+ try:+ manager, _executor = _manager_with_spawn(force_spawn_mode="strict")+ assert manager._should_force_spawn(utterance) is False, (+ f"MCP-covered request {utterance!r} wrongly force-spawned a worker"+ )+ finally:+ reg._caps.clear() # noqa: SLF001+ reg._caps.update(snapshot) # noqa: SLF001++def test_cli_tools_in_router_tools() -> None:"""``cli-tools`` (the virtual CLI loader) must live in ROUTER_TOOLS.diff --git a/tests/unit/mcp/test_adapter_capability_language.py b/tests/unit/mcp/test_adapter_capability_language.pynew file mode 100644index 0000000000..3b0874c887--- /dev/null+++ b/tests/unit/mcp/test_adapter_capability_language.py@@ -0,0 +1,125 @@+"""MCP capability verbs must cover every supported language (de/en/es).++Live bug 2026-07-14 (realtime voice turn 09:05): the German request+"Kannst du mir bitte mal gucken, alle all meine Notebooks auflisten?"+force-spawned a heavy Jarvis-Agent mission instead of the router/tool model+calling the notebooklm MCP list tool inline. Root cause chain:++ 1. ``_verbs_from_description`` extracted ONLY English verbs from the+ English MCP tool description, so ``resolve_intent`` could never match+ a German (or Spanish) phrasing of the same action.+ 2. A generic German verb from an unrelated CLI capability ("gucken",+ gcloud seed catalog) made ``has_action_intent`` True.+ 3. "action intent + no capability resolves" is exactly the+ ``_is_generic_subagent_work`` predicate, so the deterministic+ force-spawn dispatched a mission 44 ms after the transcript — before+ the LLM router ever saw the turn.++The fix expands each detected English verb with its known German/Spanish+speech-input forms at registration time, so a German phrasing resolves to+the MCP capability and the turn stays inline (the router calls the MCP+tool directly), matching the English behaviour.+"""+from __future__ import annotations++from jarvis.core.capabilities import Capability, CapabilityRegistry+from jarvis.mcp.adapter import _objects_from_tool_name, _verbs_from_description++# The exact final transcript of the live turn (trace c82aa1a6, 09:05:24).+_LIVE_GERMAN_TRANSCRIPT = (+ "Kannst du mir bitte mal gucken, " # i18n-allow: live transcript under test+ "alle all meine Notebooks auflisten?" # i18n-allow: live transcript under test+)++# Representative English MCP tool description (notebooklm-mcp notebook_list).+_LIST_DESCRIPTION = "List all notebooks in the user's NotebookLM account."+++def _notebook_list_cap() -> Capability:+ """Build the capability exactly as MCPToolAdapter registers it."""+ return Capability(+ id="mcp.notebooklm-mcp/notebook_list",+ source="mcp",+ verbs=_verbs_from_description(_LIST_DESCRIPTION),+ objects=_objects_from_tool_name("notebooklm-mcp/notebook_list"),+ description=_LIST_DESCRIPTION,+ risk_tier="monitor",+ requires_evidence=True,+ )+++def _gcloud_cli_cap() -> Capability:+ """Unrelated CLI capability with the generic verbs that made+ ``has_action_intent`` fire on the live turn (seed catalog entry)."""+ return Capability(+ id="cli.gcloud",+ source="cli",+ verbs=("zeig", "list", "check", "guck", "gucke", "gucken"), # i18n-allow: input vocabulary+ objects=("gcp", "google cloud", "gcloud", "projekt"), # i18n-allow: input vocabulary+ description="Google Cloud CLI.",+ risk_tier="safe",+ requires_evidence=False,+ )+++class TestVerbsFromDescriptionMultilingual:+ def test_english_verb_still_extracted(self) -> None:+ verbs = _verbs_from_description(_LIST_DESCRIPTION)+ assert "list" in verbs++ def test_german_forms_included(self) -> None:+ verbs = _verbs_from_description(_LIST_DESCRIPTION)+ assert "auflisten" in verbs # i18n-allow: speech-input vocabulary under test+ assert "liste" in verbs # i18n-allow: speech-input vocabulary under test++ def test_spanish_forms_included(self) -> None:+ verbs = _verbs_from_description(_LIST_DESCRIPTION)+ assert "listar" in verbs++ def test_fallback_stays_use(self) -> None:+ assert _verbs_from_description("Frobnicate the widget.") == ("use",)++ def test_no_duplicates(self) -> None:+ verbs = _verbs_from_description("List, list and list again.")+ assert len(verbs) == len(set(verbs))+++class TestGermanUtteranceResolvesToMcpCapability:+ """Regression guard for the live 2026-07-14 force-spawn."""++ def _registry(self) -> CapabilityRegistry:+ reg = CapabilityRegistry()+ reg.register(_gcloud_cli_cap())+ reg.register(_notebook_list_cap())+ return reg++ def test_live_transcript_resolves_to_mcp(self) -> None:+ reg = self._registry()+ cap = reg.resolve_intent(_LIVE_GERMAN_TRANSCRIPT)+ assert cap is not None+ assert cap.id == "mcp.notebooklm-mcp/notebook_list"++ def test_generic_subagent_predicate_no_longer_fires(self) -> None:+ """``has_action_intent AND resolve is None`` was the spawn trigger."""+ reg = self._registry()+ assert reg.has_action_intent(_LIVE_GERMAN_TRANSCRIPT)+ assert reg.resolve_intent(_LIVE_GERMAN_TRANSCRIPT) is not None++ def test_plain_german_list_phrasing_resolves(self) -> None:+ cap = self._registry().resolve_intent(+ "Liste bitte alle meine Notebooks auf." # i18n-allow: speech-input phrasing under test+ )+ assert cap is not None+ assert cap.source == "mcp"++ def test_german_show_phrasing_resolves(self) -> None:+ cap = self._registry().resolve_intent(+ "Zeig mir alle meine Notebooks" # i18n-allow: speech-input phrasing under test+ )+ assert cap is not None+ assert cap.source == "mcp"++ def test_english_resolution_unchanged(self) -> None:+ cap = self._registry().resolve_intent("Can you list all my notebooks?")+ assert cap is not None+ assert cap.id == "mcp.notebooklm-mcp/notebook_list"