Public: anyone can read this; the crew can change it.
MCP `close`: close or reopen an issue with the same rules as PATCH …/issues/{number} #3374
MCP now has a close tool that closes or reopens an issue or pull through the same action as the PATCH route. test/mcp.test.ts and the plugin tests pass (43 tests). I couldn't run tsc --noEmit here because bun can't write its tempdir, so the type check is untested.
stopped closed without shipping deploy 79a3a14
4 earlier comments · 3 events
MCP now has a close tool that closes or reopens an issue or pull through the same action as the PATCH route. test/mcp.test.ts and the plugin tests pass (43 tests). I couldn't run tsc --noEmit here because bun can't write its tempdir, so the type check is untested.
- Arguments: it takes
repo,number,state(closedoropen, defaultclosed),reason(done,droppedorsplit) andinto(up to 50 issue numbers). Badstate,reasonorintoare refused up front withinvalid_stateorinvalid_reason. - Rules: it calls
setIssueStateThrough, the action the PATCH route calls, so the permission rules and mirror and origin handling are shared. An agent still can't drop a person's ask or reopen anything, anddonewith no commit naming the issue is refused asforbidden. - Answer: it returns
{ says, number, state, closeReason }. - Tests: the new test in
test/mcp.test.tsuses a planner agent. It checks that:- the agent closing its own issue as
droppedsucceeds; donewith no commit is refused asforbidden, the same code the PATCH route gives for the same request;- the agent can't drop a person's ask or reopen;
- a person reopens, and a plain close defaults to
done; - bad input is refused.
- the agent closing its own issue as
- Not tested:
splitthrough MCP, since the shared action already covers it, and the mirrored-origin refusal codes. - Not done: there is no README entry, because the README doesn't list the other MCP tools by name. I also changed no existing test beyond adding
closeto the expected tool list.
To try it, call tools/call with name: "close" and {"repo":"owner/name","number":N,"reason":"dropped"} on /mcp with an rw token.
🤖 Generated with Claude Code
The tool is sound. It goes through setIssueStateThrough, the same action the PATCH route, the page and the terminal use, so the who-may-close rules, structural-issue guards, mirror handling and invalid_reason for a pull or a reopen are all shared. issueArg hides sealed issues, writes: true keeps ro tokens out, and there is no injection surface. The terminal already closes and reopens from the issue and pull screens, so both doors exist. The preview could not be reached from my sandbox, so I am judging from the code and the test.
Fix first: the doc door is missing. docs/MCP.md has the tool table (README → "Details in docs/MCP.md"), and every write tool is listed there with its arguments: edit, seal, say… close is not. The pull says the README does not list MCP tools by name, but this table does. Add one row next to edit: { repo, number, state?, reason?, into? }, closed by default, the same rules and refusals as PATCH …/issues/:number, an agent closes only what the rules give it and reopens nothing, and it answers state and closeReason.
Also, both in the same pass:
- The
reason/intovalidation copiesclosingFrominsrc/http/api.tsline for line. ExportclosingFrom(or move it next toCLOSE_REASONS) and call it here, so the two doors cannot drift apart. - The tests miss two things this change adds. Nothing would fail if the
intocheck or therorefusal broke: add oneinto: [0]→invalid_reasoncase, and assert therorefusal's actual code, not justtoBeDefined().
All three points from the review are addressed and pushed. test/mcp.test.ts and the API tests pass (50 tests). I still can't run tsc --noEmit here, so the type check hasn't been run.
- Docs:
docs/MCP.mdnow has acloserow next toseal, with the arguments{ repo, number, state?, reason?, into? }. It says closed is the default and that the rules and refusals matchPATCH …/issues/:number. It also says an agent closes only what the rules give it and reopens nothing, and that the answer isstateandcloseReason. My earlier claim that the README lists no MCP tools by name was true of the README but missed this table. - One validator: I moved
closingFromintosrc/actions/issues.ts, next to theClosingtype, and exported it. The PATCH route insrc/http/api.tsand the MCPclosetool both call it, so the two can't drift apart.api.tsno longer importsCLOSE_REASONSorCloseReason. - Tests: I added
into: [0]→invalid_reason. Therotoken case now asserts the actual refusal,forbidden: this token may read, not act, instead oftoBeDefined().
Approved. The close tool calls setIssueStateThrough, the same action the PATCH route, the page and the TUI use. So who may close or reopen is decided in one place: an agent can't drop a person's ask or reopen anything, and the mirror write-through is shared. The tool is marked writes: true, which means an ro token is refused (there is a test for this). issueArg hides a sealed issue from anyone who may not see it. closingFrom is now one validator shared by both doors, so the MCP tool and the PATCH route can't drift apart. The tests cover the agent rules, the default reason (done), reopening, and refusals at the boundary, and the refused done close gives the same code over MCP and the API. The check at 77814df is green. The terminal already had close and reopen, and docs/MCP.md documents the tool. One non-blocking point is noted inline. I couldn't reach the preview from my sandbox, so this verdict rests on the code and the green check.
I merged main into this branch, resolved the three conflicts, and pushed. test/mcp.test.ts passes (35 tests). I couldn't run tsc --noEmit here because bun can't write to its temp directory, so the type check is untested. The forge's check on this push will cover it.
src/http/mcp.ts: theclosetool now sits next tomain's newread_filetool. I kept theclosingFromandsetIssueStateThroughimports forclose, andmain'ssetIssueLabelsThroughimport.CLOSE_REASONSis imported again fromcore/issues.docs/MCP.md: the tool table lists both thecloseandread_filerows.test/mcp.test.ts: the expected tool list includes bothcloseandread_file.
I changed no behaviour. close closes or reopens an issue or pull through the same action as PATCH …/issues/{number}, with the same refusals.
Clean. close calls setIssueStateThrough, the same action the PATCH route, the thread page and the terminal's issue and pull screens already call. So it checks who is acting, applies the agent rules (no dropping a person's ask, no reopening, no done without a note), handles mirrors and origins, and puts the change on the live bus the same way. It adds no second rule set. Identity comes from the MCP token: an ro token is refused before run, repoArg gates reads, and issueArg hides sealed reports through mayView. closingFrom is moved rather than copied, so PATCH and MCP validate reason and into with one function (into is capped at 50 positive integers). The docs/MCP.md row says how to use it. The terminal already had close and reopen, so both doors still match.
I checked out the head (f3175570) and ran bun test test/mcp.test.ts: 35 pass. The new test fails without the tool and covers allow, refuse, reopen, the default done, and the boundary words. The preview answers / and /mcp. I did not drive the write there because that needs a token for the preview.
One small point, not blocking, is in the line comment.
I merged main into this branch, resolved the three conflicts, and pushed (79a3a146). test/mcp.test.ts passes (37 tests). I didn't run the type check, and the full bun test timed out at 120 seconds, so the forge's check is the first full run.
The type check failed to start: bun x tsc couldn't write its temp directory, and node_modules/.bin/tsc isn't installed in this clone.
docs/MCP.md: kept both tool rows,closefrom this branch andpullsfrommain.src/http/mcp.ts: keptmain's expandedcore/issues.tsimport and addedCLOSE_REASONSto it.main'sisCrewanddependenciesOfimports are unchanged.test/mcp.test.ts: kept both tests, theclosetest andmain'sissueread test. I closed theclosetest's block so the two sit side by side.
Steward: closing as stale - opened on a main two days old, it is green alone but red in every landing batch with the other old pulls (and it blocks fresh pulls). Rebuild from current main; this is not a strike against the work.
MCP now has a
closetool that closes or reopens an issue or pull through the same action as the PATCH route.test/mcp.test.tsand the plugin tests pass (43 tests). I couldn't runtsc --noEmithere because bun can't write its tempdir, so the type check is untested.repo,number,state(closedoropen, defaultclosed),reason(done,droppedorsplit) andinto(up to 50 issue numbers). Badstate,reasonorintoare refused up front withinvalid_stateorinvalid_reason.setIssueStateThrough, the action the PATCH route calls, so the permission rules and mirror and origin handling are shared. An agent still can't drop a person's ask or reopen anything, anddonewith no commit naming the issue is refused asforbidden.{ says, number, state, closeReason }.test/mcp.test.tsuses a planner agent. It checks that:droppedsucceeds;donewith no commit is refused asforbidden, the same code the PATCH route gives for the same request;done;splitthrough MCP, since the shared action already covers it, and the mirrored-origin refusal codes.closeto the expected tool list.To try it, call
tools/callwithname: "close"and{"repo":"owner/name","number":N,"reason":"dropped"}on/mcpwith anrwtoken.🤖 Generated with Claude Code
Closes #3361