Skip to content

feat(mcp): per-request header provider for volatile turn attribution on OpenClaw-owned HTTP transports - #154043

Open
TreyLawrence wants to merge 71 commits into
openclaw:mainfrom
TreyLawrence:feat/mcp-per-request-header-provider
Open

TreyLawrence wants to merge 71 commits into
openclaw:mainfrom
TreyLawrence:feat/mcp-per-request-header-provider

Conversation

@TreyLawrence

@TreyLawrence TreyLawrence commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Per-turn MCP attribution currently has to enter declarative server headers or the connection resolver. Declarative header changes invalidate the catalog; the reported Reef production measurement was 221 re-catalogs across 222 runs. The existing connection resolver caches requester credentials for five minutes, and changed resolved headers rotate the connection. Neither path can provide fresh turn attribution while retaining a transport and its catalog.

This adds a separate plugin request-header provider for OpenClaw-owned MCP HTTP transports. Upstream main was checked at 7aaef70932b30f4d7410ae00aa65b07089de2ce0; no equivalent provider existed.

Deployment consumer. The Reef embedder plugin (the same production deployment behind the measurement above) adopts this provider on release adoption: it moves traceparent and signed per-turn context headers off declarative server configuration and onto this seam, which retires the measured per-run re-catalog. Requester authentication stays entirely on the existing connection-resolver contract — this consumer sends attribution and turn-scoped credentials only, and its stable credentials are unchanged.

User Impact

Plugins can attach traceparent, signed turn credentials, and optional direct-request credentials to individual MCP requests without rebuilding the catalog or connection. Stable authentication remains in static server configuration or the existing connection resolver.

The SDK infrastructure documentation includes registration and embedded-runtime usage. This contract covers OpenClaw-owned HTTP transports; external harness-native MCP clients need OpenClaw materialized tools to use it.

Design

  • Add api.registerMcpServerRequestHeaderProvider({ serverName, resolve }), following connection-resolver registration conventions. Resolver and header-provider registrations share per-server plugin ownership, and the connection resolver is authoritative regardless of registration order: a foreign provider is rejected when the resolver already exists and displaced (removed, error diagnostic on the provider's plugin) when the resolver registers later. Registry state is identical in both orders, so a declared server with a resolver is never partitioned as static.
  • Only the host binds run identity. The embedded backend binds MCP attribution to the admitted run's actual sessionId/sessionKey/runId (internal bindMcpRequestRun), and the binding is revoked when that run settles. A context the host did not issue (forged) or whose run has settled (stale/reassigned) is dropped: the provider is not called and no volatile headers are sent. The public export from openclaw/plugin-sdk/agent-harness-runtime is runWithMcpRequestMetadata(metadata, callback) — caller tracing metadata only (e.g. traceparent), never identity.
  • Capture only MCP attribution when materializing tools. Each retained tool/resource/prompt executor opens its own operation scope, preserving attribution under overlapping acquisitions and calls without capturing unrelated cancellation or runtime authority.
  • Resolve volatile headers immediately before actual guarded HTTP fetches, including same-origin redirects and authentication/RPC retries. Streamable HTTP and SSE POST/EventSource paths share this boundary. Header values never enter server configuration, catalog identity, or the resolver rotation digest.
  • Keep configured headers, authentication, and MCP protocol fields authoritative. Scope provider headers to the configured origin; register returned values and bare bearer tokens for secret redaction. Bound provider resolution to ten seconds and report provider failures without exposing plugin error contents.

Correctness

Each operation owns an immutable context. Missing context explicitly clears inherited attribution and skips the provider. No transport stores a mutable latest-turn header map. Provider results are freshly merged into a new request header object and are not retained for redirect replay.

Initial SSE discovery can carry its discovery context. Shared streamable notification GETs and legacy SSE reconnects carry no volatile attribution. The streamable initialized-notification send has a short-lived scope so its shared stream parser and reconnect timers cannot retain the opening turn, including reconnects with Last-Event-ID. Resumable RPC streams retain their own still-active operation context. Completed scopes cannot supply headers to background callbacks.

Static authentication, requester credential revalidation/rotation, genuine configuration invalidation, tools/list_changed, and transport-close recovery retain their existing owners and behavior.

Evidence

Guarded caller-authority revalidation (Rev 24 P1, head 34a4b55ad)

Defect (ClawSweeper Rev 24). fetchWithSsrFGuard asserts the captured guarded caller authority (captureGuardedFetchRequestAuthority, e.g. a live cron-root claim) before invoking the transport fetchImpl. The header wrapper is that fetchImpl and awaits provider.resolve(), so authority revoked during resolution was not re-checked before stable credentials and volatile headers reached the server.

Fix. withMcpRequestHeaders captures the guarded assertion on entry and re-asserts it immediately before dispatch, alongside the existing abort and run-context checks. A revoked caller gets the assertion's own error, and no request is sent.

Final-effect proof. The real-runtime e2e adds a call under withGuardedFetchRequestAuthority whose MCP run stays active. Caller authority is revoked while the provider is resolving. The call is rejected, and the recording loopback server's request count is unchanged (no request for revoked_authority_operation). Regression-before-repair: with the re-assertion removed, the same scenario fails with promise resolved "{ content: [ ... ] }" instead of rejecting, meaning the real server received and answered the revoked call. A matching unit case (mcp-request-headers.test.ts) fails without the fix and passes with it.

Redacted terminal capture (OPENCLAW_E2E_SKIP_BUILD=1 OPENCLAW_E2E_VERBOSE=1 pnpm vitest run --config test/vitest/vitest.e2e.config.ts test/pr154043-real-runtime-proof.e2e.test.ts):

[pr154043-proof] allowed: real tools/call arrived with volatile header present
[pr154043-proof] canceled: rejected before I/O, server request count unchanged; pending send settled
[pr154043-proof] shared transport: subsequent attributed tools/call succeeded
[pr154043-proof] foreign: forged and SDK-asserted identity reached the server unsigned; provider never saw victim-run
[pr154043-proof] reassigned: settled run's captured context reached the server unsigned; provider never saw it
[pr154043-proof] revoked authority: provider resolved, caller authority revoked mid-resolution; rejected before I/O, server request count unchanged
 ✓ test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O
 Test Files  1 passed (1)
      Tests  1 passed (1)

At this head: focused suites 8 files / 156 tests passed; core tsgo passed; timeout-race ratchet clean for PR files; formatting and lint clean.

Run-identity authority + final-I/O proof (Rev 22 security item, head a6194b291)

Concern (ClawSweeper Rev 22). The public runWithMcpRequestContext accepted caller-supplied sessionId/runId, and the documented provider signs those IDs, so a caller could assert a foreign run and obtain a signed header at final HTTP I/O. A captured context also stayed usable after its run settled.

Fix — bind signed identity to admitted runs (the recommended option).

  • Identity is issued only by the host: runEmbeddedAttemptWithBackend calls the internal bindMcpRequestRun with the admitted run's identity, keeping enclosing caller metadata.
  • Each issued context carries run authority that is revoked when the run settles. getMcpRequestContext() returns nothing for a revoked or never-issued context, so the provider is never invoked for it. A run that settles while headers resolve is refused before dispatch by the existing MCP request context expired check.
  • The public SDK export narrows to runWithMcpRequestMetadata (metadata only). Plugins and embedded callers can no longer name a session or run.

Final-effect proof. test/pr154043-real-runtime-proof.e2e.test.ts now also drives, on the same real MCP SDK client + guarded streamable-HTTP transport + recording loopback server:

  • Foreign: a forged frozen context { runId: "victim-run" } and the public SDK helper each reach the server with no attribution header; the provider never sees victim-run.
  • Reassigned/settled: a context captured inside a run that has since settled reaches the server with no attribution header; the provider never sees it.

Regression-before-repair. With the old trust semantics temporarily restored (any context accepted, no revocation), the proof fails at final I/O. The server received a signed header for the forged run:

- Expected
+ Received
  {
-   "attribution": undefined,
+   "attribution": "synthetic-victim-run",
    "rpcMethod": "tools/call",
  }
 ❯ test/pr154043-real-runtime-proof.e2e.test.ts:193:75

Redacted terminal capture after the fix (OPENCLAW_E2E_SKIP_BUILD=1 OPENCLAW_E2E_VERBOSE=1 pnpm vitest run --config test/vitest/vitest.e2e.config.ts test/pr154043-real-runtime-proof.e2e.test.ts):

[pr154043-proof] allowed: real tools/call arrived with volatile header present
[pr154043-proof] canceled: rejected before I/O, server request count unchanged; pending send settled
[pr154043-proof] shared transport: subsequent attributed tools/call succeeded
[pr154043-proof] foreign: forged and SDK-asserted identity reached the server unsigned; provider never saw victim-run
[pr154043-proof] reassigned: settled run's captured context reached the server unsigned; provider never saw it
 ✓ test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O 61ms
 Test Files  1 passed (1)
      Tests  1 passed (1)

Unit coverage (src/agents/mcp-request-headers.test.ts) adds: forged identity never resolves headers, captured context revoked after its run settles, and a run settling mid-resolution refuses dispatch. agent-bundle-mcp-runtime.request-headers.test.ts now holds each turn open across acquisition and execution, as a host run does, and asserts that a settled turn's executor sends no attribution. On the merged head (current main 3f7689e64): focused suites (mcp-request-headers, agent-bundle-mcp-runtime{,.request-headers}, mcp-transport, mcp-http-transport, mcp-http-fetch, backend, requester-connect, registry-registrars-network.mcp-request-headers) 10 files / 159 tests passed; both PR e2e proofs passed; core tsgo passed; plugin-sdk:surface:check passed (budget pinned to exactly this PR's two exports); formatting and lint clean. The merge resolved main's mcp-http-fetch.ts redirect-policy refactor by applying the provider wrap inside the shared builder.

Registration-order fix + authority-chain proof (head 2587f4f3)

Defect (ClawSweeper P1, Rev 8). hasMcpServerOwnerConflict was first-registration-wins across both seams: a request-header provider registered first by plugin A caused plugin B's later registerMcpServerConnectionResolver for the same server to be rejected. partitionMcpServersByConnectionScope then found no resolver and classified the declared server as static, exposing its configured connection to requesters the resolver would have excluded. The PR's own registrar test pinned that behavior.

Fix. The connection resolver is authoritative regardless of order. registerMcpServerConnectionResolver still fails closed against a different plugin's resolver; against a different plugin's provider it now displaces it — the provider entry is removed and an error diagnostic is reported on the provider's plugin (MCP server request header provider for "<name>" displaced: connection resolver registered by plugin "<resolver plugin>" owns requester admission). registerMcpServerRequestHeaderProvider is unchanged (rejected when a different plugin owns either seam). Final registry state is identical in both registration orders. docs/plugins/sdk-overview/infrastructure.md states the rule.

Regression proof, unit (src/plugins/registry-registrars-network.mcp-request-headers.test.ts, it.each(["provider","resolver"])): with the registrar fix reverted, the provider-first case fails —

AssertionError: expected [ { level: 'error', …(3) } ] to deep equally contain ObjectContaining{…}

- Expected:
ObjectContaining {
  "level": "error",
  "message": StringContaining "displaced",
  "pluginId": "plugin-a",
}

+ Received:
[
  {
    "level": "error",
    "message": "MCP server connection resolver for \"user-mail\" rejected: already registered by plugin \"plugin-a\"",
    "pluginId": "plugin-b",
    "source": "/plugins/plugin-b/index.ts",
  },
]

— and passes with the fix (5/5). Both orders additionally assert, under withPluginRuntimeRegistryScope, that partitionMcpServersByConnectionScope puts user-mail in resolverRequesterServerNames and staticServers is empty.

Authority-chain proof, real transports (test/pr154043-registration-order-proof.e2e.test.ts, no transport/SDK mocks). plugin-a registers a request-header provider for user-mail; plugin-b registers a requester-scoped connection resolver that returns { url: <loopback>, headers: { Authorization: "Bearer proof-token" } } only for allowed-requester and null otherwise. The declared config is url: "https://placeholder.invalid/mcp"; the loopback (startRequesterScopedMcpProofServer) 404s without the bearer and records every request. Driven through materializeRequesterScopedMcpToolsForHarnessRun from openclaw/plugin-sdk/agent-harness-runtime. In both orders: user-mail partitions as resolver-scoped, never static; the allowed requester materializes tools and executes requester_probe, and every loopback request carried the bearer and none carried plugin-a's header; an excluded requester and a run with no requesterSenderId get no tools and the loopback request count does not move; plugin-a's provider is never invoked.

