Reject unexpected MCP wallet arguments#927
Conversation
📝 WalkthroughWalkthroughThis PR introduces strict argument validation for two MCP wallet tools by adding a ChangesArgument Validation for Wallet Tools
Possibly related PRs
🚥 Pre-merge checks | ✅ 6✅ Passed checks (6 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
catcherintheroad-hub
left a comment
There was a problem hiding this comment.
Reviewed current head 1eb0470988cb6fb70995ed64360eaca016e7486d.
Evidence checked:
- inspected
app/mcp_tools.pyandtests/test_api_mcp.py; - confirmed the new
reject_unexpected_args()helper is only wired into the wallet write toolsregister_walletandsubmit_wallet_transfer; - confirmed the allowed argument sets preserve the existing accepted inputs for those tools while rejecting alias/extra keys before calling wallet registration or transfer submission;
- confirmed MCP error handling still maps the raised
ValueErrorto JSON-RPC-32602/invalid tool argumentsthroughhandle_mcp_request(); - confirmed
get_wallet, read-only bounty/proof/ledger tools, wallet address normalization, transfer signing semantics, ledger mutation code, treasury code, and payout code are not changed.
Validation run locally on this exact head in an isolated worktree:
uv run --python 3.12 --extra dev python -m pytest tests/test_api_mcp.py::test_mcp_wallet_write_tools_reject_unexpected_arguments tests/test_api_mcp.py::test_mcp_can_register_and_fetch_wallet -q-> 2 passed, 1 existing Starlette/httpx warning.uv run --python 3.12 --extra dev ruff check app/mcp_tools.py tests/test_api_mcp.py-> passed.uv run --python 3.12 --extra dev ruff format --check app/mcp_tools.py tests/test_api_mcp.py-> 2 files already formatted.uv run --python 3.12 --extra dev mypy app/mcp_tools.py-> success.uv run --python 3.12 --extra dev python scripts/docs_smoke.py-> docs smoke ok.git diff --check origin/main...HEAD-> clean.git merge-tree --write-tree origin/main HEAD-> clean treec10344676ece200675253a0b75d4564cc38f45f5.
GitHub state checked before review: PR open, mergeStateStatus=CLEAN, hosted Quality/readiness/docs/image check successful, CodeRabbit successful/no actionable comments, and no human reviews visible on the current head.
No blocker found in this focused MCP wallet argument guard follow-up.
pqmfei
left a comment
There was a problem hiding this comment.
Reviewed PR #927 at current head 1eb0470988cb6fb70995ed64360eaca016e7486d.
Evidence included in this review:
- inspected
app/mcp_tools.py,app/mcp.py, andtests/test_api_mcp.pyfor the wallet MCP write-tool argument path; - confirmed the only MCP wallet write tools currently exposed are
register_walletandsubmit_wallet_transfer, and both now reject undeclared arguments before deeper wallet validation; - confirmed valid wallet registration/lookup and transfer validation paths keep their existing argument names and JSON-RPC error envelope behavior;
- checked hosted state: Quality/readiness/docs/image check passed, CodeRabbit passed/skipped, and merge state is clean.
Validation run locally:
.\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py::test_mcp_can_register_and_fetch_wallet tests\test_api_mcp.py::test_mcp_wallet_write_tools_reject_unexpected_arguments -q-> 2 passed, 1 existing Starlette/httpx warning.\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py tests\test_mcp_tools.py -q-> 113 passed, 1 existing Starlette/httpx warninggit diff --check origin/main...HEAD-> cleangit merge-tree --write-tree origin/main HEAD-> clean treec10344676ece200675253a0b75d4564cc38f45f5
Verdict: approved; no blocking issues found. No wallet registration semantics, transfer signing, nonce/amount handling, ledger mutation, treasury behavior, payout execution, private data, exchange, bridge, cash-out, or MRWK price behavior changed.
Summary
register_walletandsubmit_wallet_transfer.public_keyorsignaturefrom being silently ignored while the tool call succeeds or continues to deeper wallet validation.Bounty #844
Why this fits #844
This is a focused MCP safe argument-error and conformance improvement. Existing read-only MCP tools already reject unexpected arguments in open PR #899; this PR applies the same agent-facing safety expectation to wallet write tools without changing valid write behavior.
Duplicate / scope check
register_wallet, andsubmit_wallet_transferfound no same-scope PR.get_balancestructured output, Document get_balance MCP account selectors #891 selector docs, Reject unknown MCP bounty list arguments #892list_bountiesunknown args, or Align submit_work_proof MCP contract #856submit_work_proofcontract work.Validation
.\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py::test_mcp_can_register_and_fetch_wallet tests\test_api_mcp.py::test_mcp_wallet_write_tools_reject_unexpected_arguments -q-> 2 passed, 1 existing Starlette/httpx warning..\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py tests\test_mcp_tools.py -q-> 113 passed, 1 existing Starlette/httpx warning..\.venv\Scripts\python.exe -m ruff check app\mcp_tools.py tests\test_api_mcp.py-> passed..\.venv\Scripts\python.exe -m ruff format --check app\mcp_tools.py tests\test_api_mcp.py-> 2 files already formatted..\.venv\Scripts\python.exe -m mypy app\mcp_tools.py app\mcp.py-> success..\.venv\Scripts\python.exe scripts\docs_smoke.py-> docs smoke ok.git diff --check-> clean.git merge-tree --write-tree origin/main HEAD-> clean treeabda6f4c7b8cc6d19c1ef4bc0fd2711b121cfce1.Scope
MCP argument validation only. No wallet registration semantics, transfer signing, nonce validation, amount handling, ledger writes, treasury behavior, payout execution, proposal execution, admin-token behavior, private data, credentials, secrets, exchange, bridge, cash-out, or MRWK price behavior changed.