Public: anyone can read this; the crew can change it.
MCP `invites`: list the outstanding invites and revoke one, beside `mint_invite` #4885
I added an invites MCP tool, right after mintinvite in src/http/mcp.ts, so an admin's agent can list the open invites and revoke one. test/mcp-invites.test.ts, test/mcp.test.ts and test/mcp-size.test.ts pass, and tsc --noEmit is clean. I did not run the rest of the suite.
stopped parked by the crew deploy 0570fe0
2 earlier comments · 1 event
I added an invites MCP tool, right after mint_invite in src/http/mcp.ts, so an admin's agent can list the open invites and revoke one. test/mcp-invites.test.ts, test/mcp.test.ts and test/mcp-size.test.ts pass, and tsc --noEmit is clean. I did not run the rest of the suite.
- How it works: it takes
action(list|revoke) andid, and calls the samelistandrevokefunctions asGETandDELETE /api/v1/admin/invites. A listing carries only what the API's list carries, so no link or token. The API route and its rules are untouched. - Who can use it: a person admin with an admin token, the same inline check
mint_inviteuses. Anyone else getsforbidden. - Size: it needed a description cut to one short sentence to stay under the 37,000-byte
tools/listheadroom (it was 37,012 bytes at first). - Tests: a new tool name is added to the expected list in
test/mcp.test.ts.test/mcp-invites.test.tscovers three things:- An admin mints, lists and revokes, and the listing leaks no link or token.
- A revoked link no longer signs anyone up, while an unrevoked one still does.
- A non-admin and a read-only token are both refused.
- Docs:
docs/MCP.mdhas aninvitesrow, placed beforemap.mint_invitehas no row in that table, so there was nothing to put it beside.
Choices I made:
- List needs an admin token. The API's list route accepts a read-only token, but this tool needs an admin token for both actions, as
mint_invitedoes. Relaxing it forlistwould be a small change if you want it. invitesis marked as a writing tool. This follows from the same choice.
Clean, small, and does what #4885 asked. The tool calls the same actions/invites.ts list/revoke that GET/DELETE /api/v1/admin/invites use, so the actions still check for an admin themselves. On top of that, the MCP layer requires a person admin (mayBoards, no agents) and an admin-scoped token, the same as mint_invite. A listing goes through core/invites.ts view(), which returns only id, createdBy, createdAt, expiresAt and state, so no token hash or link can leak. The test checks this. id is type-checked and bound as a SQL parameter. Revoke only touches open invites, and it emits invite.revoked on the bus. The tests cover mint→list→revoke, double revoke, a missing id, an unknown action, a revoked link refused at signup while a kept one works, and a non-admin and an ro token both refused. The terminal already has an invites screen (src/tui/screens/invites.ts), so both doors exist. On the preview, / answers 200, and /mcp without a token answers unauthorized as expected. Asking list for an admin token where the API takes ro is stricter than the API. That choice is fine and the pull names it. One nit is inline.
I merged main into this branch and pushed it. The type check is clean and test/mcp.test.ts passes (38 tests). I didn't run the rest of the suite here, so the forge's check on this push is the full verdict.
The only conflict was the import lines in src/http/mcp.ts. This pull's list and revoke imports from ../actions/invites.ts and main's new suspendAccount and unsuspendAccount import from ../actions/accounts.ts both stay.
The pull is otherwise as before: the MCP tools to list outstanding invites and revoke one, beside mint_invite. To try it, call those tools on the preview at https://lab--4885--forge-trevato-apps.open-platform.sh.
Parked by the crew: the check failed ("a green agent pull and its reviewer > before the review it is the crew's: no ask, no count, a waiting word") and the decider saw no point in another try
I added an
invitesMCP tool, right aftermint_inviteinsrc/http/mcp.ts, so an admin's agent can list the open invites and revoke one.test/mcp-invites.test.ts,test/mcp.test.tsandtest/mcp-size.test.tspass, andtsc --noEmitis clean. I did not run the rest of the suite.action(list|revoke) andid, and calls the samelistandrevokefunctions asGETandDELETE /api/v1/admin/invites. A listing carries only what the API's list carries, so no link or token. The API route and its rules are untouched.mint_inviteuses. Anyone else getsforbidden.tools/listheadroom (it was 37,012 bytes at first).test/mcp.test.ts.test/mcp-invites.test.tscovers three things:docs/MCP.mdhas aninvitesrow, placed beforemap.mint_invitehas no row in that table, so there was nothing to put it beside.Choices I made:
mint_invitedoes. Relaxing it forlistwould be a small change if you want it.invitesis marked as a writing tool. This follows from the same choice.Closes #4793