Skip to content

feat(connect): support stateless MCP 2026 - #4040

Closed
reachjalil wants to merge 11 commits into
devfrom
codex/stateless-mcp-transport
Closed

reachjalil wants to merge 11 commits into
devfrom
codex/stateless-mcp-transport

Conversation

@reachjalil

@reachjalil reachjalil commented Aug 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • upgrade OpenWork Connect to the official MCP TypeScript v2 client with automatic 2026-07-28 negotiation and an explicit 2025 stateless fallback
  • serve the public /mcp/agent endpoint through the official v2 stateless HTTP handler with a fresh server per request, strict protocol validation, and subscriptions/listen
  • preserve MCP App metadata while the remaining internal legacy endpoints stay on SDK v1
  • classify v2 DCR, negotiation, OAuth, and structured network failures at the managed Desktop gateway without leaking provider details or hiding internal defects
  • mirror the v2 client into the packaged Desktop runtime and add focused modern-wire, legacy-compatibility, OAuth-boundary, managed-gateway, and repository testkit coverage

Safety hardening

  • bind each prepared server through request-local async context so SDK request cloning on the legacy path cannot detach it from the authenticated request
  • scope list-change subscriptions by organization and user, preventing one catalog mutation from notifying another authenticated audience
  • retain one handler and its global subscription binding rather than multiplying listener capacity per tenant
  • prefer protected-resource OAuth scopes over unrelated authorization-server scopes, preserve explicit narrow selections, and reject selections advertised by neither party before dynamic registration
  • validate OAuth discovery aliases as a strict two-hop binding: an advertised resource alias may point to a canonical issuer, but OpenWork independently rediscovers that issuer and discards all endpoints supplied by the alias
  • bind cached OAuth metadata, client registrations, access tokens, refresh tokens, and callback state to the verified issuer; migrate legacy resource-alias records only after strict rediscovery
  • preserve application-owned issuer mismatch diagnostics over generic HTTP status evidence so an OAuth boundary failure cannot be hidden by a captured 401
  • keep the proof lane independent of generated workspace build output by resolving source packages through the repository's development export condition
  • stabilize lifecycle tests around the additional negotiation round trip so deadline coverage remains meaningful under concurrent CI load

Preserved Connect optimizations

  • keep the model-facing /mcp/agent surface compact: ordinary provider tools remain behind bounded search_capabilities and execute_capability instead of being projected into the client context
  • keep provider discovery server-side, grant- and policy-filtered, top-K bounded, deadline-limited, and cached; server/discover advertises protocol capabilities only and does not include the provider tool catalog
  • expose only App-visible provider tools and their bound resources to the private Connect App-host audience; ordinary clients, legacy clients, and forged audience headers cannot unlock that surface
  • preserve the selected provider result as an opaque openwork/mcpApp launch reference, then re-list and revalidate the exact connection, tool visibility, and live ui:// binding before the unchanged Desktop sandbox renderer loads it

Verification

  • focused compact-catalog and Connect MCP App rendering regression matrix — 83/83 passed across the Den proxy/App registrations, live search/execute fixture, local App host, result-preservation mapper, and iframe policy
  • pnpm evals:pr specs/mcp-stateless-2026-transport.test.ts — passed at 8cbda049a3275950782132d59525c829ad769084: 5/5 evidence assertions, 0 failed, 0 pending, 0 skipped
  • the same exact eval passed in a clean detached worktree with a frozen offline install and no enterprise-client dist output present
  • pnpm --filter @openwork/enterprise-mcp-client test — 83/83 passed
  • pnpm --filter openwork-server exec bun test src/local-managed-mcp.e2e.test.ts — 8/8 passed, 147 assertions
  • focused Den OAuth persistence, connect-start, and diagnostics suites — 112/112 passed, 418 assertions
  • pnpm --filter @openwork/desktop test — 259 passed, 0 failed, 1 expected platform skip
  • enterprise client, embedded server, Den API, and app typechecks — passed
  • Den API production build, frozen-lockfile install, and patch application — passed
  • full app suite — 893 passed; seven pre-existing window.matchMedia suite-order failures remain. The same seven failures were reproduced on untouched origin/dev, while all 43 affected tests pass together in isolation. This PR changes no apps/app source.
  • local macOS Electron smoke on the rebased runtime tree — clean fresh launch; workspace, Library, MCP filter, and expanded Advanced MCP settings rendered; Electron/control bridges were present; workspace, MCP, config, agent, command, and event requests returned 200; no UI alerts or fetch errors remained after refresh
  • production dependency audit — no newly introduced advisory; the only high finding is the same transitive sharp@0.34.5 advisory already present on dev

Scaling note

Request handling is stateless across replicas. Subscription notifications use an in-process, authenticated-audience-scoped event bus; this matches the current one-replica Den API deployment default. A future multi-replica Den API topology will need a shared event bus for cross-replica notification fan-out.

@vercel

vercel Bot commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview Aug 24, 2026 11:55pm
openwork-den Ready Ready Preview Aug 24, 2026 11:55pm
openwork-den-worker-proxy Ready Ready Preview Aug 24, 2026 11:55pm
openwork-diagnostics Ready Ready Preview Aug 24, 2026 11:55pm
openwork-landing Ready Ready Preview, v0 Aug 24, 2026 11:55pm