With the registrar fix reverted, the provider-first case fails at the static-partition assertion (the exact exposure):

AssertionError: expected { 'user-mail': { …(2) } } to deeply equal {}

- Expected
+ Received

- {}
+ {
+   "user-mail": {
+     "transport": "streamable-http",
+     "url": "https://placeholder.invalid/mcp",
+   },
+ }

 ❯ test/pr154043-registration-order-proof.e2e.test.ts:69

Redacted passing capture (OPENCLAW_E2E_SKIP_BUILD=1 OPENCLAW_E2E_VERBOSE=1 pnpm vitest run --config test/vitest/vitest.e2e.config.ts test/pr154043-registration-order-proof.e2e.test.ts test/pr154043-real-runtime-proof.e2e.test.ts):

 RUN  v5.0.1 <repo>
[pr154043-order-proof] provider-first: user-mail partitioned as resolver-scoped
[pr154043-order-proof] provider-first: allowed requester executed requester_probe; loopback served 5 bearer-authorized requests
[pr154043-order-proof] provider-first: excluded + anonymous requesters got no tools; loopback request count unchanged (5); foreign provider never invoked
[pr154043-order-proof] resolver-first: user-mail partitioned as resolver-scoped
 ✓ test/pr154043-registration-order-proof.e2e.test.ts > PR #154043 registration-order proof > keeps the connection resolver authoritative over requester admission (provider-first) 232ms
[pr154043-order-proof] resolver-first: allowed requester executed requester_probe; loopback served 5 bearer-authorized requests
[pr154043-order-proof] resolver-first: excluded + anonymous requesters got no tools; loopback request count unchanged (5); foreign provider never invoked
 ✓ test/pr154043-registration-order-proof.e2e.test.ts > PR #154043 registration-order proof > keeps the connection resolver authoritative over requester admission (resolver-first) 114ms
 ✓ test/pr154043-registration-order-proof.e2e.test.ts (2 tests) 349ms
[pr154043-proof] allowed: real tools/call arrived with volatile header present
[pr154043-proof] canceled: rejected before I/O, server request count unchanged; pending send settled
[pr154043-proof] shared transport: subsequent attributed tools/call succeeded
 ✓ test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O 14ms
 ✓ test/pr154043-real-runtime-proof.e2e.test.ts (1 test) 16ms
 Test Files  2 passed (2)
      Tests  3 passed (3)

Merge with main. Branch merged upstream/main (a08479ac, plain merge commit). Conflicts: backend.ts (main dropped harness-finalization imports; the runWithMcpRequestContext wrapper around runAgentHarnessAttempt is re-grafted on main's shape) and agent-bundle-mcp-runtime.test.ts (main extracted startRequesterScopedMcpProofServer to a test-support module; the PR's startRequestHeaderMcpProofServer now lives in agent-bundle-mcp-request-headers.test-support.ts, and the per-request header runtime tests moved to the sibling agent-bundle-mcp-runtime.request-headers.test.ts to satisfy the line-cap ratchet, leaving agent-bundle-mcp-runtime.test.ts untouched). scripts/plugin-sdk-surface-report.mts budget raised by this PR's two public exports (runWithMcpRequestContext, McpServerRequestContext).

Verification at this head: core tsgo 0 errors; unit batch (agent-bundle-mcp-runtime, backend, mcp-http-transport, mcp-request-headers, mcp-transport, registry-registrars-network.mcp-request-headers, mcp-connection-resolver) 7 files / 193 passed; agent-bundle-mcp-runtime.request-headers 2 passed; e2e proofs 2 files / 3 passed; test/scripts/eager-import-closure.test.ts 16 passed; pnpm config:docs:check OK; full pnpm lint (core + extensions) passed; pnpm check:changed green through the SDK surface budget, plugin boundaries, wrapper shadowing and core typecheck (the only failure, typecheck core tests, is two assertReliabilityForcedExit import errors in src/infra/package-update-activation-*.test.ts, present on untouched upstream main).

Cancellation lifecycle fix + real-runtime proof (head 15fdd821)

The prior head had a defect at the dispatch boundary: an operation canceled while provider.resolve() was awaited settles its attribution scope, and the fallback then forwarded the request without volatile headers on the retained transport — final I/O after cancellation, under stable connection credentials. The dispatch point now rejects an expired attributed operation with a content-free error instead of falling back; the shared-transport abort check is unchanged. Regression-before-repair was verified both ways: the new unit case fails on the old expression (fetch dispatches), and temporarily restoring the old expression makes the runtime proof's server-request-count assertion fail (expected 5, received 6).

