Repository navigation
feat(mcp): make MCP startup phase budgets configurable - #6304
Conversation
REA_MCP_INITIALIZE_BUDGET_MS, REA_MCP_TOOLS_LIST_BUDGET_MS, REA_MCP_FIRST_CATALOG_BUDGET_MS, and REA_MCP_DOCTOR_DEADLINE_MS keep today's defaults and refuse values outside 1 to 2147483647 ms. Codex's 30 second startup figure stays client guidance. Co-authored-by: morluto <morluto@users.noreply.github.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9256f1d260
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
[Medium impact] The PR appears safe to merge; no actionable new defects or rule violations were established. SummaryMakes four MCP startup budgets configurable while preserving their defaults.
No actionable new issues were found. The previous and current commits have different merge bases with the target, so the full PR diff was reviewed. No previous review threads were supplied. Tests were inspected but not run. Remote supersession status could not be checked because GitHub access was unavailable. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Selected environment] --> B[Parse four budgets]
B --> C{Valid?}
C -->|No| D[Report named configuration errors]
C -->|Yes| E[Doctor uses doctor deadline]
C -->|Yes| F[Probe starts first-catalog timer]
F --> G[Initialize within remaining time]
G --> H[List tools within remaining time]
F -->|Deadline expires| I[Fail probe and close child]
H --> J[Check measured durations]
Reviews (3) · Last reviewed commit: "Merge origin/main into cursor/mcp-startu..." · Reviewed by Greptile |
The packaged startup probe applied each phase timeout on its own and checked REA_MCP_FIRST_CATALOG_BUDGET_MS only after both requests finished. A shorter first-catalog budget now clamps the in-flight request and cancels it from one deadline measured at startup. Co-authored-by: morluto <morluto@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Keep the MCP startup budget settings and the first-catalog deadline. Take the regex worker heap setting, and attribute doctor timeouts from owned abort and SDK timeout facts. Co-authored-by: morluto <morluto@users.noreply.github.com>
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
Summary
Part of #6176. The MCP initialize, tools/list, first-catalog, and doctor phase budgets are now named settings. Unset behavior stays 15000, 5000, 20000, and 30000 ms. Codex's 30 second startup figure stays client guidance.
Problem and expected behavior
Those four phase budgets were fixed, and recovery said this release has no runtime override. Callers need named settings whose defaults are those constants. Invalid values must fail configuration and name the setting. They must not fall back to the default.
Unset behavior stays the current constants. A value from 1 to 2147483647 ms is the effective budget. Any other value fails startup, doctor,
rea mcp doctor, and client-registration configuration and names the setting. Setup copies a caller-selected value throughSELECTED_REGISTRATION_SETTINGS.Recovery names the setting, the effective milliseconds, the source (
defaultorsetting), the default, the floor, the maximum, and how to change it. Doctor recovery still says Codexstartup_timeout_secof 30 seconds is client guidance and that REA does not enforce that figure as the doctor deadline.REA_MCP_FIRST_CATALOG_BUDGET_MSbounds the whole initialize plus tools/list startup, including while either request is still pending. A value lower than a phase budget must stop that pending request. It must not wait until the longer phase timeout returns.Change and scope
src/config/mcpStartupBudgets.tsowns the four settings. Startup (parseEnvironment/parseConfig) and doctor use that schema.rea mcp doctorresolves the same parser from its selected environment before it starts a child. An invalid setting returns an unhealthy check named for that setting and does not launch the child.The packaged startup probe reads
resolveMcpStartupProbePolicyfrom the environment it is given, so a selected value is not ignored. The probe's recovery sentence is duplicated inscripts/lib/mcp-startup-probe.mjsbecause that script cannot import the TypeScript module; a test requires the two sentences to be identical. A synthetic probe budget carries its own source, so a 200 ms test budget issource settingand still names the real default.The probe measures one first-catalog deadline from the same instant as the phase durations. Each in-flight initialize or tools/list request uses the shorter of that phase's budget and the time still left. The recovery names that shorter bound. The deadline also rejects the probe when the SDK timeout has not started yet, and the existing close path stops the child. A completed run still fails when the measured total exceeds the first-catalog budget. The module profiler is unchanged: it has no first-catalog budget.
This branch includes current
main, includingREA_REGEX_WORKER_HEAP_REQUEST_MIB. Registration, environment parsing, and the related tests keep that setting together with the four phase budgets. Doctor timeout recovery still uses the phase budget, and it is attached only for an owned abort or an SDK request timeout.The floor is 1 ms. The maximum is 2147483647 ms, the largest delay Node schedules exactly. A larger
setTimeoutor SDK timeout is clamped to 1 ms, so it is refused. Zero, negative, non-decimal, and out-of-range values areconfiguration_invalid.codexStartupTimeoutSeconds(30),kimiStartupTimeoutMs(30000),toolOperationHeadroomMs(120000), anddoctorStderrBytes(64 KiB) stay fixed. They are not settings.Follow the contribution scope. This is configuration of existing MCP startup admissions. It does not add a provider or a capability that executes, injects, mutates, or recovers a target. Maintainer scope decision: not applicable. The product decision to make these ceilings settings is recorded in #6176.
Contract and boundary impact
src/config/mcpStartupBudgets.tsparses the settings;parseEnvironmentrejects them before provider startup.explicitSetupRegistrationEnvironmentpreserves a caller-selected value when setup writes a registration.runProductionMcpDoctorresolves them again before connecting.scripts/lib/mcp-startup-probe.mjsowns enforcement of those budgets on the packaged probe.rea mcp doctorand the packaged startup probe name the effective budget, source, default, floor, and maximum. Invalid settings fail the doctor report before a child starts.docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs andskills/; edit authored instructions in.agents/skills/reverse-engineer-anything/and never commit build outputs): client-configuration docs name the four settings. No tool catalog text changed.Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.
Evidence and regression coverage
16000,6000,21000, and31000when set and omits the initialize key when unset; public Codex and Kimi setup writes those values and still omitsREA_UNRELATED_MARKER. Probe timeouts of 200 ms and a 1 ms first-catalog budget namesource settingand the real default. A hanging initialize with a 250 ms first-catalog budget and an 8000 ms initialize budget names the first-catalog setting and returns before that initialize budget. A child that finishes initialize and then hangs, with an 800 ms first-catalog budget and an 8000 ms tools/list budget, leaves the initialize marker and names the first-catalog setting.rea mcp doctorwithREA_MCP_DOCTOR_DEADLINE_MS=2000and no caller deadline fired at that budget.0for initialize and doctor returns unhealthy checks named for those settings and does not start the missing child. Codex's 30 second constant remains 30 after an initialize override.source settinganddefault 30000 ms.The effective REA_MCP_DOCTOR_DEADLINE_MS value for the MCP doctor startup deadline is 30000 ms (source default; default 30000 ms, floor 1 ms, maximum 2147483647 ms). Set REA_MCP_DOCTOR_DEADLINE_MS in the environment that starts REA to a positive decimal integer from 1 to 2147483647, then restart REA.It then says Codexstartup_timeout_secof 30 seconds is client guidance. A selected 2000 ms deadline usessource settingand2000 ms. A probe that exceeds the first-catalog budget namesREA_MCP_FIRST_CATALOG_BUDGET_MSand the effective milliseconds.verify-packageworkflow was not executed. The probe tests use the production probe against the fixture child. Windows was not executed. A budget above the default was checked through the parser, setup registration, and the 60000 ms doctor deadline, not by waiting out a full 30 second packaged startup.For evidence-bearing changes:
Validation performed
origin/main(af924ca4b):npm run check:fast— typecheck and lint passed (2 tasks, 4.235s).npm run format:check— all matched files use the correct format.npm run test:local -- src/config/mcpStartupBudgets.test.ts src/application/Doctor.test.ts src/setupEnvironment.test.ts— 90 passed.npm run test:focused -- tests/boundary/mcp/mcpStartupPolicy.test.ts tests/boundary/mcp/mcpDoctor.test.ts tests/boundary/filesystem/clientConfigurationEnvironment.test.ts tests/acceptance/setup/registrationRuntimeEnvironmentCli.test.ts— 82 passed, 11 skipped. The pending tools/list first-catalog case completed in 808 ms.REA_MCP_DOCTOR_DEADLINE_MS=2000completed in 1923 ms. Remote timeout prose did not receive doctor deadline guidance. Codex and Kimi setup preserved the phase budgets andREA_REGEX_WORKER_HEAP_REQUEST_MIB.Compatibility, safety, and release
Author readiness
Human owner: @morluto
Before merge
type(scope): outcome.