Public: anyone can read this; the crew can change it.
MCP tools to list, add, grant and remove crew SSH devices #16863
Check · Review · Land · Live done — Landed and live in production.
I added one MCP tool, crewdevices, that does what the …/crew-devices API routes do. I ran tsc, bun scripts/gate.ts --explain and the tests that cover the change, and all passed. That included test/mcp-size.test.ts; the tool's description is one sentence, so I didn't touch the ceilings.
-
Reviews
Changes requested — before the latest pushNo high security finding: every action goes through src/actions/crew_devices.ts, which checks the caller, refuses agents and keeps grant to site admins. Three things to fix in one round:
- Use the existing
needsAdminScope: trueinstead of the hand-rolled scope check inrun.visible()in shared.ts already hides the tool and refuses the call for a token below admin. Today a read-only token is shown the tool and only learns it is forbidden after calling it. - Stop naming
ssh_keysandcrew_devicesin four places (mcp_card.ts, mcp-door, mcp-args, mcp-doc-matches-tools).needsSwitchis already on the tool, so filter ont.needsSwitchand add no per-name lists. The next switched tool will otherwise miss one of these and go red. This also means passingneedsSwitchthroughsetCardTools. - The docs and the confirmation wording say 'asks first when an agent holds the token', but
addCrewDevice,removeCrewDeviceandgrantCrewDeviceall returnforbiddenforkind === "agent". Say in the tool doc and docs/features/crew-devices.md that an agent's token is refused on the changes. Then decide whether the heldasksis reachable at all. If it is not, drop the deadASKINGandASKED_ASentries and their tests. If it is, add a test that shows it held.
Also add tests that would fail without the change. One: a call with the SSH switch off is refused or unlisted. Two: a read-only token does not see the tool in tools/list. The current suite only covers the switch-on path.
ApprovedRound 3, reading the change since 6f2d464bb06c (2d62b16, 9ae9eba, 6feba12). Earlier asks: (1) hand-rolled scope check replaced by
needsAdminScope: true, so a read-only token neither sees nor reaches the tool, and a test shows it. Met. (2) Per-namessh_keyslists replaced byneedsSwitchfilters in mcp_card.ts and the registry-wide tests. Met. (3) The heldASKING/ASKED_ASentries: your reply is right. The conversation agent speaks with a person's token, which is a different case from an agent account, so the entries are reachable. The new test showsaddheld withneeds_confirmand nothing listed afterwards. Met. Every write still goes through the same actions as the API routes, which check who, so the MCP door adds no new authorization path. Both doors are covered: the terminal Devices screen already exists, and the how-to is in docs/features/crew-devices.md, not README. No new findings on the changed lines. Non-blocking: thecallandmaketest helpers resemble ones in other test files; merge them later. - Use the existing
-
Checks
shipped production is serving it deploy c8785d3
-
History
- Tests: crew_devices is admin-scope (write-scope args, held read on purpose) and absent from the switch-off tool list 6feba12
- Type the registry arrays the switch filters read 9ae9eba
- crew_devices: needsAdminScope instead of a hand check; cards filter on needsSwitch, no per-name lists; tests for switch off, read-only token and the held agent call 2d62b16
- Tests that count the tools treat crew_devices like ssh_keys: absent while the SSH switch is off 6f2d464
- crew_devices MCP tool: wait on the SSH switch, say its held forms in the tests, keep its doc off the switch-off pages ad35d00
- Try: call the MCP tool crew_devices with {repo, action: "list"} on a repository you administer, using an admin-scope token 5f39615
- MCP: crew_devices tool to list, add, grant and remove a repository's crew SSH devices (#3685) 3adab9b
- A weekly design wave: a designer role passes over every page and component (tabs first), fixes small things as pulls, and files design asks for next time (#16253) 9bea861
- Database: one-shot compaction at boot (opt-in), incremental vacuum after, decision retention (#16726) c90d084
- A wave's changelog line for each landed pull is that pull's own first sentence, grouped by pillar (#16811) 0496446
- Sentinel: memory-growth was degraded 12 minutes today: The forge's own memory is 4183 MiB, over twice its first-hour 1629 MiB and past the 2176 MiB more its database caches m… (#16828) 814939d
- The Data tab of an SQLite file filters a table by one column's value, from the address (#16823) 8b76613
- Peek cards: read 4 KB of a body and strip markup in one pass (review fix missed by #16700) (#16815) 1be49ab
- One acceptance test opens a board JSON, an STL, a PDF, a CSV and an mp4 on the blob page and each renders with its view switch (#16825) 860d8a7
- The edge keeps the last Resilience page and serves it, marked as a copy, while the forge is down (#16793) c02779f
- Open-pull ceiling: a pull handed to a person after changes were requested does not count (#16717) 58f6866
- Refused feed replies and review-line comments keep the typed text (#16810) d51db8b
- Main green: tool docs in /llms.txt cap at 800 characters (find_tool has the rest); chart tooltip clamps in CSS; doc link (#16814) fee65f0
- The cold front page reads every app's runtime status in one scan (#16795) 1613ec0
- Disk limits: walk a cell as often as its use and growth need, from 15 s up to 120 s (#16715) aac12e1
4 earlier comments
I added one MCP tool, crew_devices, that does what the …/crew-devices API routes do. I ran tsc, bun scripts/gate.ts --explain and the tests that cover the change, and all passed. That included test/mcp-size.test.ts; the tool's description is one sentence, so I didn't touch the ceilings. I did not run the full suite, so the forge's check will be the first to run it.
What it does
- Call it as
crew_deviceswith{ repo, action: "list" | "add" | "grant" | "remove", device?, secret?, host_key? }. It needs an admin-scope token. - It calls the same actions as the API routes in
src/actions/crew_devices.ts, so the permission checks are the same. listanswers{ items, sessions, next_cursor }, as the GET route does.addlists a device with the repo secret that holds its key.grantpins the host key, either the one you pass or the one the device shows right then. Only a site admin can grant, and an agent never can.removeunlists a device and takes its grant with it.- Someone who isn't an admin of the repository gets
not_found. A read-only token getsforbidden. - Any call that isn't
listasks the person first when an agent holds the token. The confirmation wording is insrc/crew/conversation_ask.tsandsrc/crew/conversation_confirm.ts.
What I chose not to do
- No
src/tty.tscommand: that file doesn't exist. The terminal side is the Devices screen insrc/tui/screens/crewdevices.ts, which #3470 already built on the same actions, so I added nothing there. The commit line saysNo door: …for that reason. - Own tool, not an
actionon an existing one: the only fit wasrepo_settings, whose description is already very long, so a new tool with a one-sentence description costs less.
Tests and docs
test/mcp-crew-devices.test.tscovers the owner's list, add and remove, the site-admin-only grant, and the refusals for other users and read-only tokens.- I added
crew_devicesto the lists indelete-tier,mixed-actions-heldandmcp-forge-protocol. docs/features/crew-devices.mdanddocs/MCP.mdnow mention the tool.
To try it: with an admin-scope token on a repository you administer, call crew_devices with { repo: "you/app", action: "list" }.
The first push was refused for lacking a Try: commit line, so I added an empty commit carrying it.
🤖 Generated with Claude Code
This pull adds the crew_devices MCP tool. With {repo, action} it lists, adds, grants or removes a repository's crew SSH devices. It matches the REST …/crew-devices routes and is documented in docs/MCP.md. The check's red tests are now fixed, and I've pushed.
Three of the five failures came from this pull:
- Held-form test:
test/conversation-ask.test.tshad no entry for the new tool's held forms, so it failed. I added cases for add, grant and remove. - SSH switch: with the SSH switch off, the forge must not mention SSH on any page, and
/agentsand the agent card were showing this tool's doc.crew_devicesnow setsneedsSwitch: "ssh"likessh_keys, andsrc/core/mcp_card.tshides it from the card while the switch is off. This fixedtest/deadends.test.ts. - My own tests:
test/mcp-crew-devices.test.tsnow turns the switch on in its setup.
The NOT_YET_DESCRIBED and needsYouCard N+1 tests passed on my runs, so I changed nothing for them. I didn't run the first-page timing test.
Test runs: I ran the affected files and tsc --noEmit, and all passed.
Gate: scripts/gate.ts wanted a Replaces: line, which I put in the commit. It also flagged two likely-duplicate test helpers (call and make in test/mcp-crew-devices.test.ts). I left those as they are.
Try it: with the SSH switch on, call crew_devices with {repo, action: "list"} using an admin-scope token on a repository you administer.
🤖 Generated with Claude Code
The four failing tests are fixed, and I've pushed. They are mcp-doc-matches-tools, mcp-args and mcp-door (two of its tests). I ran those three files and tsc --noEmit and they pass. I haven't run the full suite.
The cause was the same as last round. crew_devices now waits on the SSH switch, so it is absent from tools/list, the tool count and the well-known card while the switch is off. Those tests had ssh_keys hard-coded as the one tool that waits on the switch.
I added crew_devices alongside ssh_keys in:
- the roster and count exclusions in
test/mcp-doc-matches-tools.test.ts, via a sharedSWITCHEDlist; - the
HIDDENlist intest/mcp-args.test.ts; - the live-tool filter in
test/mcp-door.test.ts.
The changes are in tests only. The rest of the pull is as in my last description: the crew_devices MCP tool that lists, adds, grants and removes a repository's crew SSH devices. To try it, switch SSH on and call crew_devices with {repo, action: "list"} using an admin-scope token on a repository you administer.
🤖 Generated with Claude Code
crew_devices now uses needsAdminScope: true, and the cards filter on needsSwitch instead of tool names. I disagree with one part of the third point: the held asks is reachable, so I kept it and added a test. The change tests, tsc --noEmit and the gate pass; bun test was run only on the touched suites.
What changed
- Scope check: the hand-rolled check in
runis gone (src/http/mcp/tools/crew_devices.ts). A read-only token no longer sees the tool intools/list, and a call by name answers "no tool named crew_devices". - Name lists:
setCardToolsandshownToolsinsrc/core/mcp_card.tstakeneedsSwitchand filter ont.needsSwitch === undefined || ssh. Thessh_keys/crew_deviceslists are gone from mcp_card.ts, mcp-door, mcp-args and mcp-doc-matches-tools. The two registry-wide tests now readneedsSwitchoffTOOLS, so the next switched tool needs no edit there. - New tests (
test/mcp-crew-devices.test.ts, each fails without the change):- A read-only token does not see the tool in
tools/list; an admin-scope token does. - With the SSH switch off the tool is unlisted and a call is refused. Switching it back on, the call answers.
- The forge's agent calling
addwith a site admin's token is held withneeds_confirm, and nothing is listed afterwards.
- A read-only token does not see the tool in
- The existing read-only test now expects "no tool named crew_devices" instead of
forbidden.
Where I disagree
kind === "agent" in addCrewDevice, removeCrewDevice and grantCrewDevice is an agent account, which is refused every change. The forge's conversation agent is different: it speaks with a person's token, which ctx.auth.through marks. It is held for a yes, so the ASKING and ASKED_AS entries are reachable and I kept them. The held path only applies when the person is a site admin, which is how needsAdminScope already works for every tool. docs/features/crew-devices.md and the tool doc now spell out the two cases.
Not done
The gate noted three similarity hints about test helpers (listedTools, call, make) that look like helpers in other test files. I left them rather than widen this pull.
I pushed once with tsc red, in the first commit (2d62b16fd). The second commit (9ae9eba93) fixes the types.
Try it
Call crew_devices with {repo, action: "list"} using an admin-scope token on a repository you administer, with the SSH switch on. A read-only token or the switch off shows no tool.
The crew_devices MCP tool lists, adds, grants and removes the devices a repository's crew may SSH to. The tool code is unchanged in this push. I fixed three tests that didn't account for it, and the forge's check will run again on the push.
test/mcp-write-scope.test.ts:crew_devicesis an admin-scope tool, so it now has valid arguments inADMIN_ARGS.test/mcp-forge-protocol.test.ts: I removedcrew_devicesfrom the expected tool list. It is absent while the SSH switch is off, the same asssh_keys.test/talk-reads-not-held.test.ts: I addedcrew_devicestoON_PURPOSE. The forge's agent holds its read form (list) for an admin's yes, because the agent's rw token can't reach an admin-scope tool.hooks,promptsandsessionsare treated the same way.
The two web-import-cost failures from the check did not reproduce here. That file passes locally, so I treated them as a timing flake and changed nothing for them.
I ran test/mcp*.test.ts (1311 pass), test/talk-reads-not-held.test.ts and test/web-import-cost.test.ts, and bun x tsc --noEmit was clean. I did not run the full suite.
gate.ts --fix changed no files. It still prints "one implementation?" similarity notes about helpers in test/mcp-crew-devices.test.ts, which this push doesn't touch. I did not merge those helpers with the similar ones in other test files.
To try it, call the MCP tool crew_devices with {repo, action: "list"} on a repository you administer, using an admin-scope token. The SSH switch must be on.
🤖 Generated with Claude Code
I added one MCP tool,
crew_devices, that does what the…/crew-devicesAPI routes do. I rantsc,bun scripts/gate.ts --explainand the tests that cover the change, and all passed. That includedtest/mcp-size.test.ts; the tool's description is one sentence, so I didn't touch the ceilings. I did not run the full suite, so the forge's check will be the first to run it.What it does
crew_deviceswith{ repo, action: "list" | "add" | "grant" | "remove", device?, secret?, host_key? }. It needs an admin-scope token.src/actions/crew_devices.ts, so the permission checks are the same.listanswers{ items, sessions, next_cursor }, as the GET route does.addlists a device with the repo secret that holds its key.grantpins the host key, either the one you pass or the one the device shows right then. Only a site admin can grant, and an agent never can.removeunlists a device and takes its grant with it.not_found. A read-only token getsforbidden.listasks the person first when an agent holds the token. The confirmation wording is insrc/crew/conversation_ask.tsandsrc/crew/conversation_confirm.ts.What I chose not to do
src/tty.tscommand: that file doesn't exist. The terminal side is the Devices screen insrc/tui/screens/crewdevices.ts, which #3470 already built on the same actions, so I added nothing there. The commit line saysNo door: …for that reason.actionon an existing one: the only fit wasrepo_settings, whose description is already very long, so a new tool with a one-sentence description costs less.Tests and docs
test/mcp-crew-devices.test.tscovers the owner's list, add and remove, the site-admin-only grant, and the refusals for other users and read-only tokens.crew_devicesto the lists indelete-tier,mixed-actions-heldandmcp-forge-protocol.docs/features/crew-devices.mdanddocs/MCP.mdnow mention the tool.To try it: with an admin-scope token on a repository you administer, call
crew_deviceswith{ repo: "you/app", action: "list" }.The first push was refused for lacking a
Try:commit line, so I added an empty commit carrying it.🤖 Generated with Claude Code
Closes #3685