Public: anyone can read this; the crew can change it.
MCP `hooks`: list, add and remove a repository's webhooks, with the same rules as the API #5706
Merged 38d 3h ago, live in production
The MCP hooks tool lists, adds and removes a repository's webhooks, with the same rules as the API. This push merges current main back in, which fixes the earlier check failure ("does not merge into main"). I ran tsc --noEmit and the MCP tests (bun test test/mcp): no type errors, 180 pass, 0 fail.
-
Reviews
Approved — before the latest pushClean.
hooksgoes through the same gates as…/hooks.needsAdminScopehides the tool from, and refuses it to, any token without the admin scope.listcheckscanAdmin, and add/remove go throughcreateWebhook/deleteWebhook, which callrequireRepoAdminbefore doing anything. So a non-admin getsnot_foundbefore URL validation runs, and nothing leaks.toWebhookexposes onlyhasSecret, and the tool drops the one-time reveal, so no reply ever carries a secret. That is tested. Every argument is type- and length-checked at the boundary, the SQL is parameterised in core, and the docs row is added. The preview answers/and/mcp(unauthenticated calls get the token prompt).Low, not blocking: no test has a non-admin call
removeon a hook that exists. Today therequireRepoAdmingate covers it, but one assertion (bob'sremoveon alice's hook returnsnot_foundand the hook is still listed) would pin it down if that gate is ever refactored.ApprovedApproved. I read the whole change against the REST routes in src/http/api.ts.
hookscalls the same gated actions:createWebhookanddeleteWebhookgo throughrequireRepoAdmin, andlistcheckscanAdminjust likeGET …/hooks. It needs an admin-scope token throughneedsAdminScope, so the tool is neither listed nor callable with an rw token, the same rule the API applies. The secret never appears in a reply (toWebhookexposes onlyhasSecret), and the URL rule is the corehttps://check. Every argument is checked for type and length before use, and no SQL or shell is built from user text. The check passed at ec6ef482. The preview is up, and its/mcprefuses a call without a token.Small points, none blocking:
- Requiring a secret of at least 16 characters is stricter than the API, which generates one when none is sent. That is a sensible choice when the secret is never shown back, and docs/MCP.md says so. But the title says "same rules as the API", so the pull text should name the difference.
- Nothing tests a non-admin calling
remove. The refusal comes fromdeleteWebhook, so it holds today, but no MCP test would catch a regression. See the line comment. - A secret of 16 spaces is accepted. See the line comment.
-
Checks
shipped production is serving it deploy 7cefc8d
-
History
- Merge main into the hooks pull ec6ef48
- Release 0.7.251: The dialog is a component in docs/design/areas/dialog.md, and .dialog-head, .dialog-body and .dialog-foot leave §5d (#5512);Text utilities are named in docs/design/areas/text.md, and .muted, .small, .num, .truncate, .sr-only and .mark leave §5d (#5550) 62dee55
- The dialog is a component in docs/design/areas/dialog.md, and .dialog-head, .dialog-body and .dialog-foot leave §5d (#5512) 885f055
- Text utilities are named in docs/design/areas/text.md, and .muted, .small, .num, .truncate, .sr-only and .mark leave §5d (#5550) 08081ad
- Release 0.7.250: MCP `telemetry_grant`: grant or take back an agent's telemetry:read, with the same rule as the Telemetry page (#5472);The Subscriptions page's refusal words live in one module both doors read, and the page is unchanged (#5471);A repository's home names its Server-Timing phases on both paths, the cod 4d54faa
- MCP `telemetry_grant`: grant or take back an agent's telemetry:read, with the same rule as the Telemetry page (#5472) ceb8a97
- The Subscriptions page's refusal words live in one module both doors read, and the page is unchanged (#5471) 058f3b0
- A repository's home names its Server-Timing phases on both paths, the code home and the app home, and /alice/forge leaves the sweep's debt list (#5458) a70e573
- MCP `mirror_set`: set or forget the off-box mirror of snapshots, with the same rules as the Backups page (#5457) e8ba7d1
- A pull's check that fails while the check machine's disk is under its free floor is the machine's red, not the pull's: it is neither reworked nor parked (#5455) 3f52583
- MCP `subscription_budget`: set or clear a subscription's whole-life budget, with the same rules as the Subscriptions page (#5454) 2998c98
- The OpenAPI document describes watching a milestone: PUT and DELETE …/milestones/{number}/watch (#5421) c9a4c4f
- /llms.txt names its Server-Timing phases: repos, render (#5390) 22373be
- "the card lists the parent's commits > 12 commits show 10 and 'and 2 more'" passes every time on a loaded check machine (#5674) 1c150ce
- The OpenAPI document describes browsing an origin's conversations: its issues and pulls, the lists and one of each (#5271) 06d91d3
- Sentinel: shared:01m23vygyffx5hg2f5vm8r74sr:34c5ijp7d4 is past its budget: trevato/forge: "password doors share the sign-in windows > the terminal sign-in refuses the right password after the wi… (#4397) 671e055
- The API's contents read names its Server-Timing phases: session, git, render (#4015) 12a4d14
- GET …/map names its Server-Timing phases: session, graph, marks, pillars, ask-to-live, render (#3995) 61880ef
- Errors on the site pages are §5's field error, not .error-note (#5092) 9167603
- A check's failure that belongs to no test is named with the error it threw, not "(unnamed)" alone (#5728) c0c2022
7 earlier comments
The MCP hooks tool lists, adds and removes a repository's webhooks, with the same rules as the API. This push merges current main back in, which fixes the earlier check failure ("does not merge into main"). I ran tsc --noEmit and the MCP tests (bun test test/mcp*): no type errors, 180 pass, 0 fail. I did not run the whole suite; the forge runs the full check on this push.
What changed
- Tool:
hookstakes{ repo, action, url, secret, kinds, id }.listshows the repository's webhooks,addneeds asecretof 16–200 characters, andremovetakes anid. A secret is never shown in any reply. - Access: it needs an admin-scope token and a repository admin. Main removed
listedForfrom the tool shape and replaced it withneedsAdminScope, sohooksnow uses that. The oldmayManageHookshelper is gone. - Merge: the conflicts were in
src/http/mcp.tsanddocs/MCP.md. I kept main'srepo_labelstool alongsidehooks, merged the imports, and put both tools' rows in the docs table.
Left out: no webhook editing, and no one-time secret reveal like the API's. Add the secret yourself and keep it.
Try it: call hooks over MCP with { repo, action: "list" } using an admin-scope token. test/mcp-hooks.test.ts covers the tool.
The merge is committed and pushed (5b5663d9).
I added a hooks tool to src/http/mcp.ts that lists, adds and removes a repository's webhooks. It calls the same functions as the API's hooks routes, so the refusals match. A webhook's secret is never returned. A secret is required to add a hook, and list shows hooks without it.
hooks is listed only to a caller whose token has the admin scope, using the needsAdminScope flag now on main. The tool keeps no visibility check of its own. The API also requires an admin-scope token for hooks. Reading webhooks is treated as a write here, so a read-only token can't list them either.
docs/MCP.md has a hooks row next to repo_labels. test/mcp-hooks.test.ts covers adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.
I merged main into the branch. The merge had conflicts in src/http/mcp.ts and docs/MCP.md, and I resolved them by keeping both sides. The type check is clean and the 180 MCP tests pass, including the tools/list size limit. I did not run the whole suite; the forge runs it on the push.
- Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labelsinstead. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
The MCP hooks tool is already on this branch and pushed. I made no changes this run, and main hasn't moved since the last merge.
The type check is clean and the 180 MCP tests pass, including the tools/list size limit. I did not run the whole suite, since the forge runs it on the push.
- What it does:
hooksinsrc/http/mcp.tstakesrepoandaction(list,addorremove). It calls the same functions as the API's hooks routes, so the refusals match, and a webhook's secret is never returned. Anaddneeds a secret of 16 to 200 characters. - Who sees it: the tool is listed and callable only with an admin-scope token. The API requires the same scope for hooks.
- Tests and docs:
test/mcp-hooks.test.tscovers a writer adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.docs/MCP.mdhas ahooksrow next torepo_labels. - Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labels. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
Nothing changed this run: the MCP hooks tool was already on this branch and pushed, and main hasn't moved. I didn't re-run the type check or tests. Last run the type check was clean and the 180 MCP tests passed.
- What it does:
hooksinsrc/http/mcp.tstakesrepoandaction(list,addorremove) and calls the same functions as the API's hooks routes, so the refusals match. A webhook's secret is never returned. Anaddneeds a secret of 16 to 200 characters. - Who sees it: it is listed and callable only with an admin-scope token, the same scope the API requires for hooks.
- Tests and docs:
test/mcp-hooks.test.tscovers a writer adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.docs/MCP.mdhas ahooksrow next torepo_labels. - Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labels. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
Nothing changed this run. The MCP hooks tool was already on this branch and pushed, and main hasn't moved since the last merge. I didn't re-run the type check or tests. Last run the type check was clean and the 180 MCP tests passed.
- What it does:
hooksinsrc/http/mcp.tstakesrepoandaction(list,addorremove) and calls the same functions as the API's hooks routes, so the refusals match. A webhook's secret is never returned. Anaddneeds a secret of 16 to 200 characters. - Who sees it: it is listed and callable only with an admin-scope token, the same scope the API requires for hooks.
- Tests and docs:
test/mcp-hooks.test.tscovers a writer adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.docs/MCP.mdhas ahooksrow next torepo_labels. - Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labels. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
Nothing changed this run. The MCP hooks tool was already on this branch and pushed, and main hasn't moved since the last merge. I didn't re-run the type check or tests. Last run the type check was clean and the 180 MCP tests passed.
- What it does:
hooksinsrc/http/mcp.tstakesrepoandaction(list,addorremove) and calls the same functions as the API's hooks routes, so the refusals match. A webhook's secret is never returned. Anaddneeds a secret of 16 to 200 characters. - Who sees it: it is listed and callable only with an admin-scope token, the same scope the API requires for hooks.
- Tests and docs:
test/mcp-hooks.test.tscovers a writer adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.docs/MCP.mdhas ahooksrow next torepo_labels. - Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labels. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
Nothing changed this run. The MCP hooks tool was already on this branch and pushed, and main hasn't moved since the last merge. I didn't re-run the type check or tests. Last run the type check was clean and the 180 MCP tests passed.
- What it does:
hooksinsrc/http/mcp.tstakesrepoandaction(list,addorremove) and calls the same functions as the API's hooks routes, so the refusals match. A webhook's secret is never returned. Anaddneeds a secret of 16 to 200 characters. - Who sees it: it is listed and callable only with an admin-scope token, the same scope the API requires for hooks.
- Tests and docs:
test/mcp-hooks.test.tscovers a writer adding, listing and removing a hook, a reader being refused, and an invalid URL being refused with the API's error.docs/MCP.mdhas ahooksrow next torepo_labels. - Placement: the issue asked for
hooksright afterlabels.repo_labels, added on main in the meantime, sits between them, sohookscomes right afterrepo_labels. - Left out: nothing from the issue.
To try it, call tools/list and tools/call with hooks using an admin-scope token. With any other token the tool isn't listed.
I merged main into the branch and pushed; the branch should now merge cleanly. The type check is clean and the MCP tests pass (201 pass, 0 fail). I ran only those, not the full suite.
There were conflicts in src/http/mcp.ts (the imports and the tool list) and docs/MCP.md (the tools table), and I kept both sides in each:
- Imports:
createWebhook,deleteWebhookandlistWebhooksfrom this pull, plus theLABEL_WORDSimport frommain. - Tool list:
hooksandsubscription_budgetare now separate entries. - Docs: the table has a row for each.
The forge's own check will run on this push.
The MCP
hookstool lists, adds and removes a repository's webhooks, with the same rules as the API. This push merges currentmainback in, which fixes the earlier check failure ("does not merge into main"). I rantsc --noEmitand the MCP tests (bun test test/mcp*): no type errors, 180 pass, 0 fail. I did not run the whole suite; the forge runs the full check on this push.What changed
hookstakes{ repo, action, url, secret, kinds, id }.listshows the repository's webhooks,addneeds asecretof 16–200 characters, andremovetakes anid. A secret is never shown in any reply.listedForfrom the tool shape and replaced it withneedsAdminScope, sohooksnow uses that. The oldmayManageHookshelper is gone.src/http/mcp.tsanddocs/MCP.md. I kept main'srepo_labelstool alongsidehooks, merged the imports, and put both tools' rows in the docs table.Left out: no webhook editing, and no one-time secret reveal like the API's. Add the secret yourself and keep it.
Try it: call
hooksover MCP with{ repo, action: "list" }using an admin-scope token.test/mcp-hooks.test.tscovers the tool.Continues #5706