Skip to content

fix(mcp): accept structured initialization capabilities - #792

Merged
steipete merged 3 commits into
mainfrom
fix/mcp-initialize-capabilities-r4
Sep 24, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/mcp-initialize-capabilities-r4

Conversation

@steipete

@steipete steipete commented Sep 24, 2026 •

Copy link
Copy Markdown
Collaborator

MCP clients sending structured experimental capabilities, including {"codex/auth-change": {}} from Codex, could not initialize Peekaboo: the SDK decoded those values as strings and returned -32603. Fixes #745. Thanks @Wudib for the report.

Pin the single upstream decoder repair from swift-sdk#276, commit f7077e0d5cd57e0b2a497862017aa94ee344252f, directly atop the existing 0.12.1 dependency. Core, CLI, Mac, and Xcode select the same revision. The SDK retains arbitrary JSON capability values while malformed known capability shapes still fail. Remove the custom initialize handler that SDK startup always replaced, keeping negotiation and initialization state owned by the SDK.

The temporary pin should move to a tagged SDK containing the repair when available. The SDK's Swift experimental property becomes [String: Value]?; integrations passing a typed string dictionary need mapValues(Value.string), as documented. A compile-only Swift 6 consumer check against the exact pinned MCP module verified that contextual legacy string literals compile, a typed [String: String] fails without conversion, and mapValues(MCP.Value.string) compiles. CLI and wire JSON syntax are unchanged. The public root Peekaboo package does not depend on MCP; this affects the Core/AgentRuntime consuming graph, not every public Swift product. The Tachikoma submodule and its standalone manifest remain unchanged.

Original repair proof reproduced the failure and empty-capability control with the published 4.5.0 CLI. All 29 native wire/server/EOF tests passed, including seven initialization payload cases and real tools/list responses. Nineteen unchanged upstream request tests passed in an isolated Swift 6.3.3 Linux target; the broader upstream test target had unrelated HTTP/OAuth test-helper concurrency compile errors. Portable repository checks, focused format/lint, and the original independent review passed. CI now exercises structured initialization through the built CLI's stdio transport.

Maintainer qualification at efc623a6a1f7e220b1b0d903044f5d4646c9e2d1 preserves the original repair and all nine non-changelog changed files byte-for-byte, rebased onto main at 35c754e7ae88c9e8634f2b83ef02da08743a2c1e. The full rebased patch passed independent scoped P0 autoreview with no actionable findings. The affected Core suite passed 106 tests, including initialization, server lifecycle, argument validation, background policy, catalog filtering, and remote browser-session contracts. The complete non-automation CLI suite passed 1,459 tests (1,270 CoreCLI, 50 certification, 139 runtime). The exact-source CLI built successfully and passed Developer ID signature, Team ID, compatibility-library, and embedded source-stamp verification. Consumer source and module hashes remained unchanged through their type-check proof.

The signed CLI also passed a read-only raw-stdio test against the unchanged signed 4.5.0 GUI host in 2.238 seconds: five accepted cases (structured and nested experimental values, scalars, extensions, and empty capabilities), two malformed cases rejected with the existing -32603 contract, successful catalogs and permission reads, and clean EOF for all seven clients. Two simultaneous clients retained independent disconnected browser scopes before and after the first client's cleanup. The default catalog did not expose browser connect; no browser attachment, UI input, AppleScript, host restart, or provider key was used.

All five macOS CI jobs passed on that head. Supplemental Core validation then exposed one existing fixture failure among 3,268 tests: a watch-stop test measured full-session completion, including contact-sheet creation, metadata writes, and detached artifact validation, against an 80 ms cancellation bound. The test and production code were unchanged by the MCP repair. Commit 5ef2e6321babb2da6af98a20264b902dc9a8b395 replaces only that test's timing guess with the real fallback runner's propagated cancellation, exactly two capture attempts (one successful frame and one transient failure), and the preserved frame/warning assertions. It accurately tests a pending retry, reuses the existing completion watchdog unchanged, and changes no production behavior or timeout values. The complete candidate passed fresh independent P0 autoreview, all 39 focused watch/fallback-runner tests, formatting/lint, and ten additional exact-case repeats.

The maintainer accepts the documented Swift migration for this confirmed protocol defect. Final head 5ef2e6321babb2da6af98a20264b902dc9a8b395 passed all five macOS jobs, all four supplemental suites including full-safe, and all CodeQL analyses, each on its first attempt. The exact-head ClawSweeper review is also ready with no actionable findings. Prior-head results are recorded above for attribution, not substituted for the final gates. This PR changes source only and does not publish a release.

@steipete
steipete requested a review from a team as a code owner September 24, 2026 13:49
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@cursor

cursor Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
MCP handshake and dependency pinning affect all stdio MCP clients; changes are narrow and heavily tested but sit on a critical connection path.

Overview
Restores MCP clients (including Codex) that send structured capabilities.experimental JSON by pinning the Swift MCP SDK to commit f7077e0d (swift-sdk#276) across Core, CLI, Mac, and workspace lockfiles, instead of the 0.12.1 range.

Peekaboo drops its custom initialize handler in PeekabooMCPServer so negotiation stays on the SDK path (protocol 2025-06-18). PeekabooMCPInitializationTests exercises raw wire payloads (Codex-style experimental objects, extensions, malformed shapes) through tools/list, and macOS CI adds the suite plus a built CLI stdio smoke test. Changelog and docs/mcp-testing.md document the temporary pin and the SDK migration from typed string maps to [String: Value]?.

Separately, a watch capture session test is rewritten to assert cancellation of a pending transient ScreenCaptureKit retry via completion signals (two attempts, no fabricated transient warning), replacing a flaky elapsed-time bound—test-only, no production behavior change.

Reviewed by Cursor Bugbot for commit 5ef2e63. Bugbot is set up for automated code reviews on this repo. Configure here.

@clawsweeper clawsweeper Bot added P1 Urgent regression or broken agent/channel workflow affecting real users now. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 24, 2026
@clawsweeper

clawsweeper Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Codex review: needs maintainer review before merge. Reviewed September 24, 2026, 11:23 AM ET / 15:23 UTC (Revision 3).

ClawSweeper review

What this changes

The branch pins an upstream Swift MCP decoder repair, removes an overwritten initialize handler, adds wire and CI coverage and migration notes, and updates a watch-stop test to observe cancellation instead of elapsed time.

Merge readiness

✅ Ready for maintainer review

Current main and v4.5.0 still pin the SDK version that rejects the reported handshake. This PR addresses that failure, the maintainer has accepted the documented Swift migration, and this review found no actionable patch defect.

Priority: P1
Reviewed head: 5ef2e6321babb2da6af98a20264b902dc9a8b395

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The narrow upstream repair has strong wire coverage and detailed real-run results, with no actionable finding on the final head.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body reports a signed, exact-source CLI using the real stdio MCP entrypoint: structured requests initialized and reached catalog and permission reads, malformed requests retained their error, and EOF cleanup completed. The final-head watch test is separately reported passing; no stored-data contract changes.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body reports a signed, exact-source CLI using the real stdio MCP entrypoint: structured requests initialized and reached catalog and permission reads, malformed requests retained their error, and EOF cleanup completed. The final-head watch test is separately reported passing; no stored-data contract changes.
Evidence reviewed 9 items Current main and release retain the affected SDK: Both the pinned main revision and v4.5.0 resolve swift-sdk 0.12.1 at a0ae212ebf6eab5f754c3129608bc5557637e605.
Upstream decoder contract: The pinned repair changes experimental capabilities from string values to JSON Value values; its recorded parent is the 0.12.1 revision. The upstream PR remains open.
Dependency boundary: The changed Core manifest directly pins the SDK and links its MCP product into the agent runtime; the unchanged Tachikoma submodule also consumes that SDK.
Findings None None.
Security None None.

How this fits together

Peekaboo exposes desktop tools to MCP clients through its CLI or a host-supplied transport. The Swift MCP SDK decodes a client's initialize request before Peekaboo can return its tool catalog.

flowchart LR
A[MCP client] --> B[Initialize request]
B --> C[Swift SDK capability decoder]
C -->|valid| D[Protocol negotiation]
D --> E[Peekaboo tool catalog]
C -->|malformed| F[Initialization error]
Loading

Before merge

None.

Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Swift runtime and test lines runtime 0 added, 36 removed; tests 138 added, 35 removed The SDK takes over handshake behavior while focused regression coverage grows.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #745
Summary: This PR is the open candidate fix for the linked structured-capability initialization failure.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land the upstream decoder repair with raw-wire regression coverage, then move the temporary SHA pin to a tagged SDK release containing it.

Do we have a high-confidence way to reproduce the issue?

Yes. The linked issue supplies a raw stdio payload and a reported 4.5.0 failure/control pair, while current main still pins the string-valued decoder; this read-only review did not execute the request.

Is this the best way to solve the issue?

Yes. Adopting the upstream JSON-value decoder fixes the failing boundary while the wire tests preserve rejection of malformed known capabilities; the removed handler was replaced by SDK startup.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 35c754e7ae88.

Labels

Label changes:

No label changes.

Label justifications:

  • P1: The current MCP handshake blocks affected clients from discovering or using Peekaboo tools.
  • merge-risk: 🚨 compatibility: The pinned SDK changes the public Swift experimental-capability value type; the maintainer has accepted its documented conversion path.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body reports a signed, exact-source CLI using the real stdio MCP entrypoint: structured requests initialized and reached catalog and permission reads, malformed requests retained their error, and EOF cleanup completed. The final-head watch test is separately reported passing; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports a signed, exact-source CLI using the real stdio MCP entrypoint: structured requests initialized and reached catalog and permission reads, malformed requests retained their error, and EOF cleanup completed. The final-head watch test is separately reported passing; no stored-data contract changes.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • semyoren: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SebTardif: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-24T13:54:21.436Z sha 483b588 :: blocked before merge. :: none
  • reviewed 2026-09-24T14:54:20.408Z sha efc623a :: needs maintainer review before merge. :: none

@steipete

Copy link
Copy Markdown
Collaborator Author

Taking maintainer qualification and landing ownership of this existing repair. The exact upstream f7077e0 pin is accepted in principle for the confirmed protocol defect, including the documented mapValues(Value.string) migration; final acceptance still requires clean review, consumer/downstream proof, and exact-head CI.

I will preserve the decoder repair and tests, reconcile the release note with current main, and use exact-lease branch updates. Please coordinate any further branch changes with this qualification pass so we do not race or invalidate the tested head. No additional workaround or duplicate PR is needed.

@steipete
steipete force-pushed the fix/mcp-initialize-capabilities-r4 branch from 483b588 to efc623a Compare September 24, 2026 14:48
@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Sep 24, 2026
Replace the whole-session 80 ms timing assertion with the real fallback runner cancellation result and exact attempt count. Reuse the existing bounded completion signals and preserve frame and warning assertions without changing production code or timeout values.
@steipete
steipete merged commit 23b818f into main Sep 24, 2026
15 of 16 checks passed
@steipete
steipete deleted the fix/mcp-initialize-capabilities-r4 branch September 24, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P1 Urgent regression or broken agent/channel workflow affecting real users now. proof: sufficient Contributor real behavior proof is sufficient. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCP initialize fails with -32603 when a client sends a non-string experimental capability (breaks Codex integration)

1 participant