Repository navigation
feat: add unregistered application registration MCP transport - #1272
Conversation
Pre-merge checks:
|
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Solid & Clean Code | PR #1272 (recoupable/api, author sidneyswift, head 2606c91) adds seven new files under lib/mcp/applications/. The prior FAIL is still valid: the head commit is the same one that run reviewed, and the… |
Refactor the new MCP proposal transport code before merge: - Split readProposedRegistrationMcpBody into single-purpose functions: media and header negotiation, Content-Type and length guards, bounded body read with timeout, and JSON, batch,… |
Full details: Solid & Clean Code
-
Explanation
PR
#1272(recoupable/api, author sidneyswift, head 2606c91) adds seven new files under lib/mcp/applications/. The prior FAIL is still valid: the head commit is the same one that run reviewed, and the flagged code is unchanged. I re-read the code and confirmed the main claims. Verified violations of the check's explicit thresholds and rules: 1. readProposedRegistrationMcpBody (readProposedRegistrationMcpBody.ts, lines 30-120) is about 91 lines. It covers media negotiation, Content-Type and length guards, the lifecycle reader, a 5-second timeout race, UTF-8 decode, JSON parse, batch rejection, and tool-call id checks. The check says to flag functions longer than 20 lines. 2. handleProposedRegistrationMcpRequest.ts (lines 12-71) is about 60 lines. It mixes lifecycle, auth, method routing, header freezing, body read, server and transport setup, tool registration, connect, and two error paths. It nests life.run callbacks. 3. guardProposedRegistrationStorage.ts (lines 20-89) is about 70 lines. It mixes identity comparison, per-mechanism checks, and storage wrapping. The recoup_api_key and privy rules are inline, not extracted. 4. createProposedRegistrationMcpLifetime.ts (lines 2-74) is about 73 lines. Timers, abort handling, cleanup registry, race-based run, and close all sit in one closure. 5. DRY and constants: the 65536 byte limit appears twice (readProposedRegistrationMcpBody.ts lines 51 and 92). The string "Transport cleanup unconfirmed" appears in handleProposedRegistrationMcpRequest.ts (lines 47, 66 region) and createProposedRegistrationMcpLifetime.ts (lines 31, 35). Timeouts 5000, 30000, and 1000 and status codes 408 and 504 are inline literals. 6. registerCreateProposedRegistrationTool.ts (lines 37-44) uses a nested ternary chain to map error kinds to messages. Causality: git diff from merge-base 60af564 to HEAD lists all these files as added (A). None exist on the base. The violations therefore come from this PR. Partial refutation: the prior claim about mediaRanges is weaker. The file-name rule targets a new function added to an existing file. readProposedRegistrationMcpBody.ts is a new file, and its only export matches its name. mediaRanges is unexported. I do not rely on this point for the verdict. The other violations stand on their own. The PR description's validation claims (128 tests, CI, review dispositions) cover behavior. They do not address the structural thresholds in this check.Resolution
Refactor the new MCP proposal transport code before merge: - Split readProposedRegistrationMcpBody into single-purpose functions: media and header negotiation, Content-Type and length guards, bounded body read with timeout, and JSON, batch, and tool-call id validation. Keep the main function under 20 lines by composing them. - Move mediaRanges into its own file, mediaRanges.ts, and export it under that name. - Split handleProposedRegistrationMcpRequest into request preflight, server and transport construction, and response finalization. Keep each function under 20 lines. - Split guardProposedRegistrationStorage into an identity comparison function, one check function per credential mechanism (without repeated inline conditions), and a storage wrapper. - Split createProposedRegistrationMcpLifetime's timers, cleanup registry, and abort handling into separate helpers or a small class. - Extract named constants for the body limit (65536), timeouts (5000, 30000, 1000), status codes (408, 504), and the cleanup error message. Define each value once and share it. - Replace the nested ternary in registerCreateProposedRegistrationTool.ts with a lookup table or a mapping function.
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Codex Review Summary: ✅ CompletedThis 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: 01d8e9d502
ℹ️ 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".
There was a problem hiding this comment.
All reported issues were addressed across 11 files
Architecture diagram
sequenceDiagram
participant Client as MCP Client (SDK)
participant Handler as handleProposedRegistrationMcpRequest
participant Life as Request Lifetime Owner
participant Body as readProposedRegistrationMcpBody
participant Verify as verifyExistingApplicationMcpActor
participant Guard as guardProposedRegistrationStorage
participant Server as MCP Server + Transport
participant Domain as Proposed Create/Read Domains
participant Storage as Server-Owned Storage
Note over Client,Storage: Unregistered Direct-SDK MCP Transport Flow
Client->>Handler: POST /mcp (JSON-RPC body)
Handler->>Life: create request lifetime (30s deadline, abort handler)
Life-->>Handler: lifetime handle
alt OPTIONS request
Handler-->>Client: 204 No Content
end
Handler->>Verify: verify existing MCP actor
Verify-->>Handler: admission observation (frozen principal)
alt Unauthorized or denied
Handler-->>Client: 401/403 (body never read)
end
Handler->>Body: read body with limits (64KiB, 5s timeout)
Body->>Body: Reject batches, id-less tool calls
Body-->>Handler: parsed JSON body
alt Body exceeds limits
Body-->>Client: 400/406/408/413/415
end
Handler->>Server: Create MCP server + streamable HTTP transport
Handler->>Server: Register create/read tools
Server->>Guard: Tool invocation with parsed args
Guard->>Verify: Re-verify actor/credentials (fresh observation)
Verify-->>Guard: Fresh observation
alt Credential/actor/workspace drift detected
Guard-->>Server: ProposedStorageFailure (denied)
Server-->>Client: isError: true (storage never invoked)
end
Guard->>Storage: Wrapped create/read with drift check
Storage->>Domain: Execute proposed domain logic
Domain-->>Storage: Domain result
Storage-->>Guard: Result
Guard-->>Server: Tool result
Server-->>Client: JSON-RPC response
alt Storage or domain failure
Domain-->>Server: Failure
Server-->>Client: isError: true, fixed message
end
alt Request abort or deadline during async work
Life->>Life: Trigger termination (408/504)
Life->>Server: Close server/transport (1s cleanup bound)
Server-->>Client: Error response if deliverable
Note over Storage,Domain: No rollback - outcome unknown
end
Handler->>Life: Close lifetime (always)
Life->>Life: Run cleanups (cancel unread body)
Life-->>Handler: Cleanup confirmation
Handler-->>Client: Final response (JSON mode)
alt Cleanup failure or timeout
Life-->>Handler: Cleanup unconfirmed
Handler-->>Client: 503 (no internal details leaked)
end
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
There was a problem hiding this comment.
0 issues found across 5 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Adds an inactive, unregistered MCP transport composition for proposed application registration, with focused tests, internal docs, and branch-ignore config; no route, runtime activation, or existing-behavior change.
View guided diff | Turn on auto-fix | Re-trigger cubic
Problem and result
Adds an unregistered direct-SDK JSON MCP composition for proposed application registration. It retains the original request through authentication, bounded body reading and actual SDK dispatch. Admission and per-call identity observations must match; a per-invocation storage guard checks the fresh domain actor/workspace and termination before storage entry. Once storage starts, lost delivery remains an unknown outcome, with no rollback or automatic retry.
Media admission parses case-insensitive types, quoted parameters and Accept quality/exclusions. Only validated media tokens are canonicalized on the original request for pinned SDK compatibility. Request ownership includes early rejection, bounded cleanup, terminal reader protection and explicit observation of actual domain completion after transport termination.
Validation
128 controlled tests pass locally: 67 transport/lifecycle cases plus 61 existing cases, using actual SDK/verifier/domain code and synthetic credential/storage leaves. Scoped TypeScript, ESLint, Prettier and whitespace checks pass. Exact-head independent Spec and Standards reviews each report zero findings. Media regressions and timeout/read-guidance fixes were demonstrated red before green. Earlier poison-containment runs remain historical evidence; they were not rerun or relabeled as 128-test runs.
Exact successor:
2606c9104dff3731f59d56d00bba121d2a8e47ba, tree3fbe014dadcae8dc99221549c0932ea18f75badf. Fresh Node 22 dedicated CI passes all 128 tests with confirmed cleanup. All required checks (test, format, lint) and additional compatibility, strict-type and SQL bridge jobs pass. Actual Unit checkout is synthetic merge3effbdc8, whose tree equals the reviewed head. Dedicated proposal CI, not ordinary Unit, owns this excluded suite. All 13 original inline findings received a fix or reasoned no-change disposition; fresh exact-head Cubic review reports zero new issues; CodeRabbit skipped review.Boundaries
Eleven existing authorized paths only; no route, allowlist, shared auth/domain, SQL, descriptor/golden, production factory or runtime activation changes. Accepted Sites base remains composed. Source-only internal constants and proposed policy remain inactive. Current /mcp onboarding is unchanged. Equality observations are not atomic revocation or proof of domain-hidden credential-only drift.
Exact-head Context review passed (seal
5d2e7eca), and the coordinator accepted the bounded source. Final composition and merge remain coordinator-owned. No provider execution, real credentials or client/native acceptance is claimed.