Add structured MCP balance responses#990
Conversation
📝 WalkthroughWalkthroughThis PR adds structured content support to MCP tool results by introducing an ChangesMCP Structured Results
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 |
elianguitarra
left a comment
There was a problem hiding this comment.
Reviewed current head 1c390e3.
Approved. I inspected the MCP response path for get_balance and verified this keeps the legacy text content while adding explicit structuredContent for balance consumers:
- MCPTextResult is handled before the existing dict/string result branches, so current JSON-object tools and text-only tools keep their behavior.
- get_balance still normalizes the requested account and uses format_mrwk(get_balance(...)); the new structured payload mirrors the same normalized account and balance source.
- The added docs update the existing guidance to stop treating balances as text-only, and the test now asserts account, balance_mrwk, and balance_microunits on the MCP response.
- This overlaps with older PR #885, but #885 is currently DIRTY and has a changes-requested review for its conflict with current main. This PR is clean against current origin/main.
Validation on this exact head:
- ..venv\Scripts\python.exe -m pytest tests\test_api_mcp.py tests\test_mcp_tools.py -> 131 passed, 1 existing Starlette/httpx warning.
- ..venv\Scripts\python.exe scripts\docs_smoke.py -> docs smoke ok.
- ..venv\Scripts\python.exe -m ruff check app\mcp.py app\mcp_tools.py app\mcp_results.py tests\test_api_mcp.py -> passed.
- ..venv\Scripts\python.exe -m ruff format --check app\mcp.py app\mcp_tools.py app\mcp_results.py tests\test_api_mcp.py -> 4 files already formatted.
- ..venv\Scripts\python.exe -m mypy app\mcp.py app\mcp_tools.py app\mcp_results.py -> success.
- git merge-tree --write-tree origin/main HEAD -> clean tree 13b068e3cc7449f379fbbbb0e054bc45367f4ff5.
Scope reviewed: MCP tool result serialization, get_balance structured output, docs, and tests. I did not exercise or rely on wallet registration/signing, ledger mutation beyond test fixtures, treasury/proposal execution, payout execution, admin-token behavior, private data, bridge/exchange/cash-out behavior, or MRWK price behavior.
Summary
get_balancetext output while addingstructuredContentwith normalized account,balance_mrwk, andbalance_microunits.Bounty
Bounty #934
Evidence
get_balancepreviously returned only human-readable text, forcing tool callers to parse strings for account and balance values.Validation
.\.venv\Scripts\python.exe -m pytest tests\test_api_mcp.py tests\test_mcp_tools.py.\.venv\Scripts\python.exe scripts\docs_smoke.py.\.venv\Scripts\python.exe -m ruff check app\mcp.py app\mcp_tools.py app\mcp_results.py tests\test_api_mcp.py.\.venv\Scripts\python.exe -m ruff format --check app\mcp.py app\mcp_tools.py app\mcp_results.py tests\test_api_mcp.py.\.venv\Scripts\python.exe -m mypy app\mcp.py app\mcp_tools.py app\mcp_results.py.\.venv\Scripts\python.exe -m py_compile app\mcp.py app\mcp_tools.py app\mcp_results.pygit diff --cached --check