Skip to content

phase4-C: Claude Code integration smoke + examples + --tool CLI surface#3

Merged
rafael5 merged 1 commit into
mainfrom
phase4-C
May 11, 2026
Merged

phase4-C: Claude Code integration smoke + examples + --tool CLI surface#3
rafael5 merged 1 commit into
mainfrom
phase4-C

Conversation

@rafael5
Copy link
Copy Markdown
Contributor

@rafael5 rafael5 commented May 11, 2026

Summary

Track C of phase4-plan.md §4. Plus a Track-B carry-over: the --tool/--query CLI surface the plan framed as a B-deliverable but that landed here alongside the smoke.sh that depends on it.

--tool / --query CLI surface

m-dev-tools-mcp now has two modes:

  • MCP server (default) — no args boots the stdio transport for Claude Code / Codex / Continue.
  • CLI smoke--tool route_intent --query "…" / --tool describe --typed-id "…" / --tool verify --repo "…" runs a single tool call out of process and prints the JSON response on stdout. Lets scripts (and CI) verify the server resolves the canonical query without spinning up an MCP client.

Exit codes:

rc Meaning
0 Success
2 Usage error (unknown tool, missing required flag)
3 DiscoveryError from the tool; stdout carries a {"error": true, "code": "…", "message": "…"} blob so shells can switch on the code

argparse uses exit_on_error=False so main(argv) returns the rc cleanly under unit-test control. Conditional-required-flag validation (--query required only when --tool=route_intent, etc.) is post-parse so error messages are specific.

examples/claude-code/

  • .mcp.json — uvx-from-git config; pins to main so new catalog merges show up on next server restart.
  • README.md — install paths (uvx + release wheel), Claude Code registration steps, "other MCP clients" note.
  • smoke.sh — shells the canonical route_intent("parse JSON in M") query through the new CLI surface and asserts "module:m-stdlib#STDJSON" lands in the response. Supports M_DEV_TOOLS_MCP_BIN=… to point at a local venv install for fast iteration (default uses uvx which clones the repo).
  • session.md — template for the recorded Claude Code session Track C calls for. The session itself can't be auto-run from inside Claude Code; this file describes the steps and reserves placeholders the user fills in once after running the session locally. smoke.sh is the always-on automated assertion; this is the once-per-release human-eyes confirmation.

Test plan

  • 41/41 pytest (30 prior + 11 new CLI cases)
  • ruff clean, mypy strict clean (4 source files)
  • make check-manifest + make check-agents clean
  • examples/claude-code/smoke.sh exits 0 locally via M_DEV_TOOLS_MCP_BIN=$PWD/.venv/bin/m-dev-tools-mcp — response was ["module:m-stdlib#STDJSON"]
  • CI green

What's NOT in this PR

  • Filled-in session.md — the template stays unfilled until you (the user) record a real Claude Code session. The PR is mergeable without it; smoke.sh covers the automated half of the Track C verification.
  • v0.1.0 release wheel — that's Track D.

Track C of phase4-plan.md §4. Plus a Track-B carry-over: the
--tool/--query CLI surface the plan framed as B-deliverable but that
landed here alongside the smoke.sh that depends on it.

### --tool / --query CLI surface

``m-dev-tools-mcp`` now has two modes:

* **MCP server (default)** — no args boots the stdio transport for
  Claude Code / Codex / Continue.
* **CLI smoke** — ``--tool route_intent --query "…"`` /
  ``--tool describe --typed-id "…"`` / ``--tool verify --repo "…"``
  runs a single tool call out of process and prints the JSON
  response on stdout. Lets scripts (and CI) verify the server
  resolves the canonical query without spinning up an MCP client.

Exit codes:

* ``0`` — success
* ``2`` — usage error (unknown tool, missing required flag)
* ``3`` — DiscoveryError from the tool; stdout carries a structured
  ``{"error": true, "code": "...", "message": "..."}`` blob so shells
  can switch on the code.

argparse uses ``exit_on_error=False`` so ``main(argv)`` returns the
rc cleanly under unit-test control. Conditional-required-flag
validation (``--query`` required only when ``--tool=route_intent``,
etc.) is enforced post-parse to keep the error messages specific.

11 new TDD cases in ``tests/test_cli.py`` cover: --version still
works (Track A contract), each tool's happy path, --tool unknown,
each tool's missing-required-flag, route_intent no-match → exit 0
with ``[]``, DiscoveryError → exit 3 with structured blob, and an
end-to-end subprocess smoke that hits the live catalog (skipped on
network failure to avoid flakes).

### examples/claude-code/

* ``.mcp.json`` — uvx-from-git config; pins to ``main`` so new
  catalog merges show up on next server restart.
* ``README.md`` — install paths (uvx + release wheel), Claude Code
  registration steps, "other MCP clients" note, smoke-test pointer.
* ``smoke.sh`` — shells the canonical ``route_intent("parse JSON in
  M")`` query through the new CLI surface and asserts
  ``"module:m-stdlib#STDJSON"`` lands in the response. Supports
  ``M_DEV_TOOLS_MCP_BIN=…`` to point at a local venv install for
  fast iteration (uvx would clone the repo).
* ``session.md`` — template for the recorded Claude Code session
  Track C calls for. The session itself can't be auto-run from
  inside Claude Code; this file describes the steps and reserves
  placeholders the user fills in once after running the session
  locally. The always-on assertion is smoke.sh; this is the
  once-per-release human-eyes confirmation.

### Test plan

* 41/41 pytest (30 prior + 11 new CLI)
* ruff clean, mypy strict clean (4 source files)
* check-manifest + check-agents clean
* ``examples/claude-code/smoke.sh`` exits 0 locally via
  ``M_DEV_TOOLS_MCP_BIN=$PWD/.venv/bin/m-dev-tools-mcp``
@rafael5 rafael5 merged commit 7dc8410 into main May 11, 2026
1 check passed
@rafael5 rafael5 deleted the phase4-C branch May 11, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant