gabriel / musehub public
test_mcp_docs.py python
443 lines 23.5 KB Hotspot
Raw
sha256:0a2400b8017d871bff9916bfa6d3898b74b0dcce7f8e4d6e842365133f21090a fix(coord): a task claim is one conditional UPDATE — exactl… Opus 5.5 minor ⚠ breaking 1 day ago
1 """DOC_MCD — /mcp/docs contract (musehub#261, QA contract v2).
2
3 Every claim on the page was checked on 2026-11-09 against musehub ``dev`` 259e6968 (the real ``/mcp`` router, dispatcher,
4 scope policy and registry) and Muse 0.2.1rc20. The tool groups, counts, auth / scope / hint matrix and every card come from
5 the live registry (``ui_docs._mcp_catalogue()`` + ``MCP_TOOLS``); these tests re-derive each from the gates the server
6 enforces and from ``tools/list``, offline and database-free: the HTTP transport runs in-process on a bare FastAPI app with
7 the database dependencies stubbed, and the page is rendered by the real app. Known product defects stay documented as
8 contract plus warning (#241 defect-preservation rule): each is pinned by a strict xfail that flips when its ticket is fixed.
9
10 DOC_MCD_01 (commands parse) is ``TestPageClaims::test_documented_commands_parse``; _02 (anchors) is
11 ``test_in_page_and_docs_links_resolve``; _03 (URL scheme) is ``test_served_over_https_has_no_http_urls`` (musehub#276,
12 fixed); _04 (every registry tool once, with the group and auth the server enforces) is ``TestRegistry``;
13 _05 is ``TestMachineTwin`` (docs.json equals tools/list); _06 is ``TestQuickStart``; _07 is ``TestKnownDefects``.
14 """
15
16 from __future__ import annotations
17
18 import argparse
19 import html as html_lib
20 import re
21 import time
22 from collections.abc import Iterator
23 from pathlib import Path
24 from typing import Any
25
26 import pytest
27 from fastapi import FastAPI
28 from fastapi.testclient import TestClient
29
30 from tests.docs_contract import cli_check as cc
31 from tests.docs_contract import registry_check as rc
32 from tests.docs_contract import scheme_check as sc
33 from tests.docs_contract.pages import BRIDGE_GATEWAY_PEER, render_behind_proxy
34 from tests.docs_contract.test_doc_inf_scheme import trusted_proxies # noqa: F401 - fixture reused
35
36 pytestmark = pytest.mark.no_db
37
38 PAGE = "/mcp/docs"
39 HUB_ISSUES = "https://staging.musehub.ai/gabriel/musehub/issues/"
40 _REPO = Path(__file__).resolve().parents[2]
41 _TEMPLATE = _REPO / "musehub" / "templates" / "musehub" / "pages" / "mcp_docs.html"
42 _KNOWN = {"289", "300"}
43 XFAIL = dict(strict=True, raises=AssertionError)
44
45 INIT = {
46 "jsonrpc": "2.0",
47 "id": 1,
48 "method": "initialize",
49 "params": {
50 "protocolVersion": "2025-11-25",
51 "capabilities": {"elicitation": {"form": {}, "url": {}}},
52 "clientInfo": {"name": "doc-mcd", "version": "1"},
53 },
54 }
55
56
57 # ── Fixtures ────────────────────────────────────────────────────────────────
58
59
60 @pytest.fixture(scope="module")
61 def page() -> str:
62 from musehub.main import app
63
64 r = TestClient(app).get(PAGE)
65 assert r.status_code == 200 and r.headers["content-type"].startswith("text/html")
66 return r.text
67
68
69 @pytest.fixture(scope="module")
70 def html(page: str) -> str:
71 """The raw markup with only quote entities decoded: attribute values keep their ``>`` so tags stay parseable."""
72 return page.replace("'", "'").replace(""", '"').replace(""", '"')
73
74
75 @pytest.fixture(scope="module")
76 def text(html: str) -> str:
77 return " ".join(html_lib.unescape(re.sub(r"<[^>]+>", "", html)).split())
78
79
80 @pytest.fixture(scope="module")
81 def client() -> Iterator[TestClient]:
82 from musehub.api.routes import mcp as route
83 from musehub.auth.request_signing import optional_signed_request
84 from musehub.rate_limits import limiter
85
86 app = FastAPI()
87 app.state.limiter = limiter
88 app.include_router(route.router)
89 app.dependency_overrides[optional_signed_request] = lambda: None # anonymous caller
90 with TestClient(app) as c:
91 yield c
92
93
94 @pytest.fixture(scope="module")
95 def sid(client: TestClient) -> str:
96 r = client.post("/mcp", json=INIT)
97 assert r.status_code == 200
98 return r.headers["Mcp-Session-Id"]
99
100
101 @pytest.fixture(scope="module")
102 def initialize(client: TestClient) -> dict[str, Any]:
103 return client.post("/mcp", json=INIT).json()["result"]
104
105
106 @pytest.fixture(scope="module")
107 def docs_json(client: TestClient) -> tuple[dict[str, Any], Any]:
108 r = client.get("/mcp/docs.json")
109 assert r.status_code == 200
110 return r.json(), r
111
112
113 def _rpc(client: TestClient, sid: str, method: str, params: dict[str, Any] | None = None) -> Any:
114 body = {"jsonrpc": "2.0", "id": 7, "method": method, **({"params": params} if params else {})}
115 return client.post("/mcp", json=body, headers={"Mcp-Session-Id": sid})
116
117
118 @pytest.fixture(scope="module")
119 def tools_list(client: TestClient, sid: str) -> list[dict[str, Any]]:
120 return _rpc(client, sid, "tools/list").json()["result"]["tools"]
121
122
123 def _section(html: str, anchor: str) -> str:
124 return html.split(f'id="{anchor}"', 1)[1].split("</section>", 1)[0]
125
126
127 def _cards(html: str) -> dict[str, dict[str, str]]:
128 out: dict[str, dict[str, str]] = {}
129 for m in re.finditer(r'<div class="tool-card tool-card--([a-z-]+)" id="tool-([a-z_]+)"[^>]*data-auth="([a-z]+)"', html):
130 assert m.group(2) not in out, f"{m.group(2)} rendered twice"
131 out[m.group(2)] = {"group": m.group(1), "auth": m.group(3)}
132 return out
133
134
135 def _matrix_rows(html: str) -> list[dict[str, str]]:
136 table = html.split('id="tool-matrix-table"', 1)[1].split("</table>", 1)[0]
137 return [dict(re.findall(r'data-([a-z-]+)="([^"]*)"', m)) for m in re.findall(r"<tr data-tool=[^>]*>", table)]
138
139
140 # ── DOC_MCD_04: every registry tool once, with the group and auth the server enforces ─────────────────────
141
142
143 class TestRegistry:
144 def test_hero_counts_are_the_registry_counts(self, html: str) -> None:
145 from musehub.mcp.prompts import PROMPT_CATALOGUE
146 from musehub.mcp.resources import RESOURCE_TEMPLATES, STATIC_RESOURCES
147 from musehub.mcp.tools import MCP_TOOLS
148
149 nums = re.findall(r'<span class="stat-pill__num">(\d+)</span>\s*<span class="stat-pill__label">([A-Za-z]+)</span>', html)
150 assert dict((label, int(n)) for n, label in nums) == {
151 "Tools": len(MCP_TOOLS),
152 "Resources": len(STATIC_RESOURCES),
153 "Templates": len(RESOURCE_TEMPLATES),
154 "Prompts": len(PROMPT_CATALOGUE),
155 }
156 assert len(MCP_TOOLS) == len({t["name"] for t in MCP_TOOLS})
157
158 def test_every_registry_tool_has_exactly_one_card_in_the_group_its_registry_list_says(self, html: str) -> None:
159 from musehub.api.routes.musehub.ui_docs import _mcp_catalogue
160 from musehub.mcp.tools import MCP_TOOLS
161
162 cards = _cards(html)
163 assert set(cards) == {t["name"] for t in MCP_TOOLS}
164 for g in _mcp_catalogue()["groups"]: # type: ignore[attr-defined]
165 for t in g.tools:
166 assert cards[t.name]["group"] == g.key, t.name
167 # each card sits inside its own group's section
168 for g in _mcp_catalogue()["groups"]: # type: ignore[attr-defined]
169 body = _section(html, f"tools-{g.key}")
170 assert {n for n in re.findall(r'id="tool-([a-z_]+)"', body)} == {t.name for t in g.tools}, g.key
171
172 def test_card_auth_equals_the_gate_the_dispatcher_enforces(self, html: str) -> None:
173 from musehub.mcp.tools import MUSEHUB_WRITE_TOOL_NAMES
174
175 for name, c in _cards(html).items():
176 assert (c["auth"] == "msign") == (name in MUSEHUB_WRITE_TOOL_NAMES), name
177 assert sum(c["auth"] == "msign" for c in _cards(html).values()) == len(MUSEHUB_WRITE_TOOL_NAMES) == 75
178
179 def test_matrix_rows_equal_cards_scope_policy_and_tools_list_hints(self, html: str, tools_list: list[dict[str, Any]]) -> None:
180 from musehub.mcp import scope_policy
181 from musehub.mcp.tools import MUSEHUB_WRITE_TOOL_NAMES
182
183 rows = _matrix_rows(html)
184 listed = {t["name"]: t for t in tools_list}
185 assert len(rows) == len(listed) == 127 and {r["tool"] for r in rows} == set(listed)
186 for r in rows:
187 n, ann = r["tool"], listed[r["tool"]]["annotations"]
188 assert (r["auth"] == "msign") == (n in MUSEHUB_WRITE_TOOL_NAMES), n
189 assert (r["readonly"] == "true") == bool(ann.get("readOnlyHint")), n
190 assert (r["destructive"] == "true") == bool(ann.get("destructiveHint")), n
191 want_scope = "" if n in scope_policy.READ_TOOLS else scope_policy.REQUIRED_SCOPE.get(n, "not for agent identities" if n in scope_policy.SCOPED_CALLER_DENIED else "")
192 assert r["scope"] == want_scope, n
193
194 def test_group_summary_counts_and_totals(self, html: str) -> None:
195 from musehub.mcp.tools import MCP_TOOLS, MUSEHUB_WRITE_TOOL_NAMES
196
197 table = html.split('id="tool-groups"', 1)[1].split("</table>", 1)[0]
198 rows = {m[0]: (int(m[1]), int(m[2])) for m in re.findall(r'<tr data-group="([a-z-]+)" data-count="(\d+)" data-auth="(\d+)"', table)}
199 assert sum(c for c, _ in rows.values()) == len(MCP_TOOLS) and sum(a for _, a in rows.values()) == len(MUSEHUB_WRITE_TOOL_NAMES)
200 assert set(rows) == {"read", "write", "elicitation", "coord-read", "coord-write", "workspace"}
201 assert f"{len(MCP_TOOLS)} tools in 6 registry groups: {len(MUSEHUB_WRITE_TOOL_NAMES)} need an MSign signature" in html
202
203 def test_no_hand_written_tool_lists_remain_in_the_template(self) -> None:
204 src = _TEMPLATE.read_text(encoding="utf-8")
205 assert not re.search(r"\b(read_names|cli_names|mist_names|elicit_names)\b", src)
206 assert not re.findall(r"'(?:musehub|muse)_[a-z_]*[a-z]'", src), "a tool name is typed into the template"
207 assert "{% for t in tools if" not in src
208
209 def test_the_server_and_deprecated_badges_are_gone_and_nothing_is_deprecated(self, html: str) -> None:
210 from musehub.mcp.prompts import PROMPT_CATALOGUE
211 from musehub.mcp.resources import RESOURCE_TEMPLATES, STATIC_RESOURCES
212 from musehub.mcp.tools import MCP_TOOLS
213
214 assert "badge--server" not in html and "badge--deprecated" not in html
215 blob = repr((MCP_TOOLS, STATIC_RESOURCES, RESOURCE_TEMPLATES, PROMPT_CATALOGUE)).lower()
216 assert "deprecat" not in blob, "the no-legacy rule: delete a deprecated tool instead of badging it"
217 assert all(t.get("server_side") for t in MCP_TOOLS), "every tool carried the 'server' badge, so it said nothing"
218
219 def test_anonymous_calls_to_every_signed_tool_are_refused_by_the_gate(
220 self, client: TestClient, sid: str, monkeypatch: pytest.MonkeyPatch
221 ) -> None:
222 from musehub.api.routes import mcp as route
223 from musehub.mcp.tools import MUSEHUB_WRITE_TOOL_NAMES
224
225 # One anonymous call per signed tool, far more than the anonymous per-IP budget: lift that budget for this sweep
226 # only (the limit itself is pinned by TestKnownDefects::test_an_anonymous_caller_is_held_to_the_anonymous_limit).
227 monkeypatch.setitem(route._CALLER_LIMITS, "anonymous", f"{len(MUSEHUB_WRITE_TOOL_NAMES) + 10}/minute")
228 for name in sorted(MUSEHUB_WRITE_TOOL_NAMES):
229 r = _rpc(client, sid, "tools/call", {"name": name, "arguments": {}})
230 assert r.status_code == 401 and r.json()["error"]["code"] == -32001, name
231 assert "MSign signature" in r.json()["error"]["message"], name
232
233 def test_resources_templates_and_prompts_equal_the_jsonrpc_lists(self, client: TestClient, sid: str, html: str) -> None:
234 uris = [x["uri"] for x in _rpc(client, sid, "resources/list").json()["result"]["resources"]]
235 tpls = [x["uriTemplate"] for x in _rpc(client, sid, "resources/templates/list").json()["result"]["resourceTemplates"]]
236 names = [x["name"] for x in _rpc(client, sid, "prompts/list").json()["result"]["prompts"]]
237 assert [html.count(f'<code class="resource-card__uri">{u}</code>') for u in uris] == [1] * len(uris)
238 assert [html.count(f'<code class="resource-card__uri">{u}</code>') for u in tpls] == [1] * len(tpls)
239 assert [html.count(f'<code class="prompt-card__name">{n}</code>') for n in names] == [1] * len(names)
240
241
242 # ── DOC_MCD_05: the machine twin ─────────────────────────────────────────────
243
244
245 class TestMachineTwin:
246 def test_docs_json_equals_tools_list_resources_templates_and_prompts(self, client: TestClient, sid: str, docs_json: tuple[dict[str, Any], Any], tools_list: list[dict[str, Any]]) -> None:
247 d, _ = docs_json
248 assert d["tools"] == tools_list
249 assert [x["uri"] for x in d["resources"]] == [x["uri"] for x in _rpc(client, sid, "resources/list").json()["result"]["resources"]]
250 assert [x["uriTemplate"] for x in d["resourceTemplates"]] == [x["uriTemplate"] for x in _rpc(client, sid, "resources/templates/list").json()["result"]["resourceTemplates"]]
251 assert [x["name"] for x in d["prompts"]] == [x["name"] for x in _rpc(client, sid, "prompts/list").json()["result"]["prompts"]]
252 assert {k: len(d[k]) for k in ("tools", "resources", "resourceTemplates", "prompts")} == {"tools": 127, "resources": 9, "resourceTemplates": 19, "prompts": 11}
253
254 def test_server_block_is_the_served_one_and_public_cacheable(self, docs_json: tuple[dict[str, Any], Any], initialize: dict[str, Any]) -> None:
255 from musehub.api.routes.mcp import _PROTOCOL_VERSION
256
257 d, r = docs_json
258 assert d["server"]["version"] == initialize["serverInfo"]["version"] and d["server"]["name"] == initialize["serverInfo"]["name"]
259 assert d["server"]["protocolVersion"] == initialize["protocolVersion"] == _PROTOCOL_VERSION == "2025-11-25"
260 assert r.headers["cache-control"] == "public, max-age=300"
261 src = (_REPO / "musehub" / "api" / "routes" / "mcp.py").read_text(encoding="utf-8")
262 assert '"version": "0.2.0"' not in src, "the version is read from the dispatcher, not typed twice"
263
264 def test_the_page_links_the_machine_twin_and_the_spec_for_the_served_version(self, html: str) -> None:
265 assert html.count('href="/mcp/docs.json"') >= 2
266 assert "modelcontextprotocol.io/specification/2025-11-25" in html
267
268
269 # ── DOC_MCD_06: the quick-start is the server's own onboarding sequence ─────────────────────────────────────
270
271
272 class TestQuickStart:
273 def test_every_tool_and_prompt_named_in_the_quick_start_exists(self, html: str) -> None:
274 from musehub.mcp.prompts import PROMPT_CATALOGUE
275 from musehub.mcp.tools import MCP_TOOLS
276
277 body = _section(html, "quickstart")
278 names = set(re.findall(r"<code>((?:musehub|muse)_[a-z_]+)</code>", body))
279 assert names >= {"musehub_set_context", "musehub_list_domains", "musehub_search_repos", "musehub_read_context", "musehub_read_coord_swarm", "muse_push", "musehub_read_prompt"}
280 assert names <= {t["name"] for t in MCP_TOOLS}
281 orient = next(p for p in PROMPT_CATALOGUE if p["name"] == "musehub/orientation")
282 assert any(a["name"] == "caller_type" for a in orient["arguments"]) and "<code>musehub/orientation</code>" in body and 'caller_type: "agent"' in body
283
284 def test_the_order_equals_the_initialize_instructions(self, html: str, initialize: dict[str, Any]) -> None:
285 body = _section(html, "quickstart")
286 order = [body.index(f"<code>{n}</code>") for n in ("musehub_set_context", "musehub_read_context", "musehub_read_coord_swarm", "muse_push")]
287 assert order == sorted(order)
288 ins = initialize["instructions"]
289 assert ins.index("musehub_set_context") < ins.index("musehub_read_context") < ins.index("musehub_read_coord_swarm")
290
291 def test_the_muse_mcp_page_no_longer_says_the_sequences_differ(self, rendered: dict[str, str]) -> None:
292 guide = rendered[rc.phase_path("mcp")]
293 assert "suggests a different first sequence" not in guide and "being consolidated" not in guide
294 assert 'href="/mcp/docs#quickstart"' in guide and 'id="known-issues"' in guide
295
296 def test_the_documented_agent_registration_commands_parse(self, html: str) -> None:
297 parser = cc.capture_parser()
298 cmds = [c for c in cc.extract_commands(html)]
299 lines = {c.line for c in cmds}
300 assert {"muse auth keygen", "muse auth register --agent"} <= lines
301 _, problems = cc.check_page(parser, PAGE, html)
302 assert problems == [], "\n".join(problems)
303
304
305 # ── DOC_MCD_01/02/03 and the page's own claims ──────────────────────────────────────────────────────────
306
307
308 class TestPageClaims:
309 def test_documented_commands_parse(self, html: str) -> None:
310 _, problems = cc.check_page(cc.capture_parser(), PAGE, html)
311 assert problems == []
312
313 def test_in_page_and_docs_links_resolve(self, page: str, rendered: dict[str, str]) -> None:
314 from musehub.main import app
315
316 parsed = {p: rc.parse_page(h) for p, h in rendered.items()} | {PAGE: rc.parse_page(page)}
317 other = {r.path for r in app.routes if hasattr(r, "path")}
318 problems = [p for p in rc.check_anchors(parsed, other_routes=other) if p.startswith(PAGE)]
319 assert problems == []
320
321 def test_the_msign_examples_carry_alg_and_the_servers_parser_accepts_them(self, html: str) -> None:
322 from musehub.auth.request_signing import _parse_msign_header
323
324 raw = re.findall(r'Authorization: (MSign handle="&lt;handle&gt;".*?sig="&lt;b64url&gt;")', html)
325 assert len(raw) == 2 and all('alg="ed25519"' in e for e in raw), raw
326 for e in raw:
327 filled = html_lib.unescape(e).replace("<handle>", "alice").replace("<unix>", "1700000000").replace("<b64url>", "AAAA")
328 assert _parse_msign_header(filled) == ("alice", "ed25519", 1700000000, "AAAA")
329 assert _parse_msign_header(filled.replace(' alg="ed25519"', "")) is None # the old example, without alg, is refused
330
331 def test_the_tool_filter_is_labelled_and_the_count_is_announced(self, html: str) -> None:
332 tag = re.search(r'<input id="tool-filter"[^>]*>', html)
333 assert tag and "aria-label=" in tag.group(0)
334 counter = re.search(r'<span id="tool-count"[^>]*>', html)
335 assert counter and 'role="status"' in counter.group(0) and 'aria-live="polite"' in counter.group(0)
336
337 def test_external_links_open_with_noopener_and_there_is_one_main_and_one_h1(self, html: str) -> None:
338 for a in re.findall(r"<a [^>]*target=\"_blank\"[^>]*>", html):
339 assert "noopener" in a, a
340 assert html.count("<main ") == 1 and html.count("<h1") == 1
341
342 def test_required_marks_are_also_text_not_only_a_star(self, html: str) -> None:
343 assert html.count('<span class="mcpref__sr"> required</span>') > 100 and html.count('<span class="mcpref__sr"> optional</span>') > 100
344
345 def test_the_rate_limit_row_states_the_enforced_defaults(self, html: str) -> None:
346 from musehub.config import settings
347 from musehub.rate_limits import MCP_LIMIT
348
349 assert (settings.mcp_rate_limit_anonymous, settings.mcp_rate_limit_human, settings.mcp_rate_limit_agent) == (
350 "20/minute", "60/minute", "600/minute")
351 assert MCP_LIMIT == settings.mcp_rate_limit_agent # the per-IP ceiling on the route
352 assert ("anonymous 20 per client IP, human 60 per MSign handle, agent 600 per MSign handle; "
353 "at most 600 per client IP overall") in html
354 assert "the same for every caller" not in html and "musehub#325" not in html
355
356 def test_the_route_no_longer_hides_render_errors_behind_a_redirect(self) -> None:
357 from unittest.mock import patch
358
359 from musehub.api.routes.musehub import _templates
360 from musehub.main import app
361
362 with patch.object(_templates.templates, "TemplateResponse", side_effect=RuntimeError("boom")):
363 with pytest.raises(RuntimeError, match="boom"):
364 TestClient(app).get(PAGE)
365 assert "except Exception" not in (_REPO / "musehub" / "api" / "routes" / "mcp.py").read_text(encoding="utf-8").split("async def mcp_docs(")[1].split("# ── Helpers")[0]
366
367 def test_served_over_https_has_no_http_urls(self, trusted_proxies: str) -> None: # noqa: F811
368 served = render_behind_proxy([PAGE], trusted_proxies, BRIDGE_GATEWAY_PEER)
369 assert sc.check_page(PAGE, served[PAGE]) == []
370
371
372 # ── DOC_MCD_07: known defects, pinned: each flips when its ticket is fixed ─────────────────────────────────
373
374
375 @pytest.fixture(scope="module")
376 def anonymous_first_429(client: TestClient) -> int | None:
377 from musehub.rate_limits import limiter
378
379 limiter.reset()
380 start = time.monotonic()
381 first = None
382 for i in range(1, 640):
383 if client.post("/mcp", json={"jsonrpc": "2.0", "id": i, "method": "ping"}).status_code == 429:
384 first = i
385 break
386 assert time.monotonic() - start < 120
387 limiter.reset()
388 return first
389
390
391 class TestKnownDefects:
392 def test_every_known_issue_links_its_ticket_and_the_guide(self, html: str) -> None:
393 for n in _KNOWN:
394 assert f'href="{HUB_ISSUES}{n}"' in html, n
395 assert 'href="/muse/mcp#known-issues"' in html
396
397 def test_an_anonymous_caller_is_held_to_the_anonymous_limit(self, anonymous_first_429: int | None) -> None:
398 from musehub.config import settings
399
400 limit = int(settings.mcp_rate_limit_anonymous.split("/")[0])
401 assert anonymous_first_429 == limit + 1 # not the 601 of the per-IP agent ceiling
402
403 def test_every_mcp_rate_limit_setting_is_read_by_non_test_code(self) -> None:
404 src = "".join(p.read_text(encoding="utf-8") for p in (_REPO / "musehub").rglob("*.py") if p.name != "config.py")
405 assert "mcp_rate_limit_human" in src and "mcp_rate_limit_anonymous" in src
406
407 def test_the_signed_read_only_tools_are_the_page_note(self, html: str, tools_list: list[dict[str, Any]]) -> None:
408 from musehub.mcp import scope_policy
409 from musehub.mcp.tools import MUSEHUB_WRITE_TOOL_NAMES
410
411 listed = {t["name"]: t["annotations"] for t in tools_list}
412 signed_reads = sorted(n for n in MUSEHUB_WRITE_TOOL_NAMES if listed[n]["readOnlyHint"])
413 assert signed_reads == sorted(scope_policy.READ_TOOLS - {"musehub_accept_collaborator_invite"}) and len(signed_reads) == 15
414 assert f"{len(signed_reads)} read-only tools need a signature" in html and ", ".join(signed_reads) in html
415 assert "musehub#324" not in html and "Write tools require" not in html
416
417 def test_read_class_tools_report_read_only(self, tools_list: list[dict[str, Any]]) -> None:
418 from musehub.mcp import scope_policy
419
420 listed = {t["name"]: t for t in tools_list}
421 assert all(listed[n]["annotations"]["readOnlyHint"] for n in scope_policy.READ_TOOLS - {"musehub_accept_collaborator_invite"})
422
423 def test_the_gate_message_does_not_call_a_read_a_write(self, client: TestClient, sid: str) -> None:
424 r = _rpc(client, sid, "tools/call", {"name": "musehub_list_webhooks", "arguments": {}})
425 assert "Write tools" not in r.json()["error"]["message"]
426
427 def test_task_lists_sort_the_way_the_descriptions_say(self) -> None:
428 src = (_REPO / "musehub" / "services" / "musehub_coord_server.py").read_text(encoding="utf-8")
429 body = src.split("async def list_tasks(", 1)[1].split("async def ", 1)[0]
430 assert "priority.desc()" in body
431
432 def test_the_page_states_the_task_order_the_descriptions_promise(self, html: str) -> None:
433 from musehub.mcp.tools import MCP_TOOLS
434
435 d = {t["name"]: t["description"] for t in MCP_TOOLS}
436 assert "highest priority first" in d["musehub_list_coord_tasks"]
437 section = _section(html, "tools-coord-write")
438 assert "Tasks are listed highest <code>priority</code> first" in section and "lowest" not in section
439
440 def test_no_docstring_states_a_stale_tool_count(self) -> None:
441 import musehub.mcp.tools as pkg
442
443 assert "all 40" not in (pkg.__doc__ or "")
File History 16 commits
sha256:0a2400b8017d871bff9916bfa6d3898b74b0dcce7f8e4d6e842365133f21090a fix(coord): a task claim is one conditional UPDATE — exactl… Opus 5.5 minor ⚠ 1 day ago
sha256:2b93e88316d2f32df15a9f877b0b6e5fae363de59bc428ce5709f86e230581d8 docs(mcp): the cross-worker elicitation/push known issue mo… Opus 5.5 patch 1 day ago
sha256:e6c07a0f17d2b30516cfe406c094c493c3aeaf8ea72db9ca098d24013bcc3bb9 Merge branch 'task/wave-hub-mcp-289' into dev Opus 5.5 minor ⚠ 1 day ago
sha256:08c30c873257205e342a68f5d55803ff3c6dd6abd4747b5444c68e1da4b8da39 fix(mcp): bind sessions to their principal; honest cross-wo… Opus 5.5 minor ⚠ 1 day ago
sha256:5e59815d34816a1aa12717d0ac82362d6a9919e8b6e096e66ed49c47a028d76f fix(mcp): share Streamable HTTP sessions across worker proc… Opus 5.5 minor ⚠ 1 day ago
sha256:c2ee54efa85fcbdeea4ffc84a2dd1b8fcd4623463b22e35765df3013a26834aa merge: #276 public URLs + muse#181 docs onto dev (#313 present) Opus 5.5 minor ⚠ 1 day ago
sha256:c777acd5605d4a83bbf9d2903bff0b0d419325b7bc49317700e4037b56594e8e fix(web): absolute public URLs come from the canonical publ… Opus 5.5 minor ⚠ 1 day ago
sha256:d7af2b937831db3288db5589530c6c2f8e90f0c2c4efbbeb5dd0577076168b29 fix(mcp): SSE event ids + Last-Event-ID replay (#290); per-… Opus 5.5 minor ⚠ 2 days ago
sha256:c808b041005b5fb74b96123843a4033e94ecd49667c2fd84a9b45165e4433390 docs(mcp): progress events echo progressToken — drop the #2… Opus 5.5 minor ⚠ 2 days ago
sha256:f19d5e4a89766fc91b926cdf801255e12dcd968041c0ece8adf6627760788d22 merge: next build — MCP (#291 #292 #295 #324), profiles/sit… Opus 5.5 minor ⚠ 2 days ago
sha256:87f4c4d976afad92db715748495c09600f4aafed5f924e6b4b1664aab5a86fad merge: rc26 — MCP wave (#291 #292 #295 #324) Opus 5.5 minor ⚠ 2 days ago
sha256:8f71621a510dbf00c5cef4b4a877ab154ea8c4af406d0fe7f0319a368b954f64 fix(mcp): notifications/elicitation/complete resolves the U… Opus 5.5 minor ⚠ 2 days ago
sha256:e0601efe55c167c25a25964556649adc67857bd02e415016a026c852e1a535b2 fix(mcp): gate and dispatcher errors carry error_code/error… Opus 5.5 minor ⚠ 2 days ago
sha256:ff23c9c281bee839f187bbaf3d30de9e88d331e3c404ed45e2845954f04cad82 fix(mcp): tools/list sets all four hints from one registry … Opus 5.5 minor ⚠ 2 days ago
sha256:3d450cb7100e86b4c435cbfeb8d185f2b659827e9beb43ab1dcd32e6e31e955c docs(mcp): drop the stale #294 known issue Sonnet 5.5 patch 6 days ago
sha256:0f032aa44c3e507f97d2fc10b144695c87c91110b2dd12888287d6446a81b668 docs(mcp): #261 MCP Reference QA contract v2 — render /mcp/… Sonnet 5.5 minor ⚠ 8 days ago