Public: anyone can read this; the crew can change it.

MCP `subscription_budget`: set or clear a subscription's whole-life budget, with the same rules as the Subscriptions page #5444

Parked opened this
Closed without merging

I added the MCP tool subscriptionbudget { id, usd }, which sets a subscription's whole-life budget in dollars or clears it with usd: null. The new test, test/mcp.test.ts, test/mcp-docs.test.ts and test/mcp-size.test.ts pass, and tsc --noEmit is clean. Access: It is admin-only and needs an admin-scope token.

Notes

stopped parked by the crew deploy fb228bb

opened this

I added the MCP tool subscription_budget { id, usd }, which sets a subscription's whole-life budget in dollars or clears it with usd: null. The new test, test/mcp.test.ts, test/mcp-docs.test.ts and test/mcp-size.test.ts pass, and tsc --noEmit is clean.

  • Access: It is admin-only and needs an admin-scope token. It is marked as a write in tools/list, with a one-sentence description. A non-admin gets the JSON-RPC "unknown tool" error and nothing changes.
  • Rules: It follows the Subscriptions page, including the order of its checks. The page's handler is a form action, so I mirrored it rather than reusing it. The tool calls setBudget and runs the page's locked-budget check first.
  • Refusals: Each refusal has its own code:
    • not_found for an unknown id.
    • locked for a locked budget that would be raised or cleared (it can only be lowered).
    • invalid for a value above the subscription.budget_max_usd limit, or a non-number.
  • Answer: On success it answers { id, budgetUsd, says }, with budgetUsd rounded to cents as the page stores it.
  • Docs and tests: I added one row to docs/MCP.md. test/mcp-subscription-budget.test.ts has four tests:
    • An admin sets a budget and the page shows it (value="12.5"), then clears it.
    • An over-limit value, a string value and an unknown id are refused.
    • A locked budget is lowered but never raised or cleared.
    • A non-admin is refused.

    I did not check that each test fails without the tool.

I did not touch the read side, subscriptions (#5418), and added no dependencies.

Closes #5431

commented

I added the MCP tool subscription_budget { id, usd }, which sets a subscription's whole-life budget in dollars or clears it with usd: null. The new test, test/mcp.test.ts, test/mcp-docs.test.ts and test/mcp-size.test.ts pass, and tsc --noEmit is clean.

  • Access: It is admin-only and needs an admin-scope token. It is marked as a write in tools/list, with a one-sentence description. A non-admin gets the JSON-RPC "unknown tool" error and nothing changes.
  • Rules: It follows the Subscriptions page, including the order of its checks. The page's handler is a form action, so I mirrored it rather than reusing it. The tool calls setBudget and runs the page's locked-budget check first.
  • Refusals: Each refusal has its own code:
    • not_found for an unknown id.
    • locked for a locked budget that would be raised or cleared (it can only be lowered).
    • invalid for a value above the subscription.budget_max_usd limit, or a non-number.
  • Answer: On success it answers { id, budgetUsd, says }, with budgetUsd rounded to cents as the page stores it.
  • Docs and tests: I added one row to docs/MCP.md. test/mcp-subscription-budget.test.ts has four tests:
    • An admin sets a budget and the page shows it (value="12.5"), then clears it.
    • An over-limit value, a string value and an unknown id are refused.
    • A locked budget is lowered but never raised or cleared.
    • A non-admin is refused.

    I did not check that each test fails without the tool.

I did not touch the read side, subscriptions (#5418), and added no dependencies.

commented

Parked by the crew: the check failed ("the Files page of a 40-file diff: cold median of 3 and repeat median of 5 stay under their ceilings") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs