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

An outsider's first MCP call is timed: start, contribute and find_tool each answer under 50 ms warm, held by a test #14716

Merged opened this

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

Merged

This adds test/mcp-first-calls-timing.test.ts. It times contribute() and findtool() warm, ten calls each, over real /mcp HTTP. Median must be under 50 ms and the worst under 250 ms.

Notes

shipped production is serving it deploy 4ec2c16

opened this

This adds test/mcp-first-calls-timing.test.ts. It times contribute() and find_tool() warm, ten calls each, over real /mcp HTTP. Median must be under 50 ms and the worst under 250 ms. The new test, test/mcp-size.test.ts, bun scripts/gate.ts --fix and bun x tsc --noEmit all pass. I ran only those, not the full suite.

  • Result: both calls are already under the ceilings, so no read was cut or cached and src/http/mcp/reads.ts is untouched.
  • Server-Timing: the server already sets a server-timing header with dur= on every response. The test asserts it on each call's first answer, and nothing new was added. src/http/measure.ts turned out to be the page-view beacon, not a Server-Timing helper, so I did not touch it.
  • start: not timed. The checklist names only contribute and find_tool, and start creates an account, a repo and an app on every call.
  • find_tool: called with a read-only token, since it is not token-free.
  • Worst-case ceiling: I set 250 ms so one stalled call on a loaded machine does not fail the test, while a slow query still pushes the median over 50 ms.
  • Query counts: I did not add them. test/route-timing.test.ts is the only test that counts database time, and it works on pages rather than MCP calls, so I stuck with time ceilings.

Try it: bun test test/mcp-first-calls-timing.test.ts

Closes #14703

commented

This adds test/mcp-first-calls-timing.test.ts. It times contribute() and find_tool() warm, ten calls each, over real /mcp HTTP. Median must be under 50 ms and the worst under 250 ms. The new test, test/mcp-size.test.ts, bun scripts/gate.ts --fix and bun x tsc --noEmit all pass. I ran only those, not the full suite.

  • Result: both calls are already under the ceilings, so no read was cut or cached and src/http/mcp/reads.ts is untouched.
  • Server-Timing: the server already sets a server-timing header with dur= on every response. The test asserts it on each call's first answer, and nothing new was added. src/http/measure.ts turned out to be the page-view beacon, not a Server-Timing helper, so I did not touch it.
  • start: not timed. The checklist names only contribute and find_tool, and start creates an account, a repo and an app on every call.
  • find_tool: called with a read-only token, since it is not token-free.
  • Worst-case ceiling: I set 250 ms so one stalled call on a loaded machine does not fail the test, while a slow query still pushes the median over 50 ms.
  • Query counts: I did not add them. test/route-timing.test.ts is the only test that counts database time, and it works on pages rather than MCP calls, so I stuck with time ceilings.

Try it: bun test test/mcp-first-calls-timing.test.ts

Approved

Test-only change; no page, no preview surface. It times contribute() and find_tool() warm over real /mcp HTTP, ten runs each, median < 50 ms, worst < 250 ms, and asserts a server-timing dur= on the first answer. It matches the issue, adds no dependency and no dead code, and the contribute call needs no identity while find_tool uses a read-only token. Two things I would do next: (1) the wall-clock ceilings can flake on a loaded CI box, and the direction says tests never flake, so consider asserting the median of the server-reported dur values, or retrying the whole batch once before failing; (2) tidy the helper: text does not return text (rename it ask), drop the as any, and fix the garbled header comment about Server-Timing. Also time start in a follow-up if the issue title is meant to cover it; the boxes name only contribute and find_tool.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs