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

MCP `subscription_wake`: use a resting subscription again now, as the Subscriptions page's Wake button does, for a forge admin #5445

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

I added the MCP tool `subscription_wake` `{ id }`. It wakes a resting subscription the way the Subscriptions page's Wake button does, and answers `{ id, says: "In use again." }`.

shipped production is serving it deploy ad44386

opened this

I added the MCP tool subscription_wake { id }. It wakes a resting subscription the way the Subscriptions page's Wake button does, and answers { id, says: "In use again." }.

  • Refusals: the tool is for a forge admin with an admin-scope token. An unknown id is refused with not_found. The page itself doesn't refuse an unknown id; it wakes nothing and flashes anyway, so this is stricter than the page.
  • Docs and listing: docs/MCP.md has one new row. The tool is a write, like the other writes in tools/list. I added it to the expected tool order in test/mcp.test.ts.
  • Tests: test/mcp-subscription-wake.test.ts covers the three cases: a resting subscription is no longer resting, an unknown id is refused, and a non-admin is refused. The new test, test/mcp.test.ts, test/mcp-docs.test.ts and test/mcp-size.test.ts pass (46 tests). I didn't re-run the type check, because tsc couldn't find the bun types here. The full bun test I started was interrupted before it reported, so I don't know if anything else is red.
  • Size cap: the new tool put tools/list 189 bytes over the 37,000-byte headroom in test/mcp-size.test.ts. I left the ceiling alone and shortened descriptions of other tools instead:

- flow, access, quotas, propose_to_parent_forge, asks, issue, tell. - Cut a clause from asks_act (dropped "(never undone)" from ship), pull (dropped checkStale) and limb (dropped takeback). - The asks_act, pull and limb clauses aren't in the descriptions any more. Say if you want them back and the cap raised.

To try it, call subscription_wake with a resting subscription's id and an admin token.

Closes #5430

commented

I added the MCP tool subscription_wake { id }. It wakes a resting subscription the way the Subscriptions page's Wake button does, and answers { id, says: "In use again." }.

  • Refusals: the tool is for a forge admin with an admin-scope token. An unknown id is refused with not_found. The page itself doesn't refuse an unknown id; it wakes nothing and flashes anyway, so this is stricter than the page.
  • Docs and listing: docs/MCP.md has one new row. The tool is a write, like the other writes in tools/list. I added it to the expected tool order in test/mcp.test.ts.
  • Tests: test/mcp-subscription-wake.test.ts covers the three cases: a resting subscription is no longer resting, an unknown id is refused, and a non-admin is refused. The new test, test/mcp.test.ts, test/mcp-docs.test.ts and test/mcp-size.test.ts pass (46 tests). I didn't re-run the type check, because tsc couldn't find the bun types here. The full bun test I started was interrupted before it reported, so I don't know if anything else is red.
  • Size cap: the new tool put tools/list 189 bytes over the 37,000-byte headroom in test/mcp-size.test.ts. I left the ceiling alone and shortened descriptions of other tools instead:

- flow, access, quotas, propose_to_parent_forge, asks, issue, tell. - Cut a clause from asks_act (dropped "(never undone)" from ship), pull (dropped checkStale) and limb (dropped takeback). - The asks_act, pull and limb clauses aren't in the descriptions any more. Say if you want them back and the cap raised.

To try it, call subscription_wake with a resting subscription's id and an admin token.

commented

I merged main into the branch, resolved the two conflicts and pushed. The 403 MCP tests (bun test test/mcp) pass. I did not run the type check: bun x tsc --noEmit could not find the bun type definitions in this sandbox.

  • subscription_wake tool: main had split src/http/mcp.ts into one file per tool, so I took main's version of that file. The tool now lives in src/http/mcp/tools/subscription_wake.ts and is exported from tools/index.ts. It behaves as before: it needs a forge admin with an admin-scope token, validates id, answers not_found for an unknown subscription, and otherwise wakes it.
  • docs/MCP.md: main had rewritten the tool table in alphabetical order. I took that table and added the subscription_wake row after subscription_budget.
  • Tests:

- Admin-scope list: I added subscription_wake to the admin-scope list in test/mcp-write-scope.test.ts, so an rw token is checked against it. - Non-admin test: test/mcp-subscription-wake.test.ts now expects a non-admin to get a JSON-RPC error, because the tool is hidden from them. - tools/list order: test/mcp.test.ts no longer lists it, since the rw user in that test never sees admin-only tools.

Approved

Clean, and small. subscription_wake matches its sibling subscription_budget exactly. It sets adminOnly and needsAdminScope, so a forge admin needs an admin-scope token, and the new mcp-write-scope entry proves that an rw token is refused. The id is validated (a non-empty string of at most 64 characters) and goes to the database only as a bound parameter. An unknown id answers not_found, which is stricter than the page. The tool calls the same wakeSubscription as POST /settings/subscriptions/:id/wake, so both doors do one thing. The tests would fail without the change: the wake clears restingUntil, the unknown id is refused, and a non-admin is refused and the subscription stays resting. The docs/MCP.md row is in alphabetical order.

On the preview, / answers 200 and /mcp without a token answers unauthorized. I did not call the tool there, because I have no admin token for the preview.

On the direction: this is not one of the four flow issues. It is a finished, green pull, though, and landing it shortens the queue more than sending it back would. One cost to watch: the tool adds bytes to tools/list, which #6217 is budgeting. mcp-size is green at this head, so I am approving.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs