fix(mcp): report runtime_scope on /api/notes/sources and surface it in the Notes drawer

Review follow-up on #7720 (Greptile P2): the external Notes drawer reads the
same profile-bound MCP inventory as the MCP panel but dropped the
``runtime_scope`` label, so a profile whose runtime scope could not be
confirmed rendered its note sources as inactive/configured with no
explanation. ``/api/notes/sources`` now returns ``runtime_scope`` and the
drawer shows the existing ``mcp_runtime_scope_unavailable`` notice (same key,
no new locale strings) when it is ``unavailable``.

Tests: the skewed-routing unit test now also asserts the notes response
carries ``runtime_scope: "unavailable"`` with its sources inactive.
docs/troubleshooting.md mentions the drawer next to the panel.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
tancouandClaude Fable 5.1 committed 2026-09-24 09:53:02 +02:00
1 parent 90b814f673
commit dbf0179c53
4 files changed
+25 -5

No files matched your search

+15 -1
View File
@@ -423,9 +423,17 @@ def test_adopted_connection_serves_status_inventory_and_reload(monkeypatch, tmp_
def test_skewed_routing_hides_runtime_and_refuses_reload(monkeypatch, tmp_path):
from api.routes import _handle_mcp_servers_list, _handle_mcp_tools_list
from api.routes import (
_handle_mcp_servers_list,
_handle_mcp_tools_list,
_handle_notes_sources_list,
)
agent = _install(monkeypatch, tmp_path, pin_supported=False)
_configure(agent, "profile-write", {
"atlassian": {"command": "fake", "fake_tools": WRITE},
"joplin": {"command": "fake", "fake_tools": []}, # a notes-drawer source
})
agent.connect("atlassian", READ, scope=None)
monkeypatch.setenv("HERMES_HOME", str(agent.base / "profiles" / "profile-write")) # turn mirror
@@ -434,6 +442,12 @@ def test_skewed_routing_hides_runtime_and_refuses_reload(monkeypatch, tmp_path):
assert servers["servers"][0]["status"] == "configured"
assert servers["servers"][0]["tool_count"] is None
assert _call("profile-write", _handle_mcp_tools_list)["total"] == 0
# The notes drawer reads the same inventory and must be told the runtime is withheld.
monkeypatch.setenv("HERMES_WEBUI_EXTERNAL_NOTES_SOURCES", "1")
notes = _call("profile-write", _handle_notes_sources_list)
assert notes["runtime_scope"] == "unavailable"
assert [s["name"] for s in notes["sources"]] == ["joplin"]
assert notes["sources"][0]["active"] is False
with pytest.raises(RuntimeError, match="could not be confirmed"):
_reload("profile-write")
assert not [c for c in agent.calls if c[0] in ("discover", "shutdown")]