Skip to content

fix(mcp): refuse arguments a tool doesn't take instead of dropping them - #160

Closed
Derrors wants to merge 1 commit into
mainfrom
fix/mcp-reject-unknown-arguments
Closed

Derrors wants to merge 1 commit into
mainfrom
fix/mcp-reject-unknown-arguments

Conversation

@Derrors

@Derrors Derrors commented Nov 18, 2026

Copy link
Copy Markdown
Owner

Part of #158.

Why

to_request read the arguments it knew and silently dropped the rest. A misspelt argument, or one from a newer version, ran the call with the default and reported success. That is how iphone_wait_for {"state": "disappeared"} answered "appeared" in 0.31 s in #158: state didn't exist, so it waited for the text to appear, and it was already on screen.

What

  • Every MCP call is checked against its tool's own input schema before anything is done. The error names the unknown argument and lists the ones the tool takes:
    iphone_wait_for 没有参数 state,什么都没做;它的参数:text、timeout
  • then/then_filter/then_region/then_settle are only accepted where the schema lists them (action tools and iphone_batch).
  • iphone_batch steps are checked the same way, before any step runs. then inside a step is refused (the batch's own then applies), and wait takes only seconds.
  • The developer tools and iphone_confirm are checked against their own schemas. A tool name this server doesn't know is left to the existing "unknown tool" error.
  • The schema is the single source of truth: no separate list to keep in sync. I checked that every name to_request reads is declared in its tool's schema.

This is a behavior change for callers that passed extra arguments, so it's listed under Upgrade notes in both changelogs.

Tests

  • cargo test --workspace --all-features --locked, cargo clippy … -D warnings and cargo fmt --check pass. New tests: unknown_arguments_are_refused, batch_steps_refuse_unknown_arguments.
  • Real device: iPhone19,7, iOS 27.2.1, native control, with this branch's MCP server (MCP_CMD=target/release/iphone-control mcp):
### before
=== iphone_type_text {"text": "a", "sumbit": true} 0.18s ERROR
屏幕上没有键盘(没有输入框获得焦点),什么都没输;…        ← sumbit dropped; with a keyboard up it would have typed
### after
=== iphone_wait_for {"text": "飞行模式", "state": "disappeared", "timeout": 2} 0.00s ERROR
iphone_wait_for 没有参数 state,什么都没做;它的参数:text、timeout
=== iphone_type_text {"text": "a", "sumbit": true} 0.00s ERROR
iphone_type_text 没有参数 sumbit,什么都没做;它的参数:submit、text、then、then_filter、then_region、then_settle

#159 adds state to iphone_wait_for. Whichever of the two merges second needs a trivial rebase. With both merged, state passes this check because it's in the schema.

🤖 Generated with Claude Code

An argument a tool doesn't list in its input schema was ignored: a call
with a misspelt name, or with an argument from a newer version, ran with
the default and reported success. iphone_wait_for with
state: "disappeared" answered that the text had appeared (#158).

Each call is now checked against its tool's input schema before anything
is done, and the error names the arguments the tool takes. A batch's
steps are checked the same way; then in a step is refused (the batch's
own then applies), and wait takes only seconds. The developer tools and
iphone_confirm are checked against their own schemas.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors

Derrors commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

Folded into #159 instead (one PR for #158). The same commit will land on that branch.

@Derrors Derrors closed this Nov 18, 2026
@Derrors
Derrors deleted the fix/mcp-reject-unknown-arguments branch November 18, 2026 16:19
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