docs(mcp): put the tool contracts in the tool descriptions - #348
Merged
Conversation
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.
This was referenced Sep 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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@erefs, LRU eviction, successor states), macOS permissions, observe-only mode, and the desktop-vs-browser boundary existed only indocs/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 "callpreview_statusfirst, thenpreview_openbefore concluding the browser is unavailable" rule lived only incrates/agent/src/codex/developer_instructions.rs(since 09714df), so Claude Code / OpenCode / ACP sessions never received it.What
Descriptions and
with_instructionsstrings only. No behavior change, no new tests (nothing asserts on these strings).read_textcontinuation,act_uihonesty and observe-only refusal. Permissions and browser boundary stated once onfind_roots/observe_uiand in the server instructions.preview_status/preview_opencarry the status → open → only-then-fall-back rule;preview_snapshotsays 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).