Skip to content

Commit e95a277

Browse files
committed
feat(05-04): surface MCP caps in supamem doctor with provenance
- Add 'MCP caps' section to run_doctor between Config chain and Installed clients (D-12). Renders all three cfg.mcp_caps_* values with their chain.mcp_caps_* source attribution via console.py exports (ok()) — no bare print(). - Extend tests/test_cli_smoke.py with test_doctor_shows_caps that asserts the section header, all three keys, all three defaults (25/250/200), and the [source: ...] provenance tag. Uses the shared _run() helper that pins NO_COLOR=1, TERM=dumb, COLUMNS=200 so Rich color escapes never pollute assertion strings.
1 parent 3725950 commit e95a277

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

src/supamem/doctor.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,22 @@ def run_doctor(*, redact_secrets: bool = True) -> int:
140140
# rich's soft_wrap still respects the 80-col default in pytest.
141141
print(format_chain(cfg, chain, redact_secrets=redact_secrets))
142142

143+
# ── Section 2b: MCP caps (D-12) ──────────────────────────────────────
144+
console.print()
145+
console.print("[supamem.brand]MCP caps[/supamem.brand]")
146+
ok(
147+
f"max_top_k = {cfg.mcp_caps_max_top_k} "
148+
f"[source: {chain.mcp_caps_max_top_k}]"
149+
)
150+
ok(
151+
f"max_query_chars = {cfg.mcp_caps_max_query_chars} "
152+
f"[source: {chain.mcp_caps_max_query_chars}]"
153+
)
154+
ok(
155+
f"max_preview_chars = {cfg.mcp_caps_max_preview_chars} "
156+
f"[source: {chain.mcp_caps_max_preview_chars}]"
157+
)
158+
143159
# ── Section 3: Installed clients drift ───────────────────────────────
144160
console.print()
145161
console.print("[supamem.brand]Installed clients[/supamem.brand]")

tests/test_cli_smoke.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,27 @@ def test_index_runs_failsoft_with_no_sources() -> None:
6666
)
6767

6868

69+
def test_doctor_shows_caps() -> None:
70+
"""Plan 05-04 Task 01: ``supamem doctor`` surfaces the three cap values + sources.
71+
72+
Asserts the new "MCP caps" section renders with all three keys and their
73+
defaults (25 / 250 / 200) plus a ``[source: ...]`` provenance tag. Subprocess
74+
env is pinned by ``_run`` (NO_COLOR=1, TERM=dumb, COLUMNS=200) so Rich color
75+
escapes never pollute the assertion strings.
76+
"""
77+
result = _run("doctor")
78+
# doctor exits 1 when Qdrant is unreachable (CI / dev without docker up);
79+
# the caps section runs unconditionally before that exit, so we don't gate
80+
# on returncode here — only on the rendered surface.
81+
out = result.stdout
82+
assert "MCP caps" in out, f"expected 'MCP caps' section header in output, got: {out!r}"
83+
for key in ("max_top_k", "max_query_chars", "max_preview_chars"):
84+
assert key in out, f"expected {key!r} in doctor output, got: {out!r}"
85+
for default in ("25", "250", "200"):
86+
assert default in out, f"expected default {default!r} in doctor output, got: {out!r}"
87+
assert "[source:" in out, f"expected provenance tag '[source: ...]' in output, got: {out!r}"
88+
89+
6990
def test_version_prints_current() -> None:
7091
"""Test 6: --version prints styled banner with current __version__ + credit line."""
7192
from supamem import __version__

0 commit comments

Comments
 (0)