Skip to content

docs(openspec): plan #3236 confine MCP tool path options - #3248

Merged
dan-petty merged 3 commits into
mainfrom
fix/3236-read-only-tools-take-paths-that
Nov 2, 2026
Merged

dan-petty merged 3 commits into
mainfrom
fix/3236-read-only-tools-take-paths-that

Conversation

@devops-cli-service

Copy link
Copy Markdown
Contributor

Plans #3236

Read-only MCP tools publish path options that a model chooses, and the server opens or writes those paths. Over a network transport a model can therefore reach outside the work tree. This change stops publishing a path option that the server can choose for itself, and confines every kept path option to a root that the server sets, through safe_resolve_subpath. A schema test reads the published schema of every exposed tool and fails on a path-like text parameter that has no confinement entry. SECURITY.md rule 11 then holds for the tools, not only for the transport.

Change: openspec/changes/3236-read-only-tools-take-paths-that/

Copy link
Copy Markdown
Owner

Review of the plan for #3236.

CI: 18 check runs on head 429b554, all success or skipped. Premise: partly false at the base (4571d5f). The three example options are real, but the plan says the role tables are absent, and they are not. I did not run openspec validate (the tool is not installed in my clone).

  1. The audit cannot pass as planned (blocker). Task 4.1 asserts that the set of path-like properties equals the registry. On base, the keyword match of _PATH_PARAM_KEYWORDS finds 69 text parameters in 61 tools of the 145 that the server lists (run with mcp._list_tools()). The plan registers one (gh_pages_verify.root_dir) and removes two. The other 66 have no entry, so the task "passes" step fails. The model review in the stage comment of fix(mcp): read-only tools take paths that reach the server file system #3236 found this and it is still open. The keyword rule also gives false positives that need an allow-list with reasons (ai_failover.target_model, ai_failover.target_provider, ai_rag_query.file_filter, security_intel_network.target, vault_get.path), and it misses real file options: k8s_security_stream.output, review_export_feedback.output, tf_plan.out, ai_ingest_library.output_dir (names with no keyword). The plan removes output by hand, but its own audit would not have flagged it. Fix: pick one scope and say it in the proposal and spec: (a) the role tools only (the issue's criteria), or (b) the whole catalogue with an allow-list. [C8 scope]
  2. False premise: the role tables exist on base (blocker). Feasibility says roles.py "is no file of the staging commit" and that "the role tables of feat(mcp): serve role-scoped tool sets over authenticated HTTP #3219 are not in this base". git show 4571d5f3:src/devops_cli/ai/mcp/roles.py shows _JOB_ROLE_TOOLS (merged in feat(mcp): serve role-scoped tools over streamable HTTP #3233, 6923473). The refine block checked sha ff9ad06, which is before feat(mcp): serve role-scoped tools over streamable HTTP #3233. The module docstring says the tables name no tool that takes a path, and SECURITY.md (HTTP paragraph) says the same. I ran the audit on the three job roles: planning (28 tools), implementation (17) and review (16) hold one path-like text parameter, security_intel_network.target, which is a host or address, not a file. So criterion 1 holds for the HTTP roles by construction, and the three example tools are in no job role. They are reachable through sse (run_mcp_server runs the whole mcp object for it, server.py:436) and stdio. The plan must say this and name the transports it protects. Criterion 2 (a role-tool audit) is small and has no test yet in tests/ai/mcp/test_mcp_roles.py. [C2, C11 in part]
  3. Wrong command paths and flags (blocker). The plan keys ("ai", "ast-graph") (task 3.2) and the issue and Feasibility use devops ai ast-graph --help and devops gh pages-verify --help. The table rows are ("ai", "ast", "graph") (constants.py:269) and ("gh", "pages", "verify") (constants.py:322). I ran both help commands: "No such command 'ast-graph'" and "No such command 'pages-verify'". With the wrong key, _PATH_PARAM_RESTRICTIONS.get(path) never matches, so tasks 3.1 and 3.2 cannot go green. The gh pages verify flag is --dir (gh.py:1139), not --root_dir; root_dir is the tool parameter name. [C9]
  4. Claims about ai_ast_graph and a read path left open (major). The proposal and the spec scenario say the command "writes its graph under the data directory". ai_ast.py:113-122: with no --output it prints to stdout and writes nothing. The tool also keeps target_dir (a read path the model chooses, ai_ast.py:99); task 3.2 leaves it published, with no confinement, so the plan breaks its own audit and rule 11. [C2, C4]
  5. Two registries, and an undefined root (major). Decision 1 says _PATH_PARAM_RESTRICTIONS is the one place; decision 2 adds PATH_CONFINEMENTS in a new module. The issue chose to extend _PATH_PARAM_RESTRICTIONS (Key question 4); the plan does not say why it departs, and its "second registry" rejection rests on the false roles.py claim. The shape differs between files: the design keys by "command path and parameter name, with the server root", task 1.2 maps a path tuple to parameter names only, and task 2.2 passes "the root of the server" without naming it. find_repo_root (core/repo.py:40) and data.dir (settings.py:1197) exist; which one applies in the server pod is not stated. [C12 design rationale]
  6. Neighbours missed (major). tests/ai/mcp/test_mcp_tool_secrets.py (feat(security): refuse a secret value as an MCP tool parameter #3232, rule 12) already does this audit: _takes_text, mcp._list_tools(), an allow-list with a reason of at least 30 characters, and a test for a stale entry. validate_path_parameter and _PATH_PARAM_KEYWORDS are in core/paths.py:106,158; the plan imports the private tuple and builds tools through _create_tool_function. Reuse the pattern and the public helper. [C3]
  7. Feasibility is partly intent, and cites tool calls that did not happen (major). The last bullet is future tense ("First checks ... --help lists"), and the two commands in it fail (finding 3). The bullets quote search_code and read_file results, while the stage comment says "The model made no tool call". Quote command output or file lines that were read. [C2]
  8. Group 5 and the docs (minor). docs/MCP_TOOLS.md is generated (docs/generator.py:1345), so the hand edit and the note in 5.1 are lost by the regeneration in 5.2; 5.2 starts with a bare filename and the group has two verifies. No task updates SECURITY.md rule 11 to name the new registry and test, as rule 12 does for its test (AGENTS.md rule 8). [C5, C10]
  9. Dependencies and the refusal text (minor). There is no Dependencies section. feat(mcp): serve role-scoped tool sets over authenticated HTTP #3219 and feat(mcp): serve role-scoped tools over streamable HTTP #3233 are merged; fix(mcp): pr_check_readiness is read-only in the exposure table but can resolve threads #3235 (open) changes the read-only flags of the same exposure table that the audit reads; feat(k8s): deploy the MCP server for the roadmap jobs #3220 and feat(roadmap): let a job call the tools of the MCP server #3221 (open) are the consumers. A search for 3236 found no other open pull request that edits this code. safe_resolve_subpath puts the absolute base directory in its error (paths.py, "escapes base directory '{base}'"); a tool error goes to the model, so the spec should require a message with no server path. [C8]

Better than the earlier plans:

  • Verify commands start with uv run devops ci test / ci docs, and the new test is in the mirror folder tests/ai/mcp/test_path_confinement.py.
  • ## Criteria maps both issue criteria to groups; the title summary is 40 characters with no ...; the body is 651 characters with Plans # and Change:; the spec delta uses ADDED with a Purpose.
  • Rejected alternatives quote code facts, and Existing Tool Considered has tokens and time.

Related issues: #3235 (exposure table flags), #3221 and #3220 (jobs that call the role server). Known gap, not a finding: body_problems asks for Closes and refuses a plan body.

Verdict: hold until findings 1 to 4 are fixed (scope chosen and stated, the premise re-read at the base, real command keys, a registry shape with a named root), and 5 to 7 are answered.


Generated by Claude Code

@dan-petty

Copy link
Copy Markdown
Owner

Thank you for the detailed review. I updated the change plan to address all nine findings:

  1. Audit Scope and Catalogue Allow-list: Chosen full catalogue scope for exposed tools via mcp._list_tools(). Added CONST_MCP_PATH_PARAMETER_ALLOWLIST in constants.py with explanatory reasons of at least 30 characters and stale entry checks, paired with a dedicated role test in tests/ai/mcp/test_mcp_roles.py.
  2. Premise on Role Tables and Transports: Clarified that _JOB_ROLE_TOOLS in src/devops_cli/ai/mcp/roles.py already excludes unconfined file paths (security_intel_network.target is an IP/host). The plan explicitly protects sse and stdio transports where the full catalogue is reachable.
  3. Correct Command Paths and Flags: Updated tuples to ("ai", "ast", "graph"), ("gh", "pages", "verify"), and ("k8s", "security-stream"). Corrected the CLI flag for gh pages verify to --dir.
  4. ai_ast_graph Execution and Read Path Confinement: Corrected the behavior description: without --output, ai_ast_graph prints to stdout and writes nothing. Removed output_path from publication and confined target_dir to the repository root.
  5. Single Registry Architecture: Unified publication and path confinement into _PATH_PARAM_RESTRICTIONS in src/devops_cli/ai/mcp/generator.py. Defined roots as repository root (find_repo_root() or working directory) and settings.data.dir.
  6. Reused Established Patterns: Followed test_mcp_tool_secrets.py using _takes_text, mcp._list_tools(), and public helper validate_path_parameter.
  7. Factual Feasibility: Rewrote Feasibility in present and past tense with verified code citations and tested command outputs.
  8. Automated Documentation and Security Policy: Replaced manual edits of docs/MCP_TOOLS.md with uv run devops docs generate --sync-readme. Updated tasks to modify SECURITY.md rule 11.
  9. Dependencies and Error Sanitization: Added ## Order and Dependencies section referencing feat(mcp): serve role-scoped tool sets over authenticated HTTP #3219, feat(mcp): serve role-scoped tools over streamable HTTP #3233, fix(mcp): pr_check_readiness is read-only in the exposure table but can resolve threads #3235, feat(k8s): deploy the MCP server for the roadmap jobs #3220, and feat(roadmap): let a job call the tools of the MCP server #3221. Required that path traversal refusal messages omit the absolute server root path.

@dan-petty
dan-petty force-pushed the fix/3236-read-only-tools-take-paths-that branch from 169c130 to 4c03b69 Compare November 2, 2026 23:26
@dan-petty
dan-petty merged commit b1a6c8e into main Nov 2, 2026
19 checks passed
@dan-petty
dan-petty deleted the fix/3236-read-only-tools-take-paths-that branch November 2, 2026 23:40
dan-petty added a commit that referenced this pull request Nov 3, 2026
Plans #3236

The merged plan of #3248 scoped the audit to three tools that no role
table holds. It named commands that do not exist, said `ai ast graph`
writes to the data directory, and said `roles.py` was absent from the
base. This change audits the job-role tools, confines `target_dir` and
`root_dir`, drops two output options, and names #3300 for the other 60
tools of the ops role.

Change: `openspec/changes/3236-read-only-tools-take-paths-that/`
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