Skip to content

docs(mcp): put the tool contracts in the tool descriptions - #348

Merged
Tryanks merged 1 commit into
mainfrom
mcp-tool-contracts
Sep 7, 2026
Merged

docs(mcp): put the tool contracts in the tool descriptions#348
Tryanks merged 1 commit into
mainfrom
mcp-tool-contracts

Conversation

@Tryanks

@Tryanks Tryanks commented Sep 7, 2026

Copy link
Copy Markdown
Owner

Why

Two findings, both verified against main:

  • crates/computer-use-mcp/src/tools.rs: all 8 tool descriptions were one sentence since the server landed in feat: pi-computer-use-style desktop computer use for all providers #77. State lifecycle (state-scoped @e refs, LRU eviction, successor states), macOS permissions, observe-only mode, and the desktop-vs-browser boundary existed only in docs/computer-use.md, which the model never sees. Runtime errors like "state was evicted; call observe_ui again" were the only way to learn the rules.
  • crates/preview-mcp/src/tools.rs: the "call preview_status first, then preview_open before concluding the browser is unavailable" rule lived only in crates/agent/src/codex/developer_instructions.rs (since 09714df), so Claude Code / OpenCode / ACP sessions never received it.

What

Descriptions and with_instructions strings only. No behavior change, no new tests (nothing asserts on these strings).

  • computer-use: each tool now states its place in the workflow, the same-state rule for refs, successor state ids, bounded output / read_text continuation, act_ui honesty and observe-only refusal. Permissions and browser boundary stated once on find_roots/observe_ui and in the server instructions.
  • preview: preview_status / preview_open carry the status → open → only-then-fall-back rule; preview_snapshot says to prefer its locators over coordinates; server instructions carry the same rule in one sentence.

Codex developer instructions left as-is.

Checks

cargo fmt --all, cargo check -p computer-use-mcp -p preview-mcp, cargo test -p computer-use-mcp -p preview-mcp (34 + 4 pass).

Computer-use and preview tool descriptions were single sentences since
their introduction (#77, 092a12c). The state-lifecycle, permission,
observe-only and browser-boundary rules lived only in docs/computer-use.md,
and the preview_status -> preview_open workflow lived only in the Codex
developer instructions, so Claude Code sessions never saw either; runtime
errors were the model's only teacher.

Move those rules into the #[tool] descriptions and the server
instructions. No behavior change.
@Tryanks
Tryanks merged commit e21ec40 into main Sep 7, 2026
5 checks passed
@Tryanks
Tryanks deleted the mcp-tool-contracts branch September 7, 2026 03:15
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