test/pr154043-real-runtime-proof.e2e.test.ts drives the real transport path — resolveMcpTransport + the real MCP SDK Client over streamable HTTP against a loopback server that records every request it receives, with synthetic attribution and no real credentials. It proves, on one retained transport: (1) an allowed tools/call arrives carrying its volatile attribution header; (2) an operation aborted mid-header-resolution is rejected and the server receives no request for it (the real pending transport.send is observed to settle rejected, so the zero-I/O assertion cannot race dispatch); (3) a subsequent attributed call on the same transport succeeds.

Redacted terminal capture (OPENCLAW_E2E_SKIP_BUILD=1 OPENCLAW_E2E_VERBOSE=1 pnpm vitest run --config test/vitest/vitest.e2e.config.ts test/pr154043-real-runtime-proof.e2e.test.ts):

 RUN  v5.0.0 /Users/trey/work/.openclaw-worktrees/pr154043-fixes

stdout | test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O
[pr154043-proof] allowed: real tools/call arrived with volatile header present

stdout | test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O
[pr154043-proof] canceled: rejected before I/O, server request count unchanged; pending send settled

stdout | test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O
[pr154043-proof] shared transport: subsequent attributed tools/call succeeded

 ✓ test/pr154043-real-runtime-proof.e2e.test.ts > PR #154043 real runtime proof > dispatches attributed calls and rejects canceled calls before HTTP I/O 104ms

 Test Files  1 passed (1)
      Tests  1 passed (1)
   Start at  17:53:26
   Duration  2.08s

At this head: focused suites mcp-request-headers, mcp-http-transport, mcp-transport, registry-registrars-network.mcp-request-headers — 4 files / 46 tests passed; core tsgo passed; formatting clean.

Original evidence (unchanged)

  • Real HTTP and SSE tests send two distinct contexts through one retained runtime/transport, overlap acquisitions and asynchronous header resolution, execute retained tools in reverse completion order, and invoke a contextless tool under an unrelated ambient context. Wire assertions cover discovery headers, distinct turn credentials, unchanged static authorization, unchanged fingerprint, and exactly one initialize/tools-list cycle.
  • Registrar ownership tests cover same-plugin provider/resolver coexistence, foreign-provider rejection, and (at the current head) resolver displacement of a foreign provider in both registration orders.
  • Transport tests cover per-hop header refresh, cross-origin stripping, initial SSE discovery, contextless EventSource reconnects, notification reconnects with Last-Event-ID, and attributed RPC resumptions.
  • Provider/backend/registry tests cover copied immutable metadata, context expiration and clearing, secret registration, bounded failures, network error preservation, host identity binding, and registration ownership.

Validation on Node 24.18.0 with the pinned pnpm 12.4.0 toolchain:

  • pnpm build: passed.
  • Core tsgo: passed.
  • Focused transport/provider/backend/registration tests: 73 passed across 7 files.
  • Full agent-bundle-mcp-runtime.test.ts: 120 passed, 6 failed (all six reproduced on untouched upstream main); final source verification completed.
  • Targeted lint: passed with no warnings. Affected test-graph typechecks (agents-root, agents-other, plugins-platform): passed.
  • SDK export synchronization check: passed.

Both complete runtime runs had 120 passes and six failures. All six failures reproduced on untouched upstream main in an isolated archive using the same dependencies. They involve existing stdio cleanup exceeding test deadlines: concurrent catalog startup, catalog invalidation during connection, default hung tools/list timeout, reconnect after child exit, and private acquisition cancellation during initialize/tools-list. No deadlines, assertions, or production stdio behavior were changed. The final run used the settled source and completed artifact verification.

Changed upstream files
  • docs/plugins/sdk-overview/infrastructure.md
  • scripts/plugin-sdk-surface-report.mts
  • src/agents/agent-bundle-mcp-materialize.ts
  • src/agents/agent-bundle-mcp-request-headers.test-support.ts
  • src/agents/agent-bundle-mcp-requester.test-support.ts
  • src/agents/agent-bundle-mcp-runtime.request-headers.test.ts
  • src/agents/embedded-agent-runner/run/backend.test.ts
  • src/agents/embedded-agent-runner/run/backend.ts
  • src/agents/mcp-http-fetch.ts
  • src/agents/mcp-http-transport.test.ts
  • src/agents/mcp-http-transport.ts
  • src/agents/mcp-request-context.ts
  • src/agents/mcp-request-headers.test.ts
  • src/agents/mcp-request-headers.ts
  • src/agents/mcp-transport.test.ts
  • src/agents/mcp-transport.ts
  • src/plugin-sdk/agent-harness-runtime.ts
  • src/plugin-sdk/plugin-test-api.ts
  • src/plugins/api-builder.ts
  • src/plugins/plugin-api.types.ts
  • src/plugins/registry-empty.ts
  • src/plugins/registry-registrars-network.mcp-request-headers.test.ts
  • src/plugins/registry-registrars-network.ts
  • src/plugins/registry-types.ts
  • src/plugins/types.mcp-connection.ts
  • test/pr154043-real-runtime-proof.e2e.test.ts
  • test/pr154043-registration-order-proof.e2e.test.ts

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
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.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: L labels Sep 20, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 20, 2026
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Adds plugin-provided turn-specific MCP HTTP headers without rebuilding cached transports or tool catalogs.

Example: Two turns call the same MCP server with traceparent values trace-first and trace-second.

  • Before: Changing declarative headers invalidates the cached catalog; connection-resolver header changes rotate the connection.
  • After: Each request receives its turn's header while retaining one transport and one discovery cycle.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Strong transport-boundary evidence and no verified code findings; unresolved public API direction limits overall readiness, and current CI is not fully green.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): Supplied terminal traces exercise the real MCP SDK and guarded HTTP transport against recording loopback servers, covering retained attribution, cancellation, forged and settled identities, mid-resolution caller revocation, and excluded requester admission.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Needs a maintainer decision · Fix scope: Complete
User problem: Embedding plugins cannot refresh turn attribution on every MCP HTTP request without invalidating catalogs or rotating connections.
Reason: The implementation addresses a real missing extension boundary, but public API acceptance has no recorded owner decision.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it supplies a missing per-request MCP capability with meaningful transport proof and no verified code findings, but acceptance of the public SDK contract remains unresolved.

Priority: P2
Reviewed head: 588cf490a814d461d414eab48b70c25ee4ee2977
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should OpenClaw support registerMcpServerRequestHeaderProvider and runWithMcpRequestMetadata as public contracts for turn attribution and host-bound turn credentials?
  • Recommendation: Accept the narrow attribution contract: Sponsor the proposed seam while retaining connection-resolver ownership of requester admission and stable authentication.
  • Why: The source demonstrates a gap between per-request attribution and cached connection credentials, but neither the discussion nor recorded reviews approves this API expansion.

Before merge

  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Agent review details

How this fits together

The embedded runner binds run identity, materialized MCP tools retain attribution, and the HTTP fetch boundary combines plugin-provided headers with authoritative transport credentials before network dispatch.

flowchart LR
  A[Embedded run] --> B[Host-bound context]
  B --> C[Materialized MCP tools]
  C --> D[Retained HTTP transport]
  E[Plugin header provider] --> F[Guarded request dispatch]
  D --> F
  F --> G[MCP server]
Loading

Technical review

Best possible solution:

Accept a narrow plugin-owned attribution seam if the SDK owners endorse its public contract and separation from requester authentication.

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

Source confirms that declarative header changes affect catalog identity and resolved connection headers affect rotation; supplied loopback traces demonstrate distinct turn headers on a retained transport, though this review ran no target code.

Is this the best way to solve the issue?

Separating volatile attribution from cached credentials addresses the demonstrated boundary cleanly, while the exact supported public API remains an owner decision.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 9f83c05ea3a4.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 1cf8ea4 adds src/agents/mcp-http-transport.ts:92 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 1cf8ea446df4; files: src/agents/mcp-http-transport.ts)
  • Ayaan Zaidi: Raw commit 7d99de8 adds src/plugins/types.mcp-connection.ts:10 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 7d99de8e32d3; files: src/plugins/types.mcp-connection.ts)
  • Vincent Koc: Raw commit d10d71c adds src/plugin-sdk/agent-harness-runtime.ts:11 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: medium; commits: d10d71cdb659; files: src/plugin-sdk/agent-harness-runtime.ts)

PR surface

Source +334, Tests +1217, Docs +75, Other +2. Total +1628 across 27 files. Added test files: 6.

View PR surface stats
Area Files Added Removed Net
Source 15 364 30 +334
Tests 10 1217 0 +1217
Docs 1 79 4 +75
Config 0 0 0 0
Generated 0 0 0 0
Other 1 4 2 +2
Total 27 1664 36 +1628

Review metrics

Metric Value Why it matters
Public API expansion 1 registration method; 2 SDK exports, including 1 callable Adds an ongoing supported contract without adding configuration keys or persisted state.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A bounded integration improvement with a concrete attribution use case and no demonstrated urgent regression.
  • merge-risk: 🚨 compatibility: The PR adds a public plugin contract whose ownership and long-term support require an SDK direction decision.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (46 earlier review cycles; latest 8 shown)
  • reviewed 2026-10-10T09:48:01.727Z sha cb75d3b :: blocked before merge. :: none
  • reviewed 2026-10-10T10:26:28.328Z sha 494317e :: blocked before merge. :: none
  • reviewed 2026-10-11T08:16:00.633Z sha 6bec077 :: blocked before merge. :: none
  • reviewed 2026-10-11T13:20:51.789Z sha 5ccb9b6 :: blocked before merge. :: none
  • reviewed 2026-10-13T11:09:09.087Z sha cfa374f :: blocked before merge. :: none
  • reviewed 2026-10-13T21:30:36.373Z sha 0d9c121 :: blocked before merge. :: none
  • reviewed 2026-10-14T00:00:46.752Z sha 0b22c5d :: blocked before merge. :: none
  • reviewed 2026-10-14T02:05:55.550Z sha d997d10 :: blocked before merge. :: none

Reviewed October 14, 2026, 9:55 AM ET / 13:55 UTC (Revision 47).

@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 20, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 20, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 21, 2026
@TreyLawrence
TreyLawrence force-pushed the feat/mcp-per-request-header-provider branch 2 times, most recently from 3b78e62 to b764fbf Compare September 23, 2026 16:27
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

No content change: b764fbf17 is a tree-identical amend of the reviewed head 3b78e6223, pushed only to retrigger CI. The previous run landed inside a main-red window (launcher fixture breakage from #147621, fixed on main 36 minutes later by #155825); none of the failing files are touched by this PR.

TreyLawrence and others added 2 commits September 23, 2026 23:54
…spatch

A tool call canceled while the request-header provider resolves settles its
attribution scope; the dispatch fallback then forwarded the original request
without volatile headers on the retained transport. Reject the expired
attributed operation before any HTTP I/O instead. Adds unit coverage and a
real-runtime loopback proof (test/pr154043-real-runtime-proof.e2e.test.ts).

Co-Authored-By: Claude Fable 5 <[email protected]>
@TreyLawrence
TreyLawrence force-pushed the feat/mcp-per-request-header-provider branch from b764fbf to 43a4d95 Compare September 24, 2026 03:59
@clawsweeper clawsweeper Bot removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 27, 2026
TreyLawrence and others added 3 commits October 15, 2026 14:11
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing tests are outside this PR and pass on current main.

TreyLawrence and others added 4 commits October 16, 2026 10:39
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing Slack test is outside this PR and passes on current main.

TreyLawrence and others added 5 commits October 16, 2026 12:44
…tion-order proof

Main removed the agent-bundle-mcp-runtime testing facade (openclaw#174347).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing test is outside this PR and passes on current main.

TreyLawrence and others added 3 commits October 17, 2026 00:49
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
#	src/agents/embedded-agent-runner/run/backend.test.ts
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing checks are outside this PR and pass on current main.

…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
#	src/agents/mcp-http-transport.ts
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing checks are outside this PR and pass on current main.

…t-header-provider

# Conflicts:
#	docs/plugins/sdk-overview/infrastructure.md
#	src/plugins/registry-registrars-network.ts
…t-header-provider

# Conflicts:
#	scripts/plugin-sdk-surface-report.mts
@TreyLawrence

Copy link
Copy Markdown
Contributor Author

Retriggering CI: the failing checks are outside this PR and pass on current main.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant