Repository navigation
feat: support MCP 2026-07-28 over stdio - #350
Conversation
## Problem MCP 2026-07-28 carries version and capabilities on each request. A modern client can discover a server but Box refuses its tools/list because no initialize handshake occurred. The time server reproduces the failure with Claude Code. ## Solution Validate modern request metadata and route its requests through the existing catalog and policy admission. Preserve legacy error and timeout fallback. Validate modern replies before catalog capture. Bind input-answer retries to original parameters and server state, decide each nested method, and record a response event only for the terminal reply. Bound pending state and retain cancelled IDs until their late reply arrives. Probe modern servers during offline schema discovery. Update the MCP operator and mechanism documentation. The user authorizes the MCP protocol behavior change. No configuration key, policy action name, containment rule, or broker framing changes. Protocol extension result types remain refused until their semantics can be validated. ## Tests modern_stdio_lists_and_calls_with_or_without_discovery proves modern startup. modern_metadata_is_checked_on_every_request pins version and capability checks. modern_tool_calls_still_require_catalog_and_policy_admission and modern_tool_arguments_still_meet_the_generated_policy_action pin policy checks. modern_input_answers_are_correlated_and_decided_before_forwarding pins nested policy admission, retry identity, and terminal response accounting. modern_pending_request_and_continuation_limits_are_enforced and modern_input_requests_require_capabilities_and_unambiguous_methods pin bounds. modern_cancellation_ignores_late_replies_and_reserves_the_id pins cancellation. a_failed_modern_probe_can_fall_back_to_the_legacy_handshake and a_pending_probe_does_not_prevent_legacy_timeout_fallback pin legacy fallback. Offline discovery tests pin modern pagination, modern errors, legacy fallback, and rejection of partial frames across timeout. The schema generation suite passes all 20 cases. Adversarial mutation tests prove each new regression fails when its relevant behavior is removed or broken. Package and helper builds, no-default-features build, formatting, and clippy pass. Clippy has no owned warnings; six existing vendored Shell warnings remain. The deterministic suite has 129 passes and 12 declared Linux-only skips. The full workspace run is still in progress when this draft commit is created. Three runtime_mcp_policy_staging concurrency tests time out in the parallel run; isolated reruns remain pending. These cases do not use the modern discovery probe. A filesystem test passes after an overlapping build stops replacing its helper. The Linux cross-check lacks the target standard library. No Linux success is claimed. Live tests against this commit follow after the draft PR is opened. Preliminary contained modern and legacy probes pass; Claude startup still times out before its tool catalog is available. This does not establish Claude end-to-end success.
|
Assessment: Request Changes Admission, retry binding, and legacy compatibility work as described. There are two lifecycle gaps: continuations that clients abandon eventually make the connection fail, and a slow-starting modern-only server fails offline discovery. Both are reproduced in local tests and described in the inline comments. What I checked and found correct
The tests are thorough on the refusal paths. The gaps above are lifecycle cases that they do not cover yet. |
|
Assessment: Approve (re-review of d15ee53 against 95a9ea2) Both lifecycle issues from the previous review are fixed, and each fix has a regression test. I found no new correctness issues in the follow-up commit. All 24 What I checked and found correct
|
A cancelled modern call's late reply was dropped without recording mcp:call::response, so an agent could cancel each call right after sending it and keep calls the server ran out of ::response budgets and sequencing rules. The broker still hides the late reply from the client, but now records the response leg unless the reply is a valid input_required.
|
Assessment: Request Changes (re-review of 9b1d373 against d15ee53) The new commit 1961973 correctly records the response leg for a cancelled call when its late reply arrives. It has an unhandled case: a cancelled request whose late reply never comes. That case fills the modern pending cap (see the inline comment, reproduced locally). This was already true at d15ee53, and I missed it last round. What I checked and found correct
|
|
Assessment: Request Changes (re-review of 0eba8c9 against 9b1d373) The pending-slot exhaustion from last round is fixed. One case is still open: the cancellation bypass that 1961973 targets still works against servers that drop the reply to a cancelled call, which is how the TypeScript SDK behaves (see the inline comment, reproduced locally). All 28 What I checked and found correct
|
|
Assessment: Comment (re-review of cc4ae8d against 0eba8c9) The cancellation bypass is closed. I found no new correctness problem in this commit. All 54 What I checked and found correct
|
Description
MCP
2026-07-28clients do not sendinitialize. Box required that handshake beforetools/list, so these clients connected but could not use any tools.This adds support for the request metadata, results, and input-answer retries used by that protocol. Requests still pass the catalog and policy checks. A retried call is admitted before its input answers. Continuations retain at most 64 retry allowances, including separate allowances for identical calls. At capacity, a new continuation replaces the oldest allowance. A policy-denied retry releases its allowance. Neither case closes the connection.
Legacy handshakes remain supported. Offline schema discovery probes the server and falls back according to the MCP compatibility rules. If the server closes stdout without replying, discovery restarts it once with
initializefirst. A valid discovery reply that arrives during the fallback handshake selects a fresh process using modern requests, even if the initialize error arrives first. These paths share one restart within the original deadline. Partial or malformed replies fail discovery. Duplicate JSON keys in server frames are now rejected for both protocol paths.A server can finish work and suppress its reply after cancellation. Waiting for that reply left executed calls outside response-based policy budgets. Cancelling a modern admitted item call now records one indeterminate
mcp:call::responseimmediately. Late replies add no second event, includinginput_required. Connection shutdown records remaining admitted item calls after the server stops, and terminal replies are recorded before client delivery can fail. This follows the existing policy rule that uncertain outcomes count; an MCP response does not prove tool success. A validinput_requiredreceived before cancellation still records no response. The broker forwards the final buffered frame before closing server stdin and refuses input after EOF, so definitely unsent calls cannot create response events.Cancellation also releases the request's active slot. Up to 1,024 cancelled request IDs remain reserved for late replies, with the operator-approved 16 MiB budget for retained strings. Exceeding either limit closes the connection and stops the server; other calls may be interrupted and the client must reconnect. The triggering call's outcome is recorded before checking either limit.
The tool-grammar test fixtures now compile small native programs with known exit codes. macOS rejected a copied Apple
falseexecutable with a code-signature violation during validation; the replacement preserves contained execution and the existing status and policy assertions.Configuration keys, policy action names, and Box broker framing are unchanged. The MCP user and design docs cover the behavior and limits.
Related Issues
None linked.
Type of Change
New feature
Testing
Passed on this fix: Box and Policy builds with all features; Box without default features; Policy default and no-default builds; Policy default tests (415 passed, six existing ignored); Policy default clippy; and warning-fatal Policy documentation in both feature modes.
MCP regressions: all 25 modern-exchange tests passed in the full suite.
modern_cancellation_counts_a_call_even_if_the_server_never_repliesproves that the second Search is denied with-32001. Targeted mutation checks detect missing or duplicate outcome records, counting a validinput_required, lost accounting during reply delivery, and the active-slot leak. The two new EOF regressions failed before the ordering fix and passed after it.Review: independent code and documentation review findings are resolved. The additional EOF tests prove that the last buffered request reaches the server before input closes, and input after EOF creates no response event.
Still running at push
cc4ae8d: the combined all-feature Box/Policy suite and remaining lint, formatting, manifest, example, and deterministic-containment gates. The completed 831 Box unit tests report no failures; the final large-directory fixture is still running. These checks are not yet reported as passed. The branch was pushed immediately at the operator’s request.Current CI: the new commit is pushed; CI results are pending. The previous head,
0eba8c9, passed CI, including Linux ARM64 and macOS tests, deterministic containment, lint, packaging, and the site manifest. Those results do not validate this new commit.Live test passed at
d15ee53: Claude Code 2.1.318 withmcp-server-time==2026.10.28returned the real UTC time and reported the policy denial forconvert_time. Separate client checks passed modern discovery, direct modern startup, and legacy startup. Captured server frames contained allowed calls and no denied calls.Live client caveat: Boxy base
eed1942required a temporary policy-generation patch fromipto Core'sip4/ip6fields. That patch is not part of this PR.Live SDK scope: the earlier smoke test was not repeated for this fix; its local credentials and runtime prerequisites are unavailable.
I ran the relevant suites; completed and pending checks are listed above
All remaining validation gates have completed
Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.