Repository navigation
Description
Context & Rationale
All 155 tools in src/devops_cli/ai/mcp/server.py use a bare @mcp.tool() with no annotations=. A client therefore cannot tell these tools from read-only ones:
tf_apply(:670), which defaults toauto_approve=True;k8s_teardown_stack(:302), which defaults to theinfrastack;valkey_flush(:2502);vault_set(:2060);pr_close(:2303).
DomainGateMiddleware filters only the listing (:3006).
devops ai pipeline hands every stage get_default_tools(). The agent loop already turns ApprovalRequired into DeferredToolRequests, but no production tool sets requires_approval, and require_approval_toolset (ai/toolsets/__init__.py:429) has no caller.
docs/ROADMAP.md:1082 (P1, no issue) designs the fix.
Scope & Deliverables
- Deliverable:
- PR1:
- Annotate every tool through FastMCP's
annotations=. - Add a test beside
test_fastmcp_tool_docstrings_and_parametersthat iteratesmcp._list_tools()and fails whenreadOnlyHintis unset. - Carry the hints into
export-schemas,MCPToolInfoandMCP_TOOLS.md. - Change
tf_applyto default toauto_approve=False.
- Annotate every tool through FastMCP's
- PR2:
- The bridge builds agent tools only from
FunctionToolcomponents, and setsrequires_approvalunlessreadOnlyHintis true. devops ai pipelinegets aHandleDeferredToolCallscapability that prompts on a TTY and denies otherwise.ToolSlotreads the annotation.- Delete
require_approval_toolsetand its re-exports.
- The bridge builds agent tools only from
- PR1:
- Acceptance criteria:
- Every registered tool has
readOnlyHintset (registry test). - Each argument-dependent tool is annotated for its most dangerous arguments.
- A non-interactive pipeline run denies an unannotated or mutating tool.
devops docs checkpasses, and the new tests take at most 1 s.
- Every registered tool has
- Key questions:
- Do external clients such as Claude Code also need a
confirmargument? (proposed) No. They have their own permission prompts, and the spec says clients must not trust annotations from untrusted servers. This protects devops-cli's own loop.
- Do external clients such as Claude Code also need a
- Constraint:
- A wrong
readOnlyHint: trueis worse than none. - Do not wrap tools with pydantic-ai's
approval_required, becauseextract_tools_from_toolsetdrops every tool behind it. - Two PRs, as in feat(review): branch and pr reviews compute their own base-vs-head symbol delta #593.
- A wrong
Strategic Alignment
- Milestone: Backlog
- Depends on: none
Update 2026-10-08: refinement
No tool sets annotations=; tf_apply defaults to auto_approve=True (ai/mcp/server.py:930). As the 2026-10-01 placement asked, this item keeps PR1 (annotations, registry test, hints, tf_apply default False); PR2 (agent approval, deleting require_approval_toolset) becomes its own item depending on this one.
- Tools that write for some arguments carry
readOnlyHint: false, includingroadmap_render,gh_project_reconcile,docker_sign,argo_rollout_analyzeandrag_drift; the test holds the list as a floor.
Proposed design
Problem statement
All 155 MCP tools in src/devops_cli/ai/mcp/server.py are registered with a bare @mcp.tool() and no annotations= parameter, so no client can distinguish read-only tools from mutating ones such as tf_apply (which defaults to auto_approve=True), k8s_teardown_stack, valkey_flush, vault_set and pr_close. This issue (PR1 of a two-PR split) adds a readOnlyHint annotation to every tool via FastMCP's annotations= parameter, enforces it with a registry test, carries the hints into export-schemas / MCPToolInfo / MCP_TOOLS.md, and changes tf_apply to default to auto_approve=False. PR2 (agent-loop approval and deletion of require_approval_toolset) is a separate item that depends on this one.
Acceptance criteria
- Criterion 1: Every registered tool in src/devops_cli/ai/mcp/server.py has readOnlyHint set via FastMCP's annotations= parameter.
Verification: A test beside test_fastmcp_tool_docstrings_and_parameters iterates mcp._list_tools() and fails when any tool's readOnlyHint is unset; run pytest on that test and confirm it passes. - Criterion 2: Tools that write for some arguments carry readOnlyHint: false, including roadmap_render, gh_project_reconcile, docker_sign, argo_rollout_analyze and rag_drift; the test holds the list as a floor.
Verification: The registry test asserts each named tool has readOnlyHint set to false; run pytest on that test and confirm it passes. - Criterion 3: tf_apply defaults to auto_approve=False.
Verification: Inspect the tf_apply function signature in src/devops_cli/ai/mcp/server.py and confirm the default value is False; run a test that calls tf_apply without auto_approve and verifies the command does not include --auto-approve. - Criterion 4: The readOnlyHint values are carried into export-schemas output, the MCPToolInfo model, and docs/MCP_TOOLS.md.
Verification: Run devops ai mcp export-schemas and confirm the JSON output includes annotation data; verify MCPToolInfo in src/devops_cli/models/ai.py has a field for the hint; confirm docs/MCP_TOOLS.md renders the hints. - Criterion 5: devops docs check passes and the new tests complete in at most 1 second.
Verification: Run devops docs check and confirm exit code 0; run pytest -x --timeout=1 on the new registry test and confirm it passes within the budget.
Key questions
- Do external clients such as Claude Code also need a confirm argument?: No. External clients have their own permission prompts, and the MCP spec says clients must not trust annotations from untrusted servers. The annotations protect devops-cli's own agent loop, not third-party clients. (proposed)
- Which tools must carry readOnlyHint: false as a floor in the registry test?: roadmap_render, gh_project_reconcile, docker_sign, argo_rollout_analyze and rag_drift are named as the floor; the test holds this list and any tool that writes for some arguments must also be annotated false. [sources: src/devops_cli/ai/mcp/server.py]
- Should tools be wrapped with pydantic-ai's approval_required?: No. extract_tools_from_toolset drops every tool behind approval_required, so wrapping would silently remove tools from the agent's toolset. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 1, 2026
Placement (2026-10-01): v0.2.28. Value High, Effort High. Not Ready yet.
Checked against
release/v0.2.24at d38251e. What stops it being Ready:dan-petty-bot commentedon Oct 6, 2026
Moved to the backlog: it was New, not Ready, when v0.2.28 started. (devops roadmap reprioritize)
dan-petty commentedon Oct 8, 2026
Linked: #997 takes
readOnlyHintfrom this item and lands after it. #886's dry-run class (makes no external request) differs fromreadOnlyHint(changes no state); one declaration per command can serve both. Found by the 2026-10-08 backlog review.dan-petty-bot commentedon Oct 10, 2026
Status set to Ready at 69c99cf (see proposed design in issue body).
feat(mcp): declare ToolAnnotations readOnlyHint on all tools and defa…
dan-petty commentedon Oct 16, 2026
Delivered in #1600 (dd1b896) on release/v0.2.36.
feat(release): v0.2.36 (#1615)
feat(k8s): devops k8s doctor checks the gitea stack: tunnel host, ano…