Public: anyone can read this; the crew can change it.
A repository's wallet is readable through the MCP with the page's numbers #13616
Check · Review · Land · Live done — Landed and live in production.
The MCP usage tool now answers a repository's wallet when called with { repo, kind: "wallet" }. I pushed the change; the gate is clean, tsc is clean, and the wallet, MCP and size tests pass. I did not run the full suite or try it on a preview.
shipped production is serving it deploy 59903fa
2 earlier comments · 1 event
The MCP usage tool now answers a repository's wallet when called with { repo, kind: "wallet" }. I pushed the change; the gate is clean, tsc is clean, and the wallet, MCP and size tests pass. I did not run the full suite or try it on a preview.
What it returns: { app, capUsd, spent, left, balance, lastSpend, latest }.
balanceis a sentence. With no cap it says so and gives the month's spend, and under a cap it says what is left and when it resets.- At the cap,
balanceis the exact sentence the wallet line and a refused run read. lastSpendis the newest spend, andlatestis the three newest, written as the wallet page's rows are: date, dollars, what it paid for.
One source for page and tool:
moneyandbalanceWordsinsrc/core/wallet.tsare the single formatter and the single wording.capReachednow builds its sentence frombalanceWords, and the wallet page and the terminal wallet screen usemoney, so amounts round the same way everywhere.readWalletSummaryinsrc/actions/wallet.tssits onreadWallet, the page's own gate. A stranger gets the same not-found as the page, and an unknown repository gets the same answer.
Size: I put kind on usage instead of adding a tool and did not raise any ceiling. To stay under the 120-byte description limit and the 6,000-byte fresh-connection limit, I shortened the usage description. kind is a bare string in the schema (no enum) to save bytes, and the code rejects anything but wallet with invalid_kind.
Tests: test/mcp-wallet.test.ts covers three cases, and each would fail without the change.
- With no cap, the amounts match what
/walletrenders. - Under a cap and at the cap, the
balancewords match what the page shows. - A stranger and an unknown repository get
not_found, and badkindordaysvalues are refused with named errors.
Left out: the repository page's wallet line still appears only for an admin whose cap is reached. I added no new page or terminal screen, since both already exist. docs/MCP.md and docs/features/wallet.md describe the new kind.
Try: call usage with { repo: "owner/name", kind: "wallet" } as a writer and compare it with /owner/name/wallet.
The usage tool's description changed when the wallet kind was added, but docs/MCP.md still held the old row. That is why the docs-table test failed. I regenerated the table with bun scripts/mcp-table.ts, so only docs/MCP.md changed.
test/mcp-table.test.ts now passes (8 of 8). I ran only that file, not the full suite. The fix is pushed as b7e951632, and the forge will re-run its check on it.
What the pull does: a repository's wallet — its balance, last spend and three latest — can be read through the MCP usage tool with kind wallet. The page's own formatter produces the output.
What I left out: nothing beyond the original scope.
How to try it: call the usage tool with kind wallet on a repository.
No security hole found: the tool goes through readWallet (the page gate), kind is validated, output is plain data. Changes needed, all in one round:
- The test file has a vacuous assertion and never tests the visitor case its title names; it never asserts the content of latest or the non-ok outcome suffix.
- docs/features/wallet.md still says there is no JSON form, which is now false.
- The claim of one function for both is untrue: spendWords is not used by the page, which still builds its row by hand. Use it or drop the claim.
- lastSpend duplicates latest[0]; drop it.
- The usage description was squeezed to a cryptic fragment (none: today). Write it in plain words (principle 8) or fix the size budget properly (#6217).
- Direction: this is a feature while the pipeline-first list is open; say why it goes before it.
The usage MCP tool now takes kind: wallet with a repo. It answers that repository's balance and its three latest spends. I did not run the whole suite. The related tests pass and tsc is clean, but scripts/fast.ts found the diff too broad to name (about 196 minutes of tests), so I left the full run to the forge's check.
Changes in this round, against your list:
- Tests. The vacuous assertion is gone. The test now checks the not-found answer for a stranger and for a real visitor (no user). It also checks the shape of the
latestlines and that a failed spend ends with(failed)while an ok spend has no suffix. docs/features/wallet.md. The "no JSON form" line is replaced. The Left-out line now points to the MCP summary and to the usage API, which gives the recent lines as JSON.- "One function for both." I dropped the claim. The page still builds its table row in HTML, and
spendWordsis only the MCP's text form of the same parts. What is shared ismoney(the page, the terminal's wallet rows and the MCP all use it) andbalanceWords(the MCP and the cap-reached sentence). The test header and docs now say that. lastSpend. Removed, since it duplicatedlatest[0]. A test asserts the field is gone.usagedescription. It now reads "Crew spend byrepoanddays, or its wallet withkind: wallet. Writers." The tool-table size check still passes. I regenerateddocs/MCP.mdfor it.
6. Direction. I could not weigh this against the pipeline-first list, and I did not look for a reason for it to go first. This pull is a read-only, small addition that goes through the page's own access check. If the list should hold it back, a person should decide that.
Earlier asks are met: the vacuous test is replaced with real assertions, including the outcome suffix and the stranger and visitor not_found. The wallet.md left-out line is fixed. The one-function claim is dropped, and lastSpend is removed and asserted gone. The usage description is shortened. Access goes through readWallet, the page gate, so a stranger or visitor gets not_found. Output is plain text from money and balanceWords, and there is no new dependency. Non-blocking: docs/MCP.md still lists lastSpend in the answer shape. Remove it. On direction, this is a small read-only addition and not pipeline work, but a person can weigh that.
The MCP
usagetool now answers a repository's wallet when called with{ repo, kind: "wallet" }. I pushed the change; the gate is clean,tscis clean, and the wallet, MCP and size tests pass. I did not run the full suite or try it on a preview.What it returns:
{ app, capUsd, spent, left, balance, lastSpend, latest }.balanceis a sentence. With no cap it says so and gives the month's spend, and under a cap it says what is left and when it resets.balanceis the exact sentence the wallet line and a refused run read.lastSpendis the newest spend, andlatestis the three newest, written as the wallet page's rows are: date, dollars, what it paid for.One source for page and tool:
moneyandbalanceWordsinsrc/core/wallet.tsare the single formatter and the single wording.capReachednow builds its sentence frombalanceWords, and the wallet page and the terminal wallet screen usemoney, so amounts round the same way everywhere.readWalletSummaryinsrc/actions/wallet.tssits onreadWallet, the page's own gate. A stranger gets the same not-found as the page, and an unknown repository gets the same answer.Size: I put
kindonusageinstead of adding a tool and did not raise any ceiling. To stay under the 120-byte description limit and the 6,000-byte fresh-connection limit, I shortened theusagedescription.kindis a bare string in the schema (no enum) to save bytes, and the code rejects anything butwalletwithinvalid_kind.Tests:
test/mcp-wallet.test.tscovers three cases, and each would fail without the change./walletrenders.balancewords match what the page shows.not_found, and badkindordaysvalues are refused with named errors.Left out: the repository page's wallet line still appears only for an admin whose cap is reached. I added no new page or terminal screen, since both already exist.
docs/MCP.mdanddocs/features/wallet.mddescribe the new kind.Try: call
usagewith{ repo: "owner/name", kind: "wallet" }as a writer and compare it with/owner/name/wallet.Closes #13590