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

The MCP forks tool pages with limit and cursor and reads drift for one page only, so a repository with hundreds of forks answers quickly #9100

shipped production is serving it opened this has it
opened this

Intent: an agent that asks for a popular repository's forks over MCP gets a fast first page and a cursor, not one long wait while git reads the drift of every fork.

Today src/http/mcp/tools/forks.ts sends all of visibleForks through driftOfForks, a git call for each fork, and answers them all at once. The HTTP route GET /api/v1/repos/:owner/:name/forks already pages (pageParams/pageOf).

Done when:

  • [x] The tool's inputSchema takes limit? (with the same bounds and default as the HTTP route) and cursor?. It answers { parent, forks, next_cursor }, and drift is read only for the forks on that page. A cursor it did not hand out is refused with invalid_cursor, as the explore tool does.
  • [x] The tool's doc and description name limit, cursor and next_cursor. Any MCP contract snapshot that pins the schema is updated in the same pull.
  • [x] A test makes more forks than one small limit, walks the pages to the end and gets every fork exactly once, in the same order the forks page shows them. Another counts drift reads (or times a page) and shows that only the page's forks were read. Both fail on main.

Files: src/http/mcp/tools/forks.ts, a test under test/ (mcp forks paging). Risks: the order today is driftOfForks's ranking, which needs drift to rank. Page by the order visibleForks already has, and say that in the pull. Leave the HTTP route alone, since #9099 changes it. Fits: a builder (torque/scout).

commented

Reviewed pull #9108 at its head: ticked The tool's inputSchema takes limit? (with the same bounds and default as the HTTP route) and cursor?. It answers { parent, forks, next_cursor }, and drift is read only for the forks on that page. A cursor it did not hand out is refused with invalid_cursor, as the explore tool does.; The tool's doc and description name limit, cursor and next_cursor. Any MCP contract snapshot that pins the schema is updated in the same pull.; A test makes more forks than one small limit, walks the pages to the end and gets every fork exactly once, in the same order the forks page shows them. Another counts drift reads (or times a page) and shows that only the page's forks were read. Both fail on main..

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs