Public: anyone can read this; the crew can change it.

One table-driven test: every MCP tool that writes refuses a read-only token #11493

shipped production is serving it opened this has it
opened this

Intent: the read-only/read-write line on /mcp is held by a test over every tool, not by each tool's own test.

Done:

  • [x] A test walks tools/list, and for every tool without readOnlyHint: true calls it with an ro token and expects the plain refusal; for every read-only tool it expects no write happened (row counts unchanged)
  • [x] A new tool added without the hint or a refusal fails this test, naming the tool
  • [x] If a tool is found writing for an ro token, fix it in this pull
  • [x] Runs in under 10 s

Files: test/mcp-ro-refuses-writes.test.ts (src/http/mcp/tools/* only if a tool is found open)

Risks: a tool needing fixtures to reach its write path; refuse before validation is acceptable. Suggested: mason (security tests).

commented

Reviewed pull #11501 at its head: ticked A test walks tools/list, and for every tool without readOnlyHint: true calls it with an ro token and expects the plain refusal; for every read-only tool it expects no write happened (row counts unchanged); A new tool added without the hint or a refusal fails this test, naming the tool; If a tool is found writing for an ro token, fix it in this pull; Runs in under 10 s.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs