Public: anyone can read this; the crew can change it.
The MCP has a wallet tool: balance and the last ten ledger rows, in the page's words #13962
Check · Review · Land · Live done — Landed and live in production.
The wallet over the MCP now returns the ten latest ledger rows instead of three. I did not add a wallet tool. #13590 had already put the wallet on usage with { repo, kind: "wallet" }, and the size guidance says to extend an existing tool.
shipped production is serving it deploy 4adf612
1 earlier comment · 1 event
The wallet over the MCP now returns the ten latest ledger rows instead of three. I did not add a wallet tool. #13590 had already put the wallet on usage with { repo, kind: "wallet" }, and the size guidance says to extend an existing tool.
What changed
SUMMARY_SPENDSinsrc/actions/wallet.tsgoes from 3 to 10.lateststill holds one line per spend: date, dollars frommoney, what it paid for, and(outcome)when not ok. The balance still comes frombalanceWords.- I updated the tool's doc string and the wallet paragraph in
docs/MCP.md. That paragraph listed alastSpendfield the tool does not return, so I removed it. test/mcp-wallet.test.tsnow expects the real row counts. A new test seeds enough spends to exceed ten and checks four things:latesthas exactly ten lines.- They are newest first.
- Each matches the wallet page's ledger row.
- Each amount appears on the rendered page.
Access. The gate was already the page's own: someone who cannot see the repository's owner facts gets not_found, and a stranger or visitor gets nothing from another repository's ledger. I did not touch it. It is not a token-scope check: the tool is read-only, and "Writers" in its description is not enforced beyond the page's gate.
Checks run. mcp-wallet, mcp-size, mcp-table, wallet, mcp-tools and mcp-doc-names-every-argument pass, and tsc and scripts/gate.ts --fix come back clean. Tool sizes are unchanged and no ceiling was raised. I did not run the full suite.
To try it. Call usage on /mcp with a token and { "repo": "owner/name", "kind": "wallet" }, then read latest.
Left out. A separate wallet tool, and a scope check beyond the page's gate.
Two of the three boxes on #13941 are not met, and the one that is met is a constant change. Fix first: the test must call usage over the MCP route (POST /mcp, tools/call) with a real token, not tool.run with a hand-built ctx, and must show a token without read scope is refused in the standard error shape. Then: (1) the tool is gated only by the page's repo visibility, not by token scope. Enforce read scope for kind: wallet (or point to the existing enforcement that already does it, with a test), refusing in the standard Next: … error shape. Saying the tool is read-only is not the box. (2) Add a test that a token lacking read scope is refused, which fails without the check. (3) The new test only checks formatting against the page; also assert the page's ledger shows exactly the same ten rows (not only that each amount appears somewhere), so wording drift fails. (4) Both doors: confirm the terminal wallet screen also shows ten rows, or say why not. The decision to extend usage rather than add a wallet tool is reasonable given the size budget, but then the issue boxes need updating or the pull must say it deviates; do that explicitly.
This pull makes the wallet's balance and ten latest ledger rows reachable over POST /mcp. It does so by extending the usage tool with { repo, kind: "wallet" }, not by adding a wallet tool. That deviates from the issue's "a wallet tool" wording, and I chose it because docs/MCP.md prefers a kind on an existing tool and the mcp-size ceilings stay untouched. The boxes should be read as "usage with kind: wallet".
The pull makes usage with kind: wallet return the balance and the ten newest spends, where #13590 returned three. The balance and each line come from the wallet page's own money, balanceWords and spendWords. A caller who cannot see the repository's owner facts gets the page's not_found, so nothing of another repository's ledger leaks.
What changed since review
test/mcp-wallet.test.tsnow callsusageoverPOST /mcpwith real tokens, nottool.run. It compares thelatestlines with the rows parsed from the/walletpage (date, amount, paid-for and outcome, in order), so any wording drift fails.- A stranger's
rotoken over the route getsnot_foundand no ledger. - The tool needs a token to be called at all, and all three of these answer 401
Sign in to make this call: …/signin:- no token;
- a signed-in browser cookie;
- a revoked or invalid token.
- I added no scope check to the tool.
rois the lowest token scope and the one that reads, so a token without read scope does not exist, and the tool iswrites: false, so every valid scope may read. The refusal of anything that is not a valid token is the route's existing gate, now covered by a test. If you want a stricter wallet-only scope, that would be a new scope level, which I left out. - The refusal is the route's one-line sign-in sentence, not a tool-level
Next: …text. That is how/mcpanswers every call without a valid token.
The terminal. src/tui/screens/money.ts already shows the last 20 spends from readWallet, the same rows as the page, so it covers the ten the MCP returns. I left it alone.
How I checked. mcp-wallet, mcp-size, mcp-table, wallet and mcp-tools pass. tsc and gate.ts --fix are clean. I did not run the full suite.
To try it. Call usage on /mcp with a token and { "repo": "owner/name", "kind": "wallet" }, then compare latest with /owner/name/wallet.
Earlier asks met: the wallet is now exercised over POST /mcp with real tokens, and its latest lines are compared line for line with the rows parsed from the /wallet page. Unauthenticated, cookie-only and revoked tokens get 401 with the sign-in step, and a stranger's ro token gets not_found with no ledger. No new code paths: SUMMARY_SPENDS goes 3 to 10, docs and tool doc updated, no README change, terminal money screen already lists the same rows. No security finding. Non-blocking: the tool is named usage kind wallet rather than a wallet tool, which the issue wording differs from but the size budget justifies.
The wallet over the MCP now returns the ten latest ledger rows instead of three. I did not add a
wallettool. #13590 had already put the wallet onusagewith{ repo, kind: "wallet" }, and the size guidance says to extend an existing tool.What changed
SUMMARY_SPENDSinsrc/actions/wallet.tsgoes from 3 to 10.lateststill holds one line per spend: date, dollars frommoney, what it paid for, and(outcome)when not ok. The balance still comes frombalanceWords.docs/MCP.md. That paragraph listed alastSpendfield the tool does not return, so I removed it.test/mcp-wallet.test.tsnow expects the real row counts. A new test seeds enough spends to exceed ten and checks four things:latesthas exactly ten lines.Access. The gate was already the page's own: someone who cannot see the repository's owner facts gets
not_found, and a stranger or visitor gets nothing from another repository's ledger. I did not touch it. It is not a token-scope check: the tool is read-only, and "Writers" in its description is not enforced beyond the page's gate.Checks run.
mcp-wallet,mcp-size,mcp-table,wallet,mcp-toolsandmcp-doc-names-every-argumentpass, andtscandscripts/gate.ts --fixcome back clean. Tool sizes are unchanged and no ceiling was raised. I did not run the full suite.To try it. Call
usageon/mcpwith a token and{ "repo": "owner/name", "kind": "wallet" }, then readlatest.Left out. A separate
wallettool, and a scope check beyond the page's gate.Closes #13941