@reachjalil

reachjalil commented Aug 24, 2026 •

Copy link
Copy Markdown
Member Author

Test evidence — openwork-connect-and-the-agent-endpoint-implement-stateless-mcp-2026 — 0/0 screenshots passed · 5 assertions

✅ 0/0 screenshots passed · 5 assertions · 5 expectations passed · 0 failed · 0 pending

screenshots not uploaded (no BLOB_READ_WRITE_TOKEN)

ℹ️ ASSERTION — 1. OpenWork Connect negotiates the current stateless protocol

The outbound client uses automatic SDK negotiation, reaches a 2026-07-28 server through server/discover without initialize or Mcp-Session-Id, and does not misclassify authorization or server failures as legacy-protocol signals.

  • ✅ PASS OpenWork Connect negotiates the current stateless protocol — The outbound client uses automatic SDK negotiation, reaches a 2026-07-28 server through server/discover without initialize or Mcp-Session-Id, and does not misclassify authorization or server failures as legacy-protocol signals.

ℹ️ ASSERTION — 2. The public agent MCP is stateless on the modern wire

The HTTP witness observes a fresh server for every server/discover, tools/list, and tools/call request; 2026 protocol, method, name, client, and capability metadata; and no request or response session identifier.

  • ✅ PASS The public agent MCP is stateless on the modern wire — The HTTP witness observes a fresh server for every server/discover, tools/list, and tools/call request; 2026 protocol, method, name, client, and capability metadata; and no request or response session identifier.

ℹ️ ASSERTION — 3. Compatibility and notification behavior remain explicit

A 2025 SDK client completes initialize and tools/list without a session identifier even when the SDK clones its Request, while modern listeners receive catalog changes through subscriptions/listen only for their authenticated organization and user audience.

  • ✅ PASS Compatibility and notification behavior remain explicit — A 2025 SDK client completes initialize and tools/list without a session identifier even when the SDK clones its Request, while modern listeners receive catalog changes through subscriptions/listen only for their authenticated organization and user audience.

ℹ️ ASSERTION — 4. Protocol and authorization boundaries fail closed

The server rejects a protocol header/body mismatch with JSON-RPC error -32020. OAuth prefers resource-specific scopes, rejects unadvertised selections, independently verifies a canonical issuer behind a resource discovery alias, discards alias-supplied endpoints, binds persisted client and token records to their issuer, and preserves issuer-mismatch diagnostics over a captured HTTP 401.

  • ✅ PASS Protocol and authorization boundaries fail closed — The server rejects a protocol header/body mismatch with JSON-RPC error -32020. OAuth prefers resource-specific scopes, rejects unadvertised selections, independently verifies a canonical issuer behind a resource discovery alias, discards alias-supplied endpoints, binds persisted client and token records to their issuer, and preserves issuer-mismatch diagnostics over a captured HTTP 401.

ℹ️ ASSERTION — 5. Managed Connect failures preserve safe API boundaries

An unreachable server plus DCR rejection and modern discovery or legacy initialize failures return the bounded managed-MCP 502 without provider secrets or telemetry noise, while malformed internal SDK data remains a captured generic 500.

  • ✅ PASS Managed Connect failures preserve safe API boundaries — An unreachable server plus DCR rejection and modern discovery or legacy initialize failures return the bounded managed-MCP 502 without provider secrets or telemetry noise, while malformed internal SDK data remains a captured generic 500.

Test run created 2026-08-24T23:53:25.835Z · Source: evals/results/test-runs/2026-08-24T23-53-25-835Z-openwork-connect-and-the-agent-endpoint-implement-stateless-mcp-2026/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4040 --test-run 2026-08-24T23-53-25-835Z-openwork-connect-and-the-agent-endpoint-implement-stateless-mcp-2026

@vercel
vercel Bot temporarily deployed to Preview – openwork-diagnostics August 24, 2026 16:11 Inactive

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (6a54010869ab50de6f8a6aca5e2bf13a953a596f). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@diff-warden diff-warden Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warden security clearance: clear. No blocking findings (security or desktop↔den sync) in this diff (8cbda049a3275950782132d59525c829ad769084). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil reachjalil closed this Aug 25, 2026
@reachjalil
reachjalil deleted the codex/stateless-mcp-transport branch August 25, 2026 00:19
@reachjalil

Copy link
Copy Markdown
Member Author

Superseded by #4055 after the source branch was renamed to the outcome-based feature/stateless-mcp-transport. The replacement PR uses the identical head SHA and dev base; continue review there.

This branch was successfully deployed

5 active deployments
Preview – openwork-den-worker-proxy — 8cbda049 Deployed Aug 24, 2026 by vercel[bot]
Preview – openwork-den — 8cbda049 Deployed Aug 24, 2026 by vercel[bot]
Preview – openwork-landing — 8cbda049 Deployed Aug 24, 2026 by vercel[bot]
Preview – openwork-app — 8cbda049 Deployed Aug 24, 2026 by vercel[bot]
Preview – openwork-diagnostics — 8cbda049 Deployed Aug 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant