Skip to content

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

Merged
reachjalil merged 18 commits into
devfrom
feature/stateless-mcp-transport
Aug 25, 2026
Merged

reachjalil merged 18 commits into
devfrom
feature/stateless-mcp-transport

Conversation

@reachjalil

@reachjalil reachjalil commented Aug 25, 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
  • reject a stale dynamic client registration if the selected issuer changes in flight, reload only the same bound connection identity, and retry once against the current issuer without weakening the administrator-review boundary for existing credentials
  • 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 — 100/100 passed across the Den proxy/App registrations, live search/execute fixture, local App host and sandbox, result-preservation mapper, and iframe policy
  • published Desktop connect compatibility — the existing request layer preserves an issuer-review 409 as a structured, actionable Den error; focused regression test passed 1/1
  • pnpm evals:pr specs/mcp-stateless-2026-transport.test.ts — passed at 1f2cdd49e35b3c3d7e8ec437727704d7b86aab1c: 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 — 115/115 passed, 427 assertions, including an end-to-end concurrent issuer-change retry that persists only the replacement issuer client
  • pnpm --filter @openwork/desktop test — 259 passed, 0 failed, 1 expected platform skip
  • enterprise client, embedded server, Den API, app, and server typechecks — passed
  • enterprise client, Den API, embedded server, and app production builds; frozen-lockfile install; and patch application — passed
  • full app suite — 896 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 [email protected] 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.

@reachjalil

reachjalil commented Aug 25, 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-25T01:20:19.827Z · Source: evals/results/test-runs/2026-08-25T01-20-19-827Z-openwork-connect-and-the-agent-endpoint-implement-stateless-mcp-2026/test-run.json · Repro: pnpm --dir evals artifacts:publish -- --pr 4055 --test-run 2026-08-25T01-20-19-827Z-openwork-connect-and-the-agent-endpoint-implement-stateless-mcp-2026

@different-ai different-ai deleted a comment from vercel Bot Aug 25, 2026
diff-warden[bot]
diff-warden Bot previously approved these changes Aug 25, 2026

@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

@vercel

vercel Bot commented Aug 25, 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 25, 2026 2:41pm
openwork-den Ready Ready Preview Aug 25, 2026 2:41pm
openwork-den-worker-proxy Ready Ready Preview Aug 25, 2026 2:41pm
openwork-landing Ready Ready Preview, v0 Aug 25, 2026 2:41pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
openwork-diagnostics Skipped Skipped Aug 25, 2026 2:41pm

diff-warden[bot]
diff-warden Bot previously approved these changes Aug 25, 2026

@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 (1f2cdd49e35b3c3d7e8ec437727704d7b86aab1c). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

… binding

The SDK synthesizes the authorization server URL as the resource root with
a trailing slash when no protected-resource metadata exists, while the
canonical metadata issuer carries none, and the SDK itself compares the two
with RFC 8414's single trailing-slash tolerance. The strict string guards
rejected that pair, so the first connect against a metadata-less server
registered a client, backfilled the slashful URL as the selected issuer,
and then failed every save with an issuer mismatch until an administrator
intervened. Credential, registration, verification-stamp, and binding
checks now share the root-alias equivalence, the Den backfill prefers the
canonical metadata issuer, discovery states are stamped with the canonical
issuer, a transient metadata outage no longer invalidates persisted
discovery or flags issuer review, and an unchanged discovery load no
longer rewrites the connection row on every request.
The health sink promoted protocol_ready only when the handshake success
diagnostic reported the legacy initialize request phase, which the
negotiation rework no longer emits, so every diagnostic capped at
reachable. The negotiated protocol era on the success event now drives the
promotion for both eras. The unauthenticated bearer challenge on a
server/discover probe also classifies under the protocol-negotiation
phase, so the routine 401 challenge that starts every OAuth flow is
suppressed instead of being recorded as a provider HTTP failure.
…ts it

The scope-selection rewrite dropped the SDK's append of offline_access for
refresh-token grants when the authorization server advertises it, which
would stop refresh tokens on providers that require the scope explicitly
and force recurring reconnects. The patched scope selection restores that
append after the advertised-scope validation.
Bun's human-readable summary line varies across local versions, so the
agent-endpoint leg now asserts the suite's results from a JUnit report
written to a temporary path, keeping the witness stable wherever the eval
runs.
A per-member OAuth token response could stamp its issuer into the shared
connection's configuration without independent verification, letting one
member's provider response repoint the organization-wide issuer used by
every other member's OAuth flow. The connection-wide issuer selection now
derives only from the administrator's configuration or the connection's
own verified discovery state; a token-response issuer still participates
in the mismatch guard but is never written to the shared row.

@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 (42374758203b307b0644a7f7e733b828232bba63). Automated clearance satisfies the required-review gate only — a human still reviews and merges. Analysis run

@reachjalil
reachjalil merged commit 64d2d37 into dev Aug 25, 2026
27 checks passed

This branch was successfully deployed

4 active and 1 inactive deployments
Preview – openwork-den-worker-proxy — 42374758 Deployed Aug 25, 2026 by vercel[bot]
Preview – openwork-landing — 42374758 Deployed Aug 25, 2026 by vercel[bot]
Preview – openwork-den — 42374758 Deployed Aug 25, 2026 by vercel[bot]
Preview – openwork-app — 42374758 Deployed Aug 25, 2026 by vercel[bot]
Preview – openwork-diagnostics — 42374758 Deployed Aug 25, 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