Skip to content

fix(mcp): tools that write local state are flagged read-only #3642

Closed

Description

@dan-petty

Problem

Some MCP tools write local state or a file, and the exposure table marks them read-only. A role server and a client choose tools by that flag. A model can get a write that the flag says it cannot make.

The tools, at origin/main commit 2db71f2:

  • ai_quiesce sets the constellation quiesce flag in a snapshot file.
  • ai_resume clears that flag.
  • ai_failover records a fallback route in that flag.
  • ai_gateway_failover: --reset and --no-simulate write the gateway state file (_save_gateway_state in src/devops_cli/ai/gateway.py).
  • review_export_feedback appends review verdicts to the feedback dataset file.

The flag cannot change today. Each of the five commands has the dry-run class no-external-request. The requirement mcp-read-only-hint-agrees-with-no-external-request in openspec/specs/command-dry-run-class/spec.md says that such a tool has readOnlyHint true. The test test_mcp_exposure_table_no_external_request_read_only in tests/invariants/test_dry_run_class_ratchet.py fails on a tool that is not read-only. The class says that the command makes no external request. It does not say that the command writes nothing.

The review of #3235 found these tools. That change flags the tools that its verb rule and its review found, and it cannot flag these five without a decision on the requirement.

Expected

Decide what the class means for the flag. Then make the requirement, the ratchet test and the table agree.

A recommended answer: the class names external requests only. The ratchet then allows a tool that is not read-only for a command that writes local state. The five tools are marked not read-only.

Acceptance criteria

  1. The requirement and the ratchet test state what a no-external-request command means for readOnlyHint.
  2. ai_quiesce, ai_resume, ai_failover, ai_gateway_failover and review_export_feedback are not read-only, or the requirement says why one is.
  3. A test fails when one of these tools is flagged read-only against the rule of criterion 1.

Existing tool considered

None. The change edits one table, one requirement and one test of this repository.

Related

Related: #3235, #3480.

Source: #3235

Proposed design

Problem statement

The MCP exposure table marks five tools read-only although their commands write local state or a file. A role server and a client use readOnlyHint to choose tools, so a model can make a write that the flag says it cannot. The no-external-request dry-run class currently implies readOnlyHint true, so the table, the requirement and the ratchet test disagree.

Acceptance criteria

Requirement: no-external-request-scope

The no-external-request dry-run class SHALL state that it constrains external requests only and does not state that the command writes nothing.

Scenario: spec states the class scope

  • WHEN a test reads the no-external-request requirement in openspec/specs/command-dry-run-class/spec.md
  • THEN the requirement says the class constrains external requests only and does not imply readOnlyHint

Requirement: local-write-tools-are-not-read-only

The MCP exposure table and docs/MCP_TOOLS.md SHALL set readOnlyHint false for ai_quiesce, ai_resume, ai_failover, ai_gateway_failover and review_export_feedback.

Scenario: five local-write tools are not read-only

  • WHEN a test reads CONST_MCP_EXPOSURE_TABLE and docs/MCP_TOOLS.md for the five tool names
  • THEN each MCP entry has readOnlyHint false and each documentation row shows false

Requirement: ratchet-rejects-read-only-local-writer

The MCP exposure ratchet test SHALL fail when a command that writes local state or a file is marked read-only.

Scenario: local-write tool marked read-only fails

  • WHEN the test fixture flags the MCP entry of any one of the five local-write commands as read-only
  • THEN the ratchet test reports a mismatch for that command

Requirement: ratchet-keeps-read-only-non-writer

The MCP exposure ratchet test SHALL keep readOnlyHint true for a no-external-request command that writes no local state or file.

Scenario: non-writer marked not read-only fails

  • WHEN the test fixture marks a no-external-request command outside the local-write set as not read-only
  • THEN the ratchet test reports a mismatch for that command

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers the need: the change edits the repository's MCP exposure table, the dry-run-class requirement and the ratchet test. It builds no new code, so the cost to build, keep and fix code is zero tokens and zero elapsed time.

Key questions

  • What does the no-external-request dry-run class mean for readOnlyHint?: The class constrains external requests only. It does not say that the command writes nothing. readOnlyHint follows the command's local write behavior. (best practice) [sources: openspec/specs/command-dry-run-class/spec.md, tests/invariants/test_dry_run_class_ratchet.py, src/devops_cli/ai/gateway.py]
    • Rejected: Class implies read-only true. Rejected: five commands write local state and the current rule marks them read-only.
    • Chosen: Class constrains external requests only and readOnlyHint follows local writes. Chosen: the class name matches the rule and the flag becomes truthful.
    • Rejected: Add a separate dry-run class for local writes. Rejected: it changes the decorator and every command callback beyond this issue.
  • Which five MCP tools must be not read-only?: ai_quiesce, ai_resume, ai_failover, ai_gateway_failover and review_export_feedback must set readOnlyHint false. [sources: docs/MCP_TOOLS.md:16, docs/MCP_TOOLS.md:17, docs/MCP_TOOLS.md:27, src/devops_cli/ai/gateway.py, tests/ai/mcp/test_fastmcp_contracts.py, openspec/specs/command-dry-run-class/spec.md]
  • How should the ratchet test know which commands write local state?: Use an explicit set of the five local-write command paths in the test. Assert that their MCP entries are not read-only, and that every other no-external-request entry is read-only. (best practice) [sources: tests/invariants/test_dry_run_class_ratchet.py, src/devops_cli/ai/gateway.py, openspec/specs/command-dry-run-class/spec.md]
    • Chosen: Explicit local-write set in the test. Chosen: it is the smallest change, names the known writers and keeps the ratchet deterministic.
    • Rejected: Add a write flag to the dry-run decorator. Rejected: it changes every command callback and the decorator for a table defect.
    • Rejected: Infer writes by reading command source. Rejected: source inspection is brittle and cannot prove that a command writes nothing.
  • Should docs/MCP_TOOLS.md change with the exposure table?: Yes. docs/MCP_TOOLS.md must show the five local-write tools as not read-only so the public table matches the exposure table. (best practice) [sources: docs/MCP_TOOLS.md, tests/invariants/test_dry_run_class_ratchet.py]
    • Chosen: Update the documentation table. Chosen: the documentation currently shows true for these tools and would contradict the fixed table.
    • Rejected: Leave the documentation table unchanged. Rejected: the public table would still say the five tools are read-only.

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Alternatives check of 2026-11-07: none.
Tool: none found.

Activity

  1. added
    source/agent
    on Nov 5, 2026
  2. added
    type/bug
    scope/mcp
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  3. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/mcp. The (mcp) scope of the title gives the scope.
    • Priority: P2-Medium. The mislabeled flag misleads tool selection but does not block a user or expose a vulnerability.
    • Value: Medium. Correct flags let a model and client choose tools by their true write capability.
    • Effort: Low. The change edits one table, one requirement, and one test.
    • Related: feat(ai): local ai commands declare that they make no external request #2247, which asks for a different change. Both reference the no-external-request class, but #2247 assigns the class to commands while this candidate fixes what the class means for readOnlyHint.
  4. added
    priority/p2-medium
    on Nov 5, 2026
  5. added
    status/ready
    and removed
    status/new
    on Nov 6, 2026
  6. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at cda72c7 (see proposed design in issue body).

  7. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The web searches returned no results (the provider did not answer), and the need is a repository-internal correction: the MCP exposure table, the no-external-request requirement in openspec/specs/command-dry-run-class/spec.md and the ratchet test in tests/invariants/test_dry_run_class_ratchet.py must agree on what readOnlyHint means for commands that write local state. No open, maintained tool or library performs that change, and the issue itself records that no existing tool was found; the ADRs in force cover roadmap, CI and sandbox topics and name no MCP tooling that would settle the flag's meaning.

    Tool: none found

    Lacks:

    • A tool that derives or enforces the readOnlyHint value of this repository's MCP exposure table from each command's local write behaviour
    • A tool that rewrites the no-external-request requirement so it constrains external requests only
    • A tool that adds the ratchet assertion that a local-write command must not be read-only

    Searches run:

    • MCP readOnlyHint tool annotation specification meaning, results: 0
    • MCP tool exposure table read-only flag test library, results: 0
    • readOnlyHint MCP tool annotation, results: 0
    • model context protocol tool annotations readOnlyHint, results: 0
    • pytest invariant test MCP tool read-only flag, results: 0

    Checked on 2026-11-07. A person decides what this means for the item. The check changes no label and closes no issue.

  8. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 12, 2026
  9. removed
    status/in-review
    owner/agent
    on Nov 12, 2026
  10. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor
  11. devops-cli-service commented on Nov 12, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-12 07:00 UTC

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

    effort/lowpriority/p2-mediumscope/mcpsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions