Skip to content

fix(mcp): mcp tools and resources call commands and options that exist #836

Closed

Description

@dan-petty

Context & Rationale

src/devops_cli/ai/mcp/server.py builds 169 argv lists that start with ['uv', 'run', 'devops', ...]. Nothing resolves them against the CLI, and 12 of them fail on every call.

Missing commands (7):

  • benchmark_embeddings (:2092) and benchmark_suite (:2119) call a top-level devops benchmark. The command is devops ai benchmark (commands/ai.py:99).
  • ai_architecture (:2144) calls devops analyze architecture, which has never existed.
  • scan_gitleaks (:1857), scan_semgrep (:1868) and scan_checkov (:1878) call scan aliases. 4cfe033 (v0.2.10, 2026-09-05) removed those aliases, and tests/test_codebase_hygiene_and_shims.py:84-92 asserts they are gone. The tools arrived one day later in 22bba04 (v0.2.11), so they have never worked.
  • resource://workspace/status (:1159) calls devops workspace list.

Unknown options (5):

  • repos_sync appends --all (:234-236). devops repos sync has never had that option; the call was added in 4e48cd7.
  • resource://argo/fleet/status passes --json (:1241).
  • scan_complexity passes --max-nesting-depth (:1892). The real option is --max-indent (commands/scan.py:420-422).
  • k8s_chaos passes --experiment (:1940).
  • k8s_audit passes --namespace (:1961).

None of these is a regression: each entry point was broken from the start.

Why nothing caught it:

  • A failure comes back as ordinary tool text (Command exited with status 2: ... No such command, server.py:60-62), not as an MCP error.
  • tests/test_mcp.py:377-401 patches _run_mcp_cmd and asserts the mock's own return value.
  • typer.main.get_command(main.app) cannot resolve past the first segment, because the lazy proxies accept extra args (core/cli.py:126-150).

Planning record: docs/ROADMAP.md:1040 (P0, no issue) plans this fix and says to reuse the resolver from docs/ROADMAP.md:908, the Phantom Command, Option and Tool Reference Gate (P1, no issue). Its '3 of 170' count checked only top-level names. #739 does not migrate entries without an issue.

Scope & Deliverables

  • Deliverable:
    • One resolver function under src/devops_cli/docs/, behind the devops docs check seam, designed as ROADMAP.md:908 specifies:
      • walk resolve_command down from main._COMMAND_SPECS on typer.main.get_command objects;
      • call make_context(resilient_parsing=False) on the leaf, never invoke;
      • duck-type the vendored Click classes, with negative-control tests that fail if a Typer upgrade changes the walk.
    • An AST collector for ai/mcp/server.py:
      • collects list literals starting with uv run devops, plus literal flags added to the same variable by .append or .extend;
      • replaces non-literal elements with placeholders;
      • reports only unknown commands, unknown options and unexpected extra arguments.
    • devops docs check runs both.
    • Fix or delete the 12 entry points:
      • benchmark tools: use devops ai benchmark with its real options (--type, --models, --suite);
      • scan tools: use devops scan secrets, sast or iac;
      • scan_complexity: use --max-indent;
      • k8s_chaos and k8s_audit: pass only options that exist;
      • the workspace resource: back it with an existing command, or delete it;
      • the argo resource: drop --json;
      • repos_sync: drop all_repos;
      • ai_architecture: delete it, with no shim.
    • Rewrite the mock pass-through assertions for the changed tools.
    • Regenerate docs/MCP_TOOLS.md, add CHANGELOG Removed entries, and mark part (1) of ROADMAP.md:1040 delivered.
  • Acceptance criteria:
    • devops docs check covers at least 169 literal argv lists and reports 0 unresolved commands and 0 unknown options.
    • The fixture argv uv run devops analyze architecture is reported as unresolved, naming analyze.
    • A fixture with an unknown option is reported with its source line.
    • No test in tests/test_mcp.py asserts a mocked return value for a changed or removed tool.
    • uv run devops docs check passes with the regenerated docs/MCP_TOOLS.md.
    • The docs stage grows by at most 1 s, recorded in the task file.
    • No network access, no subprocess, no new dependency.
  • Key questions:
    • Should ai_architecture come back later, backed by the import graph? (proposed) Only when something needs it.
    • What happens to the vulture step in ROADMAP.md:1040? (proposed) It is dropped, and the task file records that. The import-cycle part is a separate item.
  • Constraint:

Strategic Alignment

  • Milestone: v0.2.24 if admitted as a critical fix (an owner-set P0 defect fix); otherwise Backlog, ranked first.
  • Design: CONTEXT.md (Critical fix)
  • Depends on: none

Activity

  1. added
    type/bug
    scope/mcp
    priority/p0-critical
    on Oct 1, 2026
  2. added this to the v0.2.24 milestone on Oct 1, 2026
  3. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Admitted to v0.2.24 as a critical fix, by the owner's decision (2026-10-01): a P0 defect fix. 12 of 169 MCP tools call commands or options that don't exist, and every agent session loads them.

  4. dan-petty commented on Oct 1, 2026

    @dan-petty
    OwnerAuthor

    Closed by #867, merged into release/v0.2.24.

    GitHub only acts on closing keywords when a pull request merges into the default branch, so this was closed by devops gh issues close-merged.

  5. added a commit that references this issue on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p0-criticalscope/mcptype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions