Repository navigation
feat: connect Agents API sessions to HTTP MCP servers - #160931
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
474896c to
e110509
Compare
e110509 to
ce0e8dd
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 29, 2026, 3:26 AM ET / 07:26 UTC (Revision 7). ClawSweeper reviewWhat this changesThe Agents API plugin translates configured Streamable HTTP MCP servers into native session tools, with shared configuration handling, filtering, tests, and reset guidance. Merge readiness✅ Ready for maintainer review Current main does not connect configured MCP servers to Agents API sessions. The current branch addresses the prior transport-precedence finding, and the recorded live exercise supports the central behavior. No new actionable defect was found. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw loads operator and plugin MCP definitions during an Agents API conversation attempt. The plugin selects supported servers for native session creation, after which the service runs MCP calls and OpenClaw delivers the reply. flowchart LR
A[Operator and plugin MCP settings] --> B[Shared configuration merge]
B --> C[Scope and transport selection]
C --> D[Session binding check]
D --> E[Agents API session]
E --> F[Native MCP calls]
F --> G[Conversation reply]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +165, Tests +43, Docs +77. Total +285 across 12 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: The Agents API harness should use the official SDK for supported static HTTP MCP servers, diagnose omitted definitions, and retain the documented /new upgrade path for existing native sessions. Do we have a high-confidence way to reproduce the issue? Not applicable as a bug reproduction: current-main source does not forward MCP tools in Agents API session creation, and the branch's changed behavior has a recorded live exercise. Is this the best way to solve the issue? Yes. The adapter reuses shared configuration handling and the official SDK's native MCP tool contract, keeping transport execution with the Agents API. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against fc312928cfb2. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (6 earlier review cycles)
|
Live Docker and hosted-environment evidenceRan the ordinary Slack conversation flow against a native Built source: Used the anonymous public example in the official MCP guide,
Observed limitation: the first exercise encountered API HTTP 503, Offline image verification, changed-file formatting, and |
|
The maintainer accepts the MVP limitation that existing native sessions cannot adopt changed MCP definitions. No live configuration update or automatic session replacement will be implemented in this PR. The existing Documented in a30c73da71f. This commit changes documentation only; the implementation and retained live-test evidence are unchanged. The other requested behavior changes are still awaiting the maintainer's decision. |
50bb48c to
7318030
Compare
|
Addressed the unsupported-definition and transport-default findings in 7318030461baec3ce5ff6f9e97ffb8af9e74b128. Each unsupported MCP definition now logs an error and is omitted; supported native connections remain required. URL-only definitions retain the existing SSE interpretation and are omitted unless Streamable HTTP is selected explicitly. The commit quotes the review requests. The maintainer accepted the remaining session-update limitation for this MVP: existing native sessions do not adopt changed MCP settings automatically. The existing reset guidance is documented, and the earlier live proof exercised normal The existing persistence test expectation was amended into the original feature commit to match the expanded reset error. Independent review of the current head found no actionable issues through P2. Real Docker verification of the new skip-and-log behavior is in progress. |
|
Maintainer decision for this MVP: accept the documented reset requirement, including upgrading an existing Agents API conversation when a Streamable HTTP server was already configured. That conversation may require The explicit direction was: “we dont need to support resset for mvp, just document the gap.” The README documents this limitation. The previous live evidence proves configuration-change rejection and recovery through Please treat the reset behavior as an accepted MVP limitation. The separate, newly raised unavailable-server policy is being reviewed independently. |
|
Applied the approved transport-precedence fix in 6a6c0152931. The core MCP runtime and Agents API now use one resolver in the existing shared MCP configuration module. An explicit Formatting and whitespace checks passed after the commit was pushed. The prior hosted live evidence remains bound to its recorded head; the mixed-alias path has not had a new live run. The separate subagent CI failure was not changed, and the current branch conflicts with main. |
ClawSweeper requested: > The loader reads global and bundled MCP definitions. An enabled SSE, Gateway OAuth, or custom TLS server now throws before any Agents API message proceeds, even when that server is for another runtime. Omit unsupported definitions with a clear diagnostic so they cannot disable unrelated conversations. > The existing MCP resolver treats a server with `url` but no transport as SSE. This adapter accepts it and declares Streamable HTTP instead, so an existing URL-only definition is sent to the wrong native transport. Require an explicit Streamable HTTP selection before forwarding. Log an error and omit each unsupported server, including unsupported tool filters and unresolved headers. Keep supported native connections required and reuse the existing transport-alias mapping.
ClawSweeper requested: > Every enabled supported server becomes required during native initialization, including a shared server unreachable from an OpenAI-hosted environment. That can stop otherwise unrelated Agents API conversations. The earlier review mentioned this availability risk; this is a late line-level finding for its unchanged trigger. Use the native optional initialization default so conversations can continue when an MCP service is unavailable.
6a6c015 to
f4fba46
Compare
Use the existing shared MCP configuration module to resolve explicit transport before legacy type aliases in both the core transport runtime and Agents API. Command-bearing definitions remain outside Agents API HTTP forwarding. ClawSweeper request: "Late discovery: a valid server with `transport: "streamable-http"`, a URL, and legacy `type: "stdio"` is skipped here, although canonical configuration and the new docs give explicit transport precedence. Compute the effective transport before rejecting a stale type alias; continue to omit command-bearing definitions."
f4fba46 to
9bc7723
Compare
|
@clawsweeper re-review Please review current head Current-head CI is running. Formatting and whitespace checks passed. Earlier accepted live Docker/hosted Linux/Slack evidence remains pinned to |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
…shipped Main has been red since b4ae783 (feat: connect Agents API sessions to HTTP MCP servers, #160931): it added three callable exports to src/plugin-sdk/agent-harness-runtime.ts without the surface ratchet update, so test/scripts/plugin-sdk-surface-report.test.ts failed 2/10 (public exports 4594 > 4591, callable 2698 > 2695). Its parent passes 10/10 and the counts at b4ae783 equal current main, so the whole delta is that merged, reviewed feature. Raise publicExports 4591 -> 4594 and publicFunctionExports 2695 -> 2698, exactly that growth with no headroom. Removing the exports would break the landed feature. @sjf-oa (Sarah Fortune), please review whether these three exports should stay public or move behind a narrower seam. Proof: plugin-sdk-surface-report.test.ts 10/10 (was 2 failed / 8 passed).
* feat: connect Agents API sessions to HTTP MCP servers * docs(agentsapi): document deferred MCP session updates * fix(agentsapi): skip unsupported MCP definitions ClawSweeper requested: > The loader reads global and bundled MCP definitions. An enabled SSE, Gateway OAuth, or custom TLS server now throws before any Agents API message proceeds, even when that server is for another runtime. Omit unsupported definitions with a clear diagnostic so they cannot disable unrelated conversations. > The existing MCP resolver treats a server with `url` but no transport as SSE. This adapter accepts it and declares Streamable HTTP instead, so an existing URL-only definition is sent to the wrong native transport. Require an explicit Streamable HTTP selection before forwarding. Log an error and omit each unsupported server, including unsupported tool filters and unresolved headers. Keep supported native connections required and reuse the existing transport-alias mapping. * fix(agentsapi): make MCP initialization optional ClawSweeper requested: > Every enabled supported server becomes required during native initialization, including a shared server unreachable from an OpenAI-hosted environment. That can stop otherwise unrelated Agents API conversations. The earlier review mentioned this availability risk; this is a late line-level finding for its unchanged trigger. Use the native optional initialization default so conversations can continue when an MCP service is unavailable. * fix(agentsapi): share MCP transport precedence Use the existing shared MCP configuration module to resolve explicit transport before legacy type aliases in both the core transport runtime and Agents API. Command-bearing definitions remain outside Agents API HTTP forwarding. ClawSweeper request: "Late discovery: a valid server with `transport: "streamable-http"`, a URL, and legacy `type: "stdio"` is skipped here, although canonical configuration and the new docs give explicit transport precedence. Compute the effective transport before rejecting a stale type alias; continue to omit command-bearing definitions." --------- Co-authored-by: Sarah Fortune <[email protected]>
…#160931 shipped Main has been red since 00e2fb1 (feat: connect Agents API sessions to HTTP MCP servers, openclaw#160931): it added three callable exports to src/plugin-sdk/agent-harness-runtime.ts without the surface ratchet update, so test/scripts/plugin-sdk-surface-report.test.ts failed 2/10 (public exports 4594 > 4591, callable 2698 > 2695). Its parent passes 10/10 and the counts at 00e2fb1 equal current main, so the whole delta is that merged, reviewed feature. Raise publicExports 4591 -> 4594 and publicFunctionExports 2695 -> 2698, exactly that growth with no headroom. Removing the exports would break the landed feature. @sjf-oa (Sarah Fortune), please review whether these three exports should stay public or move behind a narrower seam. Proof: plugin-sdk-surface-report.test.ts 10/10 (was 2 failed / 8 passed).
What Problem This Solves
Agents API sessions currently ignore configured HTTP MCP servers, so operators cannot use those services through the harness. This adds native HTTP MCP configuration while deferring stdio support.
User Impact
Enabled Streamable HTTP servers from
mcp.serversand plugin bundles are supplied to the official SDK. Connections originate from the session's execution environment. The native API owns discovery and execution; the Gateway does not create another transport.Explicit headers, environment-backed headers, exact tool allowlists and session server overrides are supported. Unsupported definitions log an error and are omitted. Supported servers use the API's optional initialization default, so an unavailable service does not block an unrelated conversation.
Stdio, requester-scoped connections, Gateway OAuth profiles, legacy SSE and custom TLS are outside this first step. URL-only definitions retain the existing SSE interpretation. Exclusions require an explicit include list so the native API can enforce them.
Implementation
Reuse shared MCP configuration merging and connection-scope partitioning through a lazy harness SDK helper. The shared configuration module also owns explicit-transport precedence over legacy type aliases, used by both the core MCP runtime and Agents API. Keep API-specific translation in the Agents API plugin. Include effective native MCP definitions in the existing session-binding fingerprint.
Accepted MVP Limitation
Existing native sessions do not adopt changed MCP settings automatically. Upgrading an existing conversation with an already-configured HTTP server may require
/new, even without a separate configuration edit. The maintainer explicitly accepted this limitation; no saved-binding migration or automatic session replacement is intended. Recorded maintainer decision.Evidence
Implementation was pushed before validation. Live evidence on 6077a1d6c1b uses native ARM64 Docker, an OpenAI-hosted Linux environment and ordinary Slack messages. A real unavailable MCP initialization failed while the same turn successfully used the documentation MCP and delivered its reply. Eight unsupported definitions logged errors and were omitted. A genuine pre-feature saved conversation was backed up and restored into the feature image, rejected before native execution, then recovered through
/new. The native session ended idle, OpenClaw ended done, and both delivery queues were empty. No mocks, fake bindings or special test modes were used in that live exercise.The current head is
9bc7723fa3f27b23f4a005b2e377b2c0578c0a18. The rebase resolves the conflict with main while retaining both hosted-network-policy and MCP session-binding checks. The maintainer-approved transport fix moves the existing precedence rule into one shared resolver used by the core MCP runtime and the Agents API adapter. Explicit HTTP transport now overrides a stale stdio type alias; command-bearing definitions remain omitted. The fix commit quotes the ClawSweeper request.The new no-mock regression,
forwards explicit HTTP transport over a stale type alias while excluding command-bearing servers, exercises real configuration merging and adapter output inextensions/agentsapi/agentsapi-mcp.test.ts. It passed in current-head CI in 3 ms; its 45-file shard took 77.48 seconds. The current-head persistence regression also passed in its CI job in 4.669 seconds, with a six-file shard duration of 36.61 seconds. These are CI measurements, not standalone file wall times. No unit tests were run locally. Changed-file formatting and whitespace checks passed after publication. Independent P0-P2 diff review completed scoped-clean. ClawSweeper revision 7 reviewed the current head and found no actionable findings or remaining before-merge items. Current-head CI completed successfully on its first attempt. The earlier live exercise does not claim execution of this mixed-alias case or the rebased head.The existing persistence fixture expectation was amended into the original feature commit. CI passed that case at an earlier head in 4.296 seconds; its containing shard took 36.65 seconds. Earlier CI also encountered a native Bun SIGSEGV without an assertion result; one diagnostic replay passed in 723 seconds without establishing the crash cause.
A subsequent earlier-head attempt exposed a separate subagent archive test failure:
starts delete-mode retention when its terminal lifecycle event completesexpectedexecution.status: "terminal"but received"running". The other 24 cases passed. The registry and fixture were unchanged by this PR, and the fixture does not run the Agents API harness. Bounded source inspection found no causal path from the MCP changes, but did not establish the asynchronous completion failure's cause or an owning fix. No timeout increase, blind rerun or unrelated lifecycle change was made. This historical result is separate from the current-head CI run.