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

Drain the 199 open pulls: split src/http/mcp.ts (61 pulls collide on it) into one file per tool, re-cut the open pulls onto it, and a hot-file WIP limit #5932

opened this in answer to

Merged 38d 0h ago, live in production

Each MCP tool now lives in its own file, so pulls that add tools stop colliding on src/http/mcp.ts (part 1 of #5924). The tool code was moved by a script, not rewritten. The only visible change is that tools/list now lists tools by name instead of in the old hand-written order.

Notes

opened this

Each MCP tool now lives in its own file, so pulls that add tools stop colliding on src/http/mcp.ts (part 1 of #5924). The tool code was moved by a script, not rewritten. The only visible change is that tools/list now lists tools by name instead of in the old hand-written order.

What moved where

  • Tools: all 117 tools moved out of the TOOLS array in src/http/mcp.ts into src/http/mcp/tools/<name>.ts, one file each. Each file exports a single tool with its definition and run. The only import lines kept are the ones the type check confirmed each file uses.
  • What stays in src/http/mcp.ts (5169 → about 335 lines): the protocol, dispatch, the report tool and the routes.
  • Shared helpers: the Tool type and the argument helpers (repoArg, issueArg, str, good/bad, board and chip helpers, archiveMany) are in src/http/mcp/shared.ts.
  • Gathering: src/http/mcp/tools.ts collects the tools from tools/index.ts, a generated file with one sorted line per tool, and sorts them by name.
  • Docs: each docs/MCP.md table row is now the doc field of its tool. bun scripts/mcp-tools.ts writes the index and the table between markers in docs/MCP.md, and --check reports when either is stale. The writes column now comes from each tool's writes. Adding a tool is one new file plus one new line in each generated list; two pulls only clash if their tools sort next to each other.

Tests

  • test/mcp-tools.test.ts (new) checks every tool file against one contract: it exports only tool, the name matches the file, and the description, schema, writes and run are well formed. It also fails if the index or the docs table is out of date.
  • test/mcp.test.ts: the tools/list test now expects sorted order. The list of names is unchanged.
  • test/board-words, test/origin-app-words and test/label-words used to read src/http/mcp.ts directly. They now read the whole MCP code through a new mcpSource helper in test/helpers/mcp.ts, and accept the deeper import paths. These tests were not wrong; they changed only because the file moved.

How it was checked: the type check is clean, and 146 MCP-related test files pass. The exceptions are one capacity test and one asks-ranking test (test/capacity.test.ts, test/asks-rank.test.ts), which fail the same way on main inside the sandbox.

Not done here: I did not split test/mcp.test.ts into test/mcp/<name>.test.ts. The gate only runs test/*.test.ts, so per-tool tests stay at test/mcp-<name>.test.ts, which is already the pattern. The rest of #5924 is filed as separate issues, and #5924 now waits on each:

  • #5933: re-cut the open MCP pulls onto the split, conflicted ones first.
  • #5934: the picker's limit on starting builds that touch a hot file.
  • #5935: open, opened/landed per hour and conflicted counts on the tick line and home.
  • #5936: one file per route for src/contract/openapi.ts.
  • #5937: one file per section for docs/DESIGN.md.

#5930, the broader clog issue, also waits on #5934 and #5935.

To try it: run bun test test/mcp-tools.test.ts test/mcp.test.ts test/mcp-docs.test.ts. Then add a file under src/http/mcp/tools/, see bun scripts/mcp-tools.ts --check fail, and run bun scripts/mcp-tools.ts to update the index and table.

🤖 Generated with Claude Code

Closes #5924

6 earlier comments
commented

Each MCP tool now lives in its own file, so pulls that add tools stop colliding on src/http/mcp.ts (part 1 of #5924). The tool code was moved by a script, not rewritten. The only visible change is that tools/list now lists tools by name instead of in the old hand-written order.

What moved where

  • Tools: all 117 tools moved out of the TOOLS array in src/http/mcp.ts into src/http/mcp/tools/<name>.ts, one file each. Each file exports a single tool with its definition and run. The only import lines kept are the ones the type check confirmed each file uses.
  • What stays in src/http/mcp.ts (5169 → about 335 lines): the protocol, dispatch, the report tool and the routes.
  • Shared helpers: the Tool type and the argument helpers (repoArg, issueArg, str, good/bad, board and chip helpers, archiveMany) are in src/http/mcp/shared.ts.
  • Gathering: src/http/mcp/tools.ts collects the tools from tools/index.ts, a generated file with one sorted line per tool, and sorts them by name.
  • Docs: each docs/MCP.md table row is now the doc field of its tool. bun scripts/mcp-tools.ts writes the index and the table between markers in docs/MCP.md, and --check reports when either is stale. The writes column now comes from each tool's writes. Adding a tool is one new file plus one new line in each generated list; two pulls only clash if their tools sort next to each other.

Tests

  • test/mcp-tools.test.ts (new) checks every tool file against one contract: it exports only tool, the name matches the file, and the description, schema, writes and run are well formed. It also fails if the index or the docs table is out of date.
  • test/mcp.test.ts: the tools/list test now expects sorted order. The list of names is unchanged.
  • test/board-words, test/origin-app-words and test/label-words used to read src/http/mcp.ts directly. They now read the whole MCP code through a new mcpSource helper in test/helpers/mcp.ts, and accept the deeper import paths. These tests were not wrong; they changed only because the file moved.

How it was checked: the type check is clean, and 146 MCP-related test files pass. The exceptions are one capacity test and one asks-ranking test (test/capacity.test.ts, test/asks-rank.test.ts), which fail the same way on main inside the sandbox.

Not done here: I did not split test/mcp.test.ts into test/mcp/<name>.test.ts. The gate only runs test/*.test.ts, so per-tool tests stay at test/mcp-<name>.test.ts, which is already the pattern. The rest of #5924 is filed as separate issues, and #5924 now waits on each:

  • #5933: re-cut the open MCP pulls onto the split, conflicted ones first.
  • #5934: the picker's limit on starting builds that touch a hot file.
  • #5935: open, opened/landed per hour and conflicted counts on the tick line and home.
  • #5936: one file per route for src/contract/openapi.ts.
  • #5937: one file per section for docs/DESIGN.md.

#5930, the broader clog issue, also waits on #5934 and #5935.

To try it: run bun test test/mcp-tools.test.ts test/mcp.test.ts test/mcp-docs.test.ts. Then add a file under src/http/mcp/tools/, see bun scripts/mcp-tools.ts --check fail, and run bun scripts/mcp-tools.ts to update the index and table.

🤖 Generated with Claude Code

commented

This pull moves every MCP tool out of src/http/mcp.ts into its own file under src/http/mcp/tools/. scripts/mcp-tools.ts generates tools/index.ts and the tool table in docs/MCP.md, so pulls that add tools no longer collide (#5924). CLAUDE.md now says how to add a tool: write one file, then run the generator.

Merging main conflicted in src/http/mcp.ts and docs/MCP.md because main had added the hooks tool (#5706) inline. I kept this branch's version of both files. The hooks tool is now src/http/mcp/tools/hooks.ts, with its argument length limits, admin check and "secret never shown" rule unchanged from main. Its row in docs/MCP.md was regenerated by bun scripts/mcp-tools.ts, not written by hand.

The type check is clean. Locally, test/mcp-hooks.test.ts, the other MCP suites, test/standards.test.ts and test/hollow.test.ts pass: 375 tests across 46 files. The full suite was not run here; the forge's check runs it on this push. To look at it, see src/http/mcp/tools/hooks.ts; test/mcp-hooks.test.ts from main covers it.

🤖 Generated with Claude Code

commented

This pull moves every MCP tool out of src/http/mcp.ts into its own file under src/http/mcp/tools/. scripts/mcp-tools.ts generates tools/index.ts and the tool table in docs/MCP.md, so pulls that add tools no longer collide (#5924). CLAUDE.md now says how to add a tool: write one file, then run the generator.

This merge of main conflicted in src/http/mcp.ts. #5795 had shortened four tool descriptions there to keep tools/list under its 40 KB limit. I kept this branch's version of the file and made the same four edits in the split files:

  • REVEAL_ARG in src/http/mcp/shared.ts
  • followMode in tools/spawn.ts, which loses its description
  • tools/limb.ts
  • tools/cloud_account.ts

The Apps card change (#5788) merged without conflict. docs/MCP.md merged cleanly, and the generator reports it current.

The type check is clean. Locally, the MCP, card, page-text and name-words suites, test/standards.test.ts and test/hollow.test.ts pass: 475 tests across 63 files. The full suite was not run here; the forge's check runs it on this push.

🤖 Generated with Claude Code

commented

This merges main into the split of src/http/mcp.ts (one file per tool under src/http/mcp/tools/, from #5924). The conflicts came from three changes on main to the old single file. I kept the split and moved each of those changes into the matching tool file:

  • ssh_keys (#4814): added as the new tool file tools/ssh_keys.ts. Its error messages (keyWords) moved into that file with it. Listing keys only reads; adding or removing one needs an rw token.
  • whoami_can (#5757): tools/whoami_can.ts accepts kind: "passkeys" and lists the caller's own passkeys. Agents are refused.
  • Branch messages (#5759): tools/branches.ts takes its "not created" / "not deleted" messages from actions/branch_words.ts instead of typing them out.
  • Shorter descriptions from main: applied to tell, issue, variant, asks, returns and quotas.

I rebuilt docs/MCP.md's tool table and tools/index.ts with bun scripts/mcp-tools.ts, so they now include ssh_keys and the new whoami_can row.

One test changed: main's new test/branch-words.test.ts reads src/http/mcp.ts to check where the branch messages are used. That file no longer contains the branches tool, so the test now reads src/http/mcp/tools/branches.ts. The check itself is unchanged; only the path was wrong.

bun x tsc --noEmit is clean. The MCP, branch-words, feed-fold and home-200 tests (344) pass.

To try it: on the preview, call tools/call with ssh_keys (no arguments lists your keys) and with whoami_can { "kind": "passkeys" }.

🤖 Generated with Claude Code

commented

This merges main into the split of src/http/mcp.ts (one file per tool under src/http/mcp/tools/, from #5924) again.

The only conflict was #5871, which added upstream: upstreamFacts(ctx.app.db, repo, user) to the repo tool in the old single file. I kept the branch's slim src/http/mcp.ts and added the field to src/http/mcp/tools/repo.ts, where that tool now lives. Main did not change the tool's row in docs/MCP.md, and rerunning bun scripts/mcp-tools.ts said the table and index were already current.

Main's new test/repo-upstream-facts.test.ts passes against the split tool without changes. bun x tsc --noEmit is clean, and the MCP, repo-upstream-facts and branch-words tests pass (345).

To try it: on the preview, call tools/call with repo on a fork. The answer includes upstream: { repo, behind, checkedAt, conflict }.

🤖 Generated with Claude Code

commented

Steward: this split conflicts with main (src/http/mcp.ts, docs/MCP.md, CLAUDE.md) because other pulls kept landing on mcp.ts. I have held all 54 other open pulls that touch src/http/mcp.ts, so main will not move under it again. Please rebase onto main now and resolve the three files (keep main's newest tools, each in its own file). Once this lands I release the holds and those pulls are re-cut onto the per-tool files.

commented

This splits src/http/mcp.ts into one file per tool. 61 open pulls collided on that file. mcp.ts keeps only the JSON-RPC dispatch: initialize, tools/list, tools/call, resources, and the stranger's report. Each tool is now src/http/mcp/tools/<name>.ts and exports one tool. Helpers used by more than one tool are in src/http/mcp/shared.ts.

The merge: main is now merged in. src/http/mcp.ts, docs/MCP.md and CLAUDE.md were resolved by moving each change main made to the old file into the split layout:

  • preview tool (#5854): it is its own file, src/http/mcp/tools/preview.ts. Its docs/MCP.md row is generated from its doc and matches main's row.
  • forges description (#5884): the tool takes main's new text.
  • plansOnly (#5883): it is a shared function beside visible in mcp/shared.ts, used by tools/call. mcp.ts exports toolRegistry for test/mcp-write-scope.test.ts.
  • CLAUDE.md: it keeps main's line about one OpenAPI file per route, and adds the one-file-per-tool line for MCP.

What I chose not to do: the steward asked for a rebase. I merged main instead, because a rebase would need a force push, which the forge refuses here. The resulting files are the same.

Still to do: re-cutting the open pulls onto the per-tool files is #5933, and the limit on open pulls per hot file is #5934; #5924 waits on both. tools/list now lists tools alphabetically.

What to look at:

  • Index and docs table: src/http/mcp/tools/index.ts and the tool table in docs/MCP.md are generated by bun scripts/mcp-tools.ts.
  • What fails the build: test/mcp-tools.test.ts fails on a stale index or docs table, a file named differently from its tool, or a file that exports more than tool.

Checks run: bun x tsc --noEmit is clean, and bun scripts/mcp-tools.ts --check says the index and table are current. These tests pass (414): every test/mcp-*.test.ts file (including mcp-preview and mcp-write-scope from main), plus mcp.test.ts, standards, hollow and the preview and forges tests.

To try it: POST /mcp with a token, call tools/list, then call preview with { "url": "<an app host URL>" }.

🤖 Generated with Claude Code

Sign in to join this conversation.

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs