Repository navigation
feat: connect MCP apps through a principal-bound relay plugin - #168233
Conversation
Add a disabled-by-default bundled plugin with an outbound authenticated WebSocket, persistent Ed25519 identity, single-use pairing codes, and Gateway-owned grants with durable revocation tombstones. Expose status, conversation reads, owner-authored message submission, and bounded reply polling through existing documented SDK contracts. Keep approval handling in OpenClaw, omit custom source attribution, and provide running-Gateway CLI commands plus setup and security documentation. Validate with 121 focused tests, protocol vectors, and docs checks. Extension type lanes report no mcp-relay errors; unrelated QA-lab declarations and SDK declaration-preparation timeout leave environment-limited gates for CI.
Omit sessions.create idempotency keys for the principal-less in-process client while retaining the required key for chat.send. Enforce the real Gateway contract in the request fake so new-conversation sends regress when the unsupported key returns. Use agent.wait terminalReply as the sole reply source and direct expired snapshots to read_conversation. Remove transcript reconstruction, receipt lookups, and the run/session admission cache. Preserve conversation existence and current grant/connection authority around publication. Log redacted operation and Gateway diagnostics through the plugin logger and document the revised reply behavior. The plugin suite passes 122 tests in 108.68 seconds on Node 24.21.0. Regressions reproduced the original send failure, conversation-deletion race, and overlapping parameter redaction before their fixes.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review blockedAutomated review did not run, so no review verdict was produced. Reason: The input-safety check rejected material in this revision. No detected value, path, or scanner output is reproduced here. Automatic review is on hold, including after source changes. Request a fresh re-review after resolving the failure; maintainers can also release the hold through an intentional scanner-policy update. Next step: If this is a genuine credential, remove and rotate it. If it is an intentional test fixture, a maintainer must review and qualify it. |
|
Validate explicit frame ancestors and apply them only to Control UI app documents. Preserve default CSP and X-Frame-Options denial, keep protected public and media surfaces unchanged, and hot-apply the policy to subsequent responses.
Accept an optional HTTPS controlUiUrl with matching manifest and runtime validation. Advertise controlUi.url only in configured remote status results, preserving the existing default response and relay authority.
Document HTTPS setup, explicit trusted ancestors, separate Gateway origin policy, partitioned browser pairing, and existing cookie-backed plugin and SSO limitations. Refresh generated config baselines and relay inventory references.
…n-openclaw-6fdc8f # Conflicts: # docs/.generated/config-baseline.counts.json # docs/.generated/config-baseline.sha256 # src/gateway/control-ui-index.ts # src/gateway/control-ui.ts
…n-openclaw-6fdc8f
Expose optional controlUiIngress on trusted plugin service contexts, with versioned HTTP/WS transport, presentation, and settlement contracts. Reuse the canonical HTTP, upgrade, device admission, and dispatch owners through bounded in-memory Node transports carrying immutable remote provenance. Require device-authenticated operators within a read/write ceiling. Deny local recovery/trust, identity proxies, browser shared credentials, no-auth hosts, role-configured hosts, undeclared routes, and privileged scopes. Keep exact origins and frame policy handle-local, isolate sandbox routing, and compose plugin grant authority with host lifecycle and effect guards. Close fences admission and joins pending streams, sockets, and accepted work. Realizes B2 and core B5. Implements the runtime lifetime portion of B4, signed plugin-read cookie descriptors from B7, bounded core transport from B8, and shared-secret/recovery/service-worker denial from B9. Enrollment, durable audience credential binding, relay protocol/hosting/session delivery, and embedded presentation remain OC-2 and later phases. No schema, protocol, or existing device-token representation changes; no enrollment stubs. Add owner contract tests and an isolated paired-device HTTP/WS composition proof, public SDK export registration, and capability/security documentation. Remove one inherited unused local in channel-presence-policy to unblock core typechecking. Validation: affected owner/sibling tests, core/extension/UI/script typechecks, full build and affected runtime build, targeted lint, SDK export checks, docs checks, and fresh isolated review pass. Final integration proof passes in 173.69s; transport proof in 25.67s; security/factory proof in 125.52s. No CI dispatched. Existing full-lint/deadcode findings and SDK surface-budget overages remain recorded; this capability adds exactly one public subpath, ten exports, and no callable exports to the surface budget.
Add service-bound issue/cancel contracts and validate exact read/write scopes and device identity in the bootstrap owner. Keep enrollment unavailable before any credential issuance or pairing write until durable audience storage and downgrade behavior are approved. Document the storage gate and prove isolated ingress rejects shared credentials and the existing auto-approval bootstrap fallback. No schema or credential representation changes.
…gress Replace the rejected remote enrollment stub with the existing trusted-proxy operator pairing path. A live plugin grant authenticates signed browsers and auto-approves ordinary devices at the ingress read/read-write ceiling. Reject shared credentials, bootstrap tokens, role changes, excess scopes, and key mismatches. Bound credential-free token recovery without changing valid-token reconnect behavior or the existing HTTP device-token path. Remove issuePairingBootstrap/cancelPairingBootstrap, their forwarding, the manual enrollment policy and unavailable storage seam, and obsolete tests. Document plugin grant-holder authentication, normal device visibility and revocation, and the accepted direct-listener validity of ordinary tokens. No schema, migration, credential format, or new lifecycle machinery changes. Prove fresh pairing, token handoff/reconnect, read/write RPCs, admin denial, normal device list/revoke, same-key recovery, and direct-listener scope limits through one isolated Gateway fixture. Owner tests and all core type graphs, changed-file lint, docs, and focused guards pass. SDK surface budgets and the changed check's unused exports retain the exact inherited OC-2 failures.
Allow restricted HTTPS wildcard frame ancestors and preserve shared-origin handles with independent grant lifetimes. Advertise ingress origins in hello and board, Canvas, and MCP App sandbox responses while retaining existing mount paths and relative plugin-tab grants. Mark ingress documents so the browser stays on its serving Gateway, requests the grant ceiling, stores normal device tokens, and retries a rejected token once without credentials. Hide shared-credential login and connection inputs, and skip service-worker registration in embedded ingress. Validate through the isolated HTTP/WebSocket/Canvas composition, owner and UI regressions, affected type graphs, lint, docs, UI build, and SDK API comparison.
Merge the remote Control UI ingress branch at 1d697d0 and replace the unshipped direct embed with per-grant HTTP and WebSocket transport over the existing relay connection. Preserve paths, core device-token authority, plugin read cookies, and read/write scope ceilings. Bound frames, streams, sockets, queued bytes, and pending admissions; close them on cancellation, revocation, origin replacement, disconnect, and service retirement. Report UI capability in local and remote status and the CLI. The first launch on unsupported Gateway auth displays core's error in the frame; subsequent status falls back until config reload or plugin restart. Keep sandbox WebSockets forbidden. Update setup, trust, revocation, and limits documentation without adding a core availability API or plugin config. Validation: 22 tunnel tests, 34 service tests, 13 state tests, and 8 CLI tests pass. Final single-worker wall times: tunnel 11.40s, service 5.19s, state 10.22s, CLI 14.58s. The real ingress composition proves marked index HTTP and signed credential-free hello with a normal read/write device token; final targeted command 44.95s, test 6.53s. Its full existing suite also passed; cold compiler preparation dominates wrapper wall time. Core/plugin typechecks, changed-file lint, docs, config baselines, full build, and diff checks pass. Build/type/lint proof uses an exact candidate export with the frozen lockfile, preserving the shared Gateway install. Codex P2 review is clean after fixing shared-output and cancelled-admission resource accounting. CI timing remains pending the branch push.
Security-sensitive guard clearedCurrent revision: This PR no longer changes files in the maintainer security-review tier. Separate CODEOWNERS requirements still apply to security policy and enforcement files. |
|
Merged via squash.
|
Add the plugin and both documentation paths to the existing labeler map. This repairs the extension-coverage failure in scheduled run 38359584345, introduced when d46497e (#168233) added MCP relay without its label. Proof: the exact labeler-extension-coverage.test.ts file passes both tests (126.56 seconds command wall time). Changed-file formatting, lint and whitespace checks pass. Independent Codex review found no P0-P2 defects.
…aw#168233) * feat(mcp-relay): connect remote MCP clients to Gateway sessions Add a disabled-by-default bundled plugin with an outbound authenticated WebSocket, persistent Ed25519 identity, single-use pairing codes, and Gateway-owned grants with durable revocation tombstones. Expose status, conversation reads, owner-authored message submission, and bounded reply polling through existing documented SDK contracts. Keep approval handling in OpenClaw, omit custom source attribution, and provide running-Gateway CLI commands plus setup and security documentation. Validate with 121 focused tests, protocol vectors, and docs checks. Extension type lanes report no mcp-relay errors; unrelated QA-lab declarations and SDK declaration-preparation timeout leave environment-limited gates for CI. * fix(mcp-relay): repair session creation and use terminal replies Omit sessions.create idempotency keys for the principal-less in-process client while retaining the required key for chat.send. Enforce the real Gateway contract in the request fake so new-conversation sends regress when the unsupported key returns. Use agent.wait terminalReply as the sole reply source and direct expired snapshots to read_conversation. Remove transcript reconstruction, receipt lookups, and the run/session admission cache. Preserve conversation existence and current grant/connection authority around publication. Log redacted operation and Gateway diagnostics through the plugin logger and document the revised reply behavior. The plugin suite passes 122 tests in 108.68 seconds on Node 24.21.0. Regressions reproduced the original send failure, conversation-deletion race, and overlapping parameter redaction before their fixes. * feat(gateway): allow opt-in Control UI framing Validate explicit frame ancestors and apply them only to Control UI app documents. Preserve default CSP and X-Frame-Options denial, keep protected public and media surfaces unchanged, and hot-apply the policy to subsequent responses. * feat(mcp-relay): advertise the direct Control UI URL Accept an optional HTTPS controlUiUrl with matching manifest and runtime validation. Advertise controlUi.url only in configured remote status results, preserving the existing default response and relay authority. * docs: explain direct Control UI embedding in ChatGPT Document HTTPS setup, explicit trusted ancestors, separate Gateway origin policy, partitioned browser pairing, and existing cookie-backed plugin and SSO limitations. Refresh generated config baselines and relay inventory references. * chore(mcp-relay): fix lint findings * docs(mcp-relay): require a public, ungated Control UI URL for ChatGPT embedding * fix(mcp-relay): use the SDK record guard and cover openKeyedStoreV2 in the state fake * feat(gateway): add service-bound remote Control UI ingress Expose optional controlUiIngress on trusted plugin service contexts, with versioned HTTP/WS transport, presentation, and settlement contracts. Reuse the canonical HTTP, upgrade, device admission, and dispatch owners through bounded in-memory Node transports carrying immutable remote provenance. Require device-authenticated operators within a read/write ceiling. Deny local recovery/trust, identity proxies, browser shared credentials, no-auth hosts, role-configured hosts, undeclared routes, and privileged scopes. Keep exact origins and frame policy handle-local, isolate sandbox routing, and compose plugin grant authority with host lifecycle and effect guards. Close fences admission and joins pending streams, sockets, and accepted work. Realizes B2 and core B5. Implements the runtime lifetime portion of B4, signed plugin-read cookie descriptors from B7, bounded core transport from B8, and shared-secret/recovery/service-worker denial from B9. Enrollment, durable audience credential binding, relay protocol/hosting/session delivery, and embedded presentation remain OC-2 and later phases. No schema, protocol, or existing device-token representation changes; no enrollment stubs. Add owner contract tests and an isolated paired-device HTTP/WS composition proof, public SDK export registration, and capability/security documentation. Remove one inherited unused local in channel-presence-policy to unblock core typechecking. Validation: affected owner/sibling tests, core/extension/UI/script typechecks, full build and affected runtime build, targeted lint, SDK export checks, docs checks, and fresh isolated review pass. Final integration proof passes in 173.69s; transport proof in 25.67s; security/factory proof in 125.52s. No CI dispatched. Existing full-lint/deadcode findings and SDK surface-budget overages remain recorded; this capability adds exactly one public subpath, ten exports, and no callable exports to the surface budget. * fix(mcp-relay): merge duplicate SDK import * feat(gateway): prepare remote Control UI enrollment contract Add service-bound issue/cancel contracts and validate exact read/write scopes and device identity in the bootstrap owner. Keep enrollment unavailable before any credential issuance or pairing write until durable audience storage and downgrade behavior are approved. Document the storage gate and prove isolated ingress rejects shared credentials and the existing auto-approval bootstrap fallback. No schema or credential representation changes. * refactor(gateway): use regular device tokens for remote Control UI ingress Replace the rejected remote enrollment stub with the existing trusted-proxy operator pairing path. A live plugin grant authenticates signed browsers and auto-approves ordinary devices at the ingress read/read-write ceiling. Reject shared credentials, bootstrap tokens, role changes, excess scopes, and key mismatches. Bound credential-free token recovery without changing valid-token reconnect behavior or the existing HTTP device-token path. Remove issuePairingBootstrap/cancelPairingBootstrap, their forwarding, the manual enrollment policy and unavailable storage seam, and obsolete tests. Document plugin grant-holder authentication, normal device visibility and revocation, and the accepted direct-listener validity of ordinary tokens. No schema, migration, credential format, or new lifecycle machinery changes. Prove fresh pairing, token handoff/reconnect, read/write RPCs, admin denial, normal device list/revoke, same-key recovery, and direct-listener scope limits through one isolated Gateway fixture. Owner tests and all core type graphs, changed-file lint, docs, and focused guards pass. SDK surface budgets and the changed check's unused exports retain the exact inherited OC-2 failures. * feat(gateway): support credential-free embedded Control UI ingress Allow restricted HTTPS wildcard frame ancestors and preserve shared-origin handles with independent grant lifetimes. Advertise ingress origins in hello and board, Canvas, and MCP App sandbox responses while retaining existing mount paths and relative plugin-tab grants. Mark ingress documents so the browser stays on its serving Gateway, requests the grant ceiling, stores normal device tokens, and retries a rejected token once without credentials. Hide shared-credential login and connection inputs, and skip service-worker registration in embedded ingress. Validate through the isolated HTTP/WebSocket/Canvas composition, owner and UI regressions, affected type graphs, lint, docs, UI build, and SDK API comparison. * refactor(mcp-relay): remove unshipped direct Control UI embedding * fix(gateway): give remote Control UI upgrade sockets net.Socket timeouts The Gateway WebSocket keepalive arms an inactivity timeout on the upgrade request's socket. Remote Control UI ingress hands the upgrade an in-memory duplex without setTimeout, so the first keepalive tick after an embedded browser authenticated threw `transport.setTimeout is not a function` from a timer and crashed the Gateway. Give the server side of the in-memory transport net.Socket inactivity-timeout semantics (setTimeout/timeout, refreshed by traffic in either direction, cleared with the operation) plus no-op setNoDelay/setKeepAlive. A regression test runs the real keepalive against an ingress-upgraded socket; it reproduced the crash before the fix. * fix(gateway): grant the ingress ceiling to returning embedded browsers The embedded Control UI requests no explicit scopes and lets core grant the remote ingress ceiling. Core applied that default only to credential-free connects, so a returning browser presenting its stored device token got an empty scope set and every RPC failed with `missing scope: operator.read`. Apply the ceiling default to every remote ingress connect with an empty scope request, after signature verification as before. The integration test now covers the real reconnect shape (device token, empty scopes); it failed before this change. * perf(mcp-relay): pass compressed and cacheable Control UI responses through The tunnel dropped Accept-Encoding and Content-Encoding and forced Cache-Control: no-store, so every Control UI asset crossed the Gateway uplink uncompressed and was refetched on every launch. The Gateway already serves Brotli (the main bundle shrinks 268 KB -> 72 KB) with immutable caching. Forward Accept-Encoding, keep Content-Encoding and the Gateway's Cache-Control, and leave shared-cache prevention to the relay, which marks every tunneled response private on its per-grant origin. * fix(gateway): complete embedded Control UI owner reads Use the existing shared-owner actor for locally approved ingress connections and their device-token reconnects. Authenticate credential-free Control UI reads with the live grant, retain owner resource authorization and token revocation, and admit private backgrounds plus the exact bootstrap config alias. Gate embedded question requests under the read/write ceiling without changing personal session-question or admin, approval, and pairing rules. Extend the suite-level ingress and UI reconnect regressions; document the resource and identity contracts. * feat(ui): add embedder Gateway switcher transport Expose linked Gateways, primary selection, and host settings through the existing identity menu for framed remote ingress. Validate parent snapshots and omit unsupported native actions while preserving the WebKit transport. * feat(gateway): bind remote ingress and RPC to live principals Add capability-negotiated owner and verified-person grants with a chosen operator ceiling intersected with current role and access authority. Share that principal across Control UI transport and origin-free Gateway RPC. Keep signed ingress connects tokenless, preserve paired-device visibility, and retain grant authority through HTTP resources, nested plugin calls, personal actions, computer operations, and pending effects. Closing a UI handle also drains its actual RPC execution. * fix(ui): keep remote ingress connections tokenless Sign ingress connects without cached or supplied credentials and leave scope selection to the live grant. Remove ingress token recovery and prevent credential-backed warm boot across relay grants. Use the admitted personal profile for question eligibility while preserving the ordinary direct Gateway authentication and credential paths. * test(gateway): require tokenless ingress HTTP reads Keep a valid paired token as a negative control alongside the shared Gateway token, and prove credential-free reads use the live grant ceiling. * refactor(gateway): simplify remote ingress ownership and adapters * refactor(gateway): remove ingress accounting and settlement * refactor(mcp-relay): simplify plugin authority and tunnel ownership Remove the unshipped grant-state migration and old-host fallback. Centralize result limits and publication checks in the service, keep live authority at host effects, and let scheduler scopes own tunnel cancellation. Simplify state candidates, Connected apps refreshes, and duplicate test layers while preserving tokenless ingress and revocation regressions. * refactor(mcp-relay): simplify state and tunnel ownership * refactor(plugins): complete principal-bound ingress factory cutover * fix(mcp-relay): reopen retired bindings and bound UI buffers Evict stale principal and UI handles so live grants can reopen under current authority. Bound assembled WebSocket messages and the relay output queue without adding drain machinery. Use the runtime V2 store owner in integration fixtures, retain sanitized logging, and align the plugin version with the repository sync tool. * fix(mcp-relay): evict bindings retired by unsupported auth Include unsupported-auth in binding retirement so corrected Gateway authentication can admit a fresh binding. Cover recovery when the old binding keeps returning its stored error. * build(mcp-relay): refresh generated Control UI assets * test(mcp-relay): bind the retired ingress mock explicitly * fix(mcp-relay): serialize grant writes and bound pending uploads Use the existing grant mutation queue for creation and approval so revocation cannot be overtaken. Bound accepted HTTP uploads before enqueueing and terminate saturated control-frame sends through the connection lifecycle. * fix(mcp-relay): preserve active grant authority
Add the plugin and both documentation paths to the existing labeler map. This repairs the extension-coverage failure in scheduled run 38359584345, introduced when 74177cb (openclaw#168233) added MCP relay without its label. Proof: the exact labeler-extension-coverage.test.ts file passes both tests (126.56 seconds command wall time). Changed-file formatting, lint and whitespace checks pass. Independent Codex review found no P0-P2 defects.
…se (#172299) mcp-relay (#168233) and muse (#170487) were added without the assets/icon.png and assets/activity.svg every bundled plugin must ship, so bundled-plugin-icons.test.ts fails with ENOENT in the plugin sweep. mcp-relay is OpenClaw infrastructure: reuse the shared OpenClaw mascot identity and add a functional relay glyph in the Connections and sharing activity family. muse is Meta's Muse Code runtime for the Meta provider: reuse the Meta identity and activity artwork byte-for-byte.
…se (openclaw#172299) mcp-relay (openclaw#168233) and muse (openclaw#170487) were added without the assets/icon.png and assets/activity.svg every bundled plugin must ship, so bundled-plugin-icons.test.ts fails with ENOENT in the plugin sweep. mcp-relay is OpenClaw infrastructure: reuse the shared OpenClaw mascot identity and add a functional relay glyph in the Connections and sharing activity family. muse is Meta's Muse Code runtime for the Meta provider: reuse the Meta identity and activity artwork byte-for-byte.
What Problem This Solves
Remote MCP clients and ChatGPT's embedded browser need a transport to a private Gateway without exposing an inbound port or sharing the Gateway token or password.
User Impact
The optional, disabled-by-default
mcp-relayplugin connects outbound to the relay. Users authorize each app through Sign in with your Gateway or a single-use pairing code and manage grants in Connected apps. Pairing defaults to read/write access capped by the user's role; choosing full role access can also permit administration and approvals.Every grant belongs to its approving owner or signed-in person. MCP operations and the tokenless embedded Control UI share that principal and the selected scope ceiling intersected with its live permissions. Revocation closes the UI transports and fences retained work. On verified-profile Gateways, people pair as themselves; CLI owner pairing remains available on single-user Gateways.
The relay can read and modify transit content. This is not end-to-end encryption against the relay, and a compromised relay can exercise an existing grant's allowed operations. Enable the plugin and approve an app only when that authority is intended. Existing installations remain disconnected until the plugin is enabled. Identity, pairing hashes, and grant state use the Gateway's durable plugin state owner and survive updates; this new plugin needs no legacy-state migration.
Why This Change Was Made
This is the plugin consumer of the core ingress capability merged in #170540 (
2444aae8f8f9e593f4801127eab4b37d3703c4c6). The core owns principal resolution, live authorization, session visibility, HTTP/RPC admission, and transport lifetime. This PR contains the relay protocol and service, pairing/consent and grant management, Connected apps UI, plugin metadata/docs, and the real-plugin integration case.The plugin serializes grant writes and revocation so pending pairing cannot restore revoked access. Existing grant IDs cannot replace their authority. Bounded HTTP/WebSocket payloads and outgoing queues make overload visible and close affected streams. Consent uses the authenticated Gateway caller and returns only to the configured relay origin; profile IDs stay on the Gateway.
Evidence
Published head
50f86891ec7f0553b52f1b4b358954535c75c4d8, after merging main605065ce746. Plugin and integration source remain byte-identical to tested/reviewed87e478a6bc49b61451e5aa319a16c86aba68f3bc; only main integration and generator-owned config metadata changed, and the regenerated metadata passed validation. The diff is plugin-only, including its real-plugin integration fixture, metadata and documentation.pnpm test extensions/mcp-relay src/gateway/remote-control-ui-ingress.integration.test.ts --maxWorkers=1: 161 plugin tests and 7 real-ingress cases passed; 141.93 seconds wall time. The integration case exercises the actual plugin, durable keyed state, HTTP/WebSocket ingress, owner/person authorization, role reduction, and revocation using synthetic relay I/O. The integration file takes 116.63 seconds including first-run source preparation; its actual cases reuse one isolated Gateway fixture.d46497e0f67cba6ff8aaff9391a297e0133cc010; no admin exception.Earlier owner-only revisions had live ChatGPT/production-relay smoke coverage. The current person/Team/sign-in flow uses synthetic relay I/O with real isolated Gateway ingress. Live OAuth-provider sign-in and the relay's 30-day refresh-token expiry enforcement were not independently verified. The coordinator Gateway was not restarted or reconfigured.
Before: Connected apps was unavailable.
After: caller-bound consent shows the app, return host, approving person, selected ceiling, and administration warning. All capture data is synthetic.
Release-note context: optional MCP relay integration with principal-bound grants, tokenless embedded Control UI, Gateway sign-in consent, and a Connected apps management tab. Pairing codes remain supported; owner pairing defaults to read/write access on single-user Gateways. The reusable core API is documented in #170540.