Repository navigation
Conversation
`SingleAgentClient.getAgentInfo()` previously routed its post-discovery listTools connection through `connectMCP`, which has no retry on `StreamableHTTPError` and no SSE fallback. Every other production path (`callMCPTool`, `mcp-tasks`) goes through `connectMCPWithFallback`, which retries once on transient session errors and falls back to `SSEClientTransport` for non-401 failures. The asymmetry surfaced as `getAgentInfo()` failing on flaky StreamableHTTP servers where the comply suite kept working. - Extend `connectMCPWithFallback` with an optional `authProvider` parameter, forwarded to both StreamableHTTP and SSE transports so OAuth-protected agents still work through the fallback. - Rewire `getAgentInfo()` to use `connectMCPWithFallback` for both bearer-token and saved-OAuth-token cases. - `discoverMCPEndpoint`'s "Failed to discover MCP endpoint" error now includes a hint that the most common cause is `agent_uri` pointing at the host root when the MCP endpoint lives at a non-standard path. Closes #1233, #1234. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
Convergence findings from parallel review (protocol + code + security): - Add SSE-fallback regression test (`connectMCPWithFallback` against a public-shaped URL with mocked global fetch). The original test only exercised the StreamableHTTP retry path; the headline SSE-fallback behavior was untested because 127.0.0.1 short-circuits the fallback path via the isPrivateAddress gate. - Add a paired test pinning that the isPrivateAddress gate is preserved for loopback addresses (no SSE fallback fires). - Drop `/adcp/mcp` from the discovery-hint examples; replace with `/v1/mcp` (more conventional in the wild). - Loosen `initCount` assertion in the retry test to `>= 2` so the test doesn't couple to discovery probe-order internals. Single-reviewer items addressed: - JSDoc note on `connectMCPWithFallback`: unlike `connectMCP`, this helper does not attach `transport`/`client` to a thrown `UnauthorizedError`, so callers that need `transport.finishAuth(code)` should use `connectMCP` directly. Non-interactive providers work fine. - Comment at `connectionCacheKey` flagging that any future caller threading `authProvider` through `withCachedConnection` must add an OAuth-identity dimension to the cache key to prevent cross-tenant collisions. - Tighten changeset prose: the retry predicate is `StreamableHTTPError` specifically (not generic transient errors). Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
| let postCount = 0; | ||
| let getCount = 0; | ||
| globalThis.fetch = async (input, init) => { | ||
| const url = typeof input === 'string' ? input : input?.url ?? input?.toString(); |
Contributor
Author
|
Closing without merge after stepping back. The PR addresses a theoretical asymmetry (getAgentInfo lacks fallback) that no user has reported biting them, and the SSE-fallback test ended up mocked enough that it pins the wiring rather than real behavior. Splitting the actually-useful pieces:
Per @adcp project guidance: don't add error handling for scenarios that can't happen. |
Contributor
Author
|
Acknowledged — clean decomposition. The discovery hint (#1234) and retry-predicate widening (separate issue) are both trackable independently now. Nothing further needed from triage here. Generated by Claude Code |
2 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SingleAgentClient.getAgentInfo()now usesconnectMCPWithFallbackinstead ofconnectMCP, gaining the same StreamableHTTP-retry / SSE-fallback semantics that every other code path (callMCPTool,mcp-tasks) already has.connectMCPWithFallbacklearns an optionalauthProviderparameter, forwarded to both StreamableHTTP and SSE transports so OAuth-protected agents still work through the fallback.discoverMCPEndpoint's "Failed to discover MCP endpoint" error message now appends a hint that the most common cause isagent_uripointing at the host root while the MCP endpoint lives at a non-standard path (e.g./api/mcp,/adcp/mcp).Background
Discovered while investigating #1231 (closed as not-a-bug). Root cause at
adcp.bidmachine.iowas registration mismatch — the MCP endpoint is at/adcp/mcpand requires bearer auth, but the AAO probe registered the host root. Two real-but-separate gaps split out of that triage:getAgentInfo()was the only normal-path call without fallback — measurably more brittle than every other code path against the same server.Test plan
npm run test:lib— 5681/5688 pass, 7 skipped, 0 failednpm run typecheck— cleantest/lib/get-agent-info-fallback.test.js) pins both fixes:initializewith 400; without the fixgetAgentInfopropagates the error, with the fix it retries and succeeds (verified by stash/restore round-trip)./api/mcp//adcp/mcpexamples.