Add structured MCP balance result#885
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds structured result support to MCP tools. MCPTextResult type is defined alongside updated type aliases for tool results and handlers, _tool_result_response is extended to format MCPTextResult into JSON-RPC responses carrying text and structuredContent, get_balance tool is updated to return structured account and balance data, and tests are updated to validate the new structure. ChangesStructured MCP tool results
Possibly related issues
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 |
mauricemohr88-debug
left a comment
There was a problem hiding this comment.
Reviewed current head bc3475bfe19048c34f146d644952117a3f8a2707.
Approved. I inspected app/mcp.py, app/mcp_tools.py, and tests/test_api_mcp.py and verified this is a focused MCP balance-response improvement:
- the new frozen
MCPTextResultkeeps the existing human-readablecontent[0].textresponse while allowing explicitstructuredContentfor tools that should not parse balance strings; _tool_result_response()handlesMCPTextResultbefore the legacydictandstrpaths, so existing structured JSON and text responses remain intact;get_balancestill normalizes the requested account and still formats balances viaformat_mrwk(get_balance(...));- the added structured payload contains only the normalized account and formatted MRWK balance, with coverage for treasury, wallet-address, and GitHub-login account paths;
- no wallet registration, transfer signing, ledger mutation, payout/proof execution, treasury mutation, proposal execution, admin-token API, bridge, exchange, cash-out, MRWK price, private-data, or secret-handling behavior is changed.
Validation on this exact head:
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_wallet_account_views_normalize_mixed_case_addresses tests/test_api_mcp.py::test_github_account_views_normalize_mixed_case_logins tests/test_api_mcp.py tests/test_mcp_tools.py -q-> 112 passed, 1 existing Starlette/httpx warning.uv run --python 3.12 --extra dev ruff check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py tests/test_mcp_tools.py-> passed.uv run --python 3.12 --extra dev ruff format --check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py tests/test_mcp_tools.py-> 4 files already formatted.uv run --python 3.12 --extra dev mypy app/mcp.py 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 treeb5224fd2e5b933b84054aff7a5127590cbcfe5f6.
GitHub state checked before approval: mergeStateStatus=CLEAN; hosted Quality, readiness, docs, and image checks and CodeRabbit statuses are successful on this head. I found no prior human review and no existing #838 claim for PR #885 / this head before posting this review.
Summary
structuredContent.get_balanceto keep the existing text response (account: X MRWK) and add structured{account, balance_mrwk}output for agents.Bounty #844
Evidence
This is a focused MCP structured-response usability improvement:
tools/listinput schemas;submit_work_proofargument/schema behavior;Validation
uv run --extra dev python -m pytest tests/test_api_mcp.py::test_mcp_tools_list_and_call tests/test_api_mcp.py::test_wallet_account_views_normalize_mixed_case_addresses tests/test_api_mcp.py::test_github_account_views_normalize_mixed_case_logins -q->3 passed, 1 existing Starlette/httpx warninguv run --extra dev python -m pytest tests/test_api_mcp.py tests/test_mcp_tools.py -q->112 passed, 1 existing Starlette/httpx warninguv run --extra dev ruff check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py-> passeduv run --extra dev ruff format --check app/mcp.py app/mcp_tools.py tests/test_api_mcp.py->3 files already formatteduv run --extra dev mypy app/mcp.py app/mcp_tools.py-> successgit diff --check origin/main...HEAD-> cleangit merge-tree --write-tree origin/main HEAD-> clean treeabda6f4c7b8cc6d19c1ef4bc0fd2711b121cfce1Scope
MCP response formatting and tests only. No private data, credentials, wallet material, payout/proof/ledger execution, exchange/bridge/cash-out, price behavior, or fabricated payout claims.
Summary by CodeRabbit