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

The MCP list tools refuse a bad limit with one code and the maximum their schema promises #14423

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

pulls, commits, issues and queuegates now read limit through one shared helper and refuse a bad one with invalidlimit and limit is a whole number from 1 to N. The new test, test/mcp-size.test.ts and the existing pulls, commits, issues, doc-parity and doctor-doors tests pass, and tsc is clean.

Notes

shipped production is serving it deploy 404563e

opened this

pulls, commits, issues and queue_gates now read limit through one shared helper and refuse a bad one with invalid_limit and limit is a whole number from 1 to N. The new test, test/mcp-size.test.ts and the existing pulls, commits, issues, doc-parity and doctor-doors tests pass, and tsc is clean. I did not run the full suite.

What changed

  • parseLimitValue in src/contract/page_query.ts is the same rule parseLimit applies to a query string, but for a JSON argument. A whole number from 1 to the maximum passes, and a string like "7", a 1.5 or a 0 is refused. A new limitArg in src/http/mcp/shared.ts wraps it and builds the invalid_limit refusal through limitSays, the same function the HTTP routes use for that message.
  • The four tools call limitArg. The maximums are pulls 50 with repo, commits 100, issues 200 and queue_gates 100. pulls, commits and queue_gates used to answer invalid. issues already answered invalid_limit.
  • pulls' schema maximum goes from 200 to 50, with the description "with repo; 200 without". I took the handler's number as truth, as the issue's risk note says. Without repo the pile still takes up to 200 through pageRows. The schema now says 50 and the description carries the 200, so a client that reads only maximum will not try more than 50 in that mode.
  • test/mcp-limit.test.ts runs one test per tool. It reads the maximum from the tool's own schema, then checks that the maximum and 1 pass, and that maximum+1, 0, 1.5 and "7" give invalid_limit naming that maximum.

What I left alone

  • person and pins keep their own badLimit helper. They were not in the issue.
  • I raised no ceiling and added no tool. The only added schema text is the short pulls description.

Things to check

  • The push needed a commit message containing Try:, so I added an empty commit carrying it.

Try it: call pulls with repo and limit: 51, or any of the four tools with limit: "7". Each answers invalid_limit.

Closes #14417

2 earlier comments
commented

pulls, commits, issues and queue_gates now read limit through one shared helper and refuse a bad one with invalid_limit and limit is a whole number from 1 to N. The new test, test/mcp-size.test.ts and the existing pulls, commits, issues, doc-parity and doctor-doors tests pass, and tsc is clean. I did not run the full suite.

What changed

  • parseLimitValue in src/contract/page_query.ts is the same rule parseLimit applies to a query string, but for a JSON argument. A whole number from 1 to the maximum passes, and a string like "7", a 1.5 or a 0 is refused. A new limitArg in src/http/mcp/shared.ts wraps it and builds the invalid_limit refusal through limitSays, the same function the HTTP routes use for that message.
  • The four tools call limitArg. The maximums are pulls 50 with repo, commits 100, issues 200 and queue_gates 100. pulls, commits and queue_gates used to answer invalid. issues already answered invalid_limit.
  • pulls' schema maximum goes from 200 to 50, with the description "with repo; 200 without". I took the handler's number as truth, as the issue's risk note says. Without repo the pile still takes up to 200 through pageRows. The schema now says 50 and the description carries the 200, so a client that reads only maximum will not try more than 50 in that mode.
  • test/mcp-limit.test.ts runs one test per tool. It reads the maximum from the tool's own schema, then checks that the maximum and 1 pass, and that maximum+1, 0, 1.5 and "7" give invalid_limit naming that maximum.

What I left alone

  • person and pins keep their own badLimit helper. They were not in the issue.
  • I raised no ceiling and added no tool. The only added schema text is the short pulls description.

Things to check

  • The push needed a commit message containing Try:, so I added an empty commit carrying it.

Try it: call pulls with repo and limit: 51, or any of the four tools with limit: "7". Each answers invalid_limit.

commented

The check failed on the "both doors" rule, because the pull edits MCP files and nothing under src/tui/. I pushed a new commit with a No door: line saying why, and I have not seen the forge's re-run yet.

This change only makes four existing MCP list tools refuse a bad limit the same way. It adds nothing for the terminal to reach.

bun scripts/gate.ts --fix changed nothing on this run. It still prints the "both doors" rule failing locally, because it reads the pull's diff and not the commit messages. The forge's check is what counts, and the No door: line is the exit the rule itself offers. If the forge reads that commit and the rule still fails, the cause is something else.

It also notes one comment line over 100 columns in src/http/mcp/tools/pulls.ts. The gate says that needs no action, and the nightly rewrap fixes it on main.

The description I gave earlier still stands.

commented

The MCP list tools now refuse a bad limit with invalid_limit and name the maximum they enforce. The check was red because docs/MCP.md was stale.

  • Cause: I lowered the pulls schema limit to its repo-mode 50 earlier on this branch. The generated tool table in docs/MCP.md still showed the old limit.
  • Fix: I regenerated it with bun scripts/mcp-table.ts and pushed (commit 3fa1c1b64).
  • Other two failures: "standby answers 503…" (test/maintenance.test.ts) and "the guides are read once…" did not reproduce. test/maintenance.test.ts passes locally, and I ran the guides test alone through test/llms-full.test.ts, which also passes. test/maintenance.test.ts was the slowest test in the log at 5.1 s, so it may have been load. I did not investigate the guides test further.
  • Checks run: test/mcp-table.test.ts and test/maintenance.test.ts pass, and tsc --noEmit is clean. I did not run scripts/gate.ts or the rest of the suite.

To try it, call pulls, commits, issues or queue_gates with limit 51 or "7" and read invalid_limit.

Approved

Clean. The four tools read limit through one helper (limitArg over parseLimitValue), the refusal is invalid_limit with the shared limitSays text, schema maxima match the handlers (pulls 50 with repo, described as 200 without), and the test covers max, 1, max+1, 0, 1.5 and "7" per tool. No security surface changed, no ceiling raised, no new tool. Non-blocking: pulls without repo (the pile) goes through pageRows and is not covered by the new test; it still hand-rolls its own check.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs