Accept API field aliases in MCP lookups#893
Conversation
📝 WalkthroughWalkthroughAdds exclusive dual-selector parsing for MCP tool inputs: ChangesMCP selector normalization
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 |
8a29e00 to
11e6f9e
Compare
11e6f9e to
8b653b3
Compare
8b653b3 to
4903348
Compare
mauricemohr88-debug
left a comment
There was a problem hiding this comment.
Current-head review for #838 on 49033480f40c091c7cec2ae5a2fab88d0da708a9.
Evidence checked:
- Inspected
app/mcp_tools.py;get_proofnow acceptshashorproof_hash, andget_ledger_entrynow acceptssequenceorledger_sequence, while mixed selectors still raise before lookup. - Verified the aliases are read through the existing validators (
str_arg,proof_hash_from_path, andpositive_int_arg), so malformed hashes, non-positive ledger sequences, and wrong types continue to be rejected by the same paths. - Inspected
app/mcp.pyanddocs/api-examples.md; the tool descriptions and MCP examples now mention the aliases without changing response shapes. - Inspected
tests/test_api_mcp.py; coverage checkstools/listdescriptions, alias parity with canonical selectors, and mixed-selector rejection for both tools. - Ran
uv run --python 3.12 --extra dev python -m pytest tests/test_api_mcp.py::test_mcp_tools_list_and_call tests/test_api_mcp.py::test_mcp_get_ledger_entry_includes_payment_proof_hash tests/test_api_mcp.py::test_mcp_get_ledger_entry_rejects_mixed_sequence_selectors tests/test_api_mcp.py::test_mcp_get_proof_returns_public_proof_details tests/test_api_mcp.py::test_mcp_get_proof_rejects_mixed_hash_selectors -q: 5 passed, 1 existing Starlette warning. - Ran
uv run --python 3.12 --extra dev python -m pytest tests/test_api_mcp.py tests/test_mcp_tools.py -q: 114 passed, 1 existing warning. - Ran
uv run --python 3.12 --extra dev ruff check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py: passed. - Ran
uv run --python 3.12 --extra dev ruff format --check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py: 3 files already formatted. - Ran
uv run --python 3.12 --extra dev mypy app/mcp_tools.py app/mcp.py: success. - Ran
uv run --python 3.12 --extra dev python scripts/docs_smoke.py: docs smoke ok. - Ran
git diff --check origin/main...HEADandgit merge-tree --write-tree origin/main HEAD: clean.
No blocker found. The change is a narrow MCP usability improvement that maps public API field names onto existing lookup validators without mutating ledger, proof, treasury, wallet, or payout behavior.
Summary
Bounty #844 MCP usability follow-up.
This PR lets MCP lookup tools accept the same field names agents receive from public API payloads and exposes those aliases in
tools/listdescriptions:get_proofkeepshashand also acceptsproof_hash.get_ledger_entrykeepssequenceand also acceptsledger_sequence.Agents commonly receive
proof_hashandledger_sequencefrom/api/v1/activity,/api/v1/ledger,get_bountyaward rows,get_proof, andget_ledger_entry. Accepting these aliases avoids predictable-32602 invalid tool argumentsdead ends without changing response shapes.Live behavior checked before the fix
Against
https://mcp.mrwk.online/mcpusing public proof/ledger values from/api/v1/activity:get_proofwitharguments.hashreturned the proof payload successfully.get_proofwith the same value underarguments.proof_hashreturned-32602 invalid tool arguments.get_ledger_entrywitharguments.sequencereturned the ledger-entry payload successfully.get_ledger_entrywith the same value underarguments.ledger_sequencereturned-32602 invalid tool arguments.Validation
uv run --python 3.12 --extra dev python -m pytest tests/test_api_mcp.py::test_mcp_tools_list_and_call tests/test_api_mcp.py::test_mcp_get_ledger_entry_includes_payment_proof_hash tests/test_api_mcp.py::test_mcp_get_ledger_entry_rejects_mixed_sequence_selectors tests/test_api_mcp.py::test_mcp_get_proof_returns_public_proof_details tests/test_api_mcp.py::test_mcp_get_proof_rejects_mixed_hash_selectors -q-> 5 passed, 1 existing warninguv run --python 3.12 --extra dev python -m pytest tests/test_api_mcp.py tests/test_mcp_tools.py -q-> 114 passed, 1 existing warninguv run --python 3.12 --extra dev ruff check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py-> passeduv run --python 3.12 --extra dev ruff format --check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py-> passeduv run --python 3.12 --extra dev mypy app/mcp_tools.py app/mcp.py-> successuv run --python 3.12 --extra dev python scripts/docs_smoke.py-> docs smoke okgit diff --check origin/main...HEAD-> cleangit merge-tree --write-tree origin/main HEAD-> clean treee89a80c362f20dcd98aaf41cfad383b6c7b44f72Scope
Focused MCP selector usability and tool descriptions only. No proof payload shape, ledger-entry response shape, ledger mutation, payout execution, wallet behavior, treasury behavior, admin-token behavior, private data, bridge, exchange, cash-out, or MRWK price behavior is changed.
Summary by CodeRabbit
New Features
hashorproof_hashfor proofs, and eithersequenceorledger_sequencefor ledger entries; requests providing both alternatives are rejected.Documentation
Tests