Skip to content

fix(client): hint at wrong-path agent_uri in discovery failure error (#1234) - #1247

Merged
bokelley merged 2 commits into
mainfrom
bokelley/discover-path-hint
May 2, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/discover-path-hint

Conversation

@bokelley

@bokelley bokelley commented May 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #1234. Appends a hint to the discoverMCPEndpoint "Failed to discover MCP endpoint" error pointing operators at the most common cause: agent_uri registered at the host root when the actual MCP endpoint lives at a non-standard path. Five lines, no behavior change.

Discovered while investigating #1231 (closed as not-a-bug — root cause was registration mismatch). The original symptom: a dashboard probe showed "agent offline" when the agent was healthy and just registered with the wrong path. Better discovery diagnostics shorten the time-to-fix for the most common operator mistake.

This replaces the closed PR #1244, which bundled a more invasive symmetry-fix that wasn't justified by a reproducible failure. The retry-predicate concern surfaced during that review is filed separately as #1246.

Test plan

  • npm run typecheck — clean
  • New regression test test/lib/discover-mcp-endpoint-hint.test.js asserts both the existing failure-list output and the new hint text + example paths

bokelley and others added 2 commits May 1, 2026 18:47
`SingleAgentClient.discoverMCPEndpoint` only auto-probes `/`, `/mcp`, and
`/mcp/`. When the registered `agent_uri` is the host root but the actual
MCP endpoint lives at a non-standard path (e.g. `/api/mcp`, `/v1/mcp`),
operators see a generic "Failed to discover MCP endpoint" error and
typically reach for transport-level debugging when the actual cause is
the registration.

Append a hint to that error pointing at the most common fix: register
the exact MCP path as `agent_uri`. No behavior change.

Closes #1234.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
The previous "only probes /, /mcp, and /mcp/" was inaccurate — the SDK
auto-appends those suffixes to whatever path is provided, not just the
host root. Also surface SSE/legacy paths since FastMCP and reference
servers commonly expose MCP at /sse.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit a9ddd45 into main May 2, 2026
8 of 9 checks passed
@bokelley
bokelley deleted the bokelley/discover-path-hint branch May 2, 2026 00:21
bokelley added a commit that referenced this pull request May 2, 2026
Drive-by unblock: this file landed in main via #1247 with a single
prettier nit (one-line array got line-broken). The repo-wide
`prettier --check` step then fails on every PR. Format-only change.
bokelley added a commit that referenced this pull request May 2, 2026
…1241)

* fix(harness): close stdin on grader spawnSync to prevent 120s hang

Closes #1237.

`runGrader` invokes the storyboard CLI with `--webhook-receiver` via
spawnSync. Empirically the parent saw `status=null signal=SIGTERM
stdout=0b stderr=0b` at 120s, while the same args run directly from a
shell completed in ~1.3s.

Root cause is stdio inheritance, not sync-vs-async spawn. spawnSync
without an explicit `stdio` option defaults stdin to `'pipe'` — the
child receives an open, never-written stdin pipe. Some libraries the
CLI loads probe stdin/TTY state on startup and stall when stdin is a
disconnected pipe. Direct shell invocation works because the child
inherits the parent's TTY.

Fix is one option: `stdio: ['ignore', 'pipe', 'pipe']`. Closes stdin up
front so any TTY/stdin probing fast-fails, while keeping stdout/stderr
captured for JSON parsing.

Also adds a diagnostic log that fires on `signal === 'SIGTERM'` with
empty stdout — copy-pasteable repro command so operators don't mistake
a harness-level kill for an agent conformance failure. And a one-line
note in `docs/guides/VALIDATE-YOUR-AGENT.md` so contributors who hit
the timeout from the validate guide know what they're seeing.

No changeset: `scripts/manual-testing/` is excluded from the published
`files` array.

* chore: empty changeset for harness-only #1237 fix

`scripts/manual-testing/` is not in `package.json#files`; no published
package change. Empty changeset satisfies the changeset-check CI step.

* fix(harness): use ETIMEDOUT and bump maxBuffer per pre-merge review

Two correctness fixes from code-reviewer + nodejs-testing-expert:

- Replace `res.signal === 'SIGTERM' && !res.stdout` with
  `res.error?.code === 'ETIMEDOUT'`. The signal-only predicate also
  matches Ctrl-C, OOM kill, external kill, and maxBuffer overflow —
  none of which deserve the "timed out after 120s" message. Node sets
  ETIMEDOUT specifically when `options.timeout` fires, on both POSIX
  and Windows.
- Bump `maxBuffer` from the 1 MiB default to 16 MiB. A passing webhook-
  bundle JSON report approaches the default on its own; on overflow
  spawnSync kills with SIGTERM and returns *truncated* stdout, which
  silently mis-grades as fail when JSON.parse trips on the truncation.

* chore: prettier-write test/lib/discover-mcp-endpoint-hint.test.js

Drive-by unblock: this file landed in main via #1247 with a single
prettier nit (one-line array got line-broken). The repo-wide
`prettier --check` step then fails on every PR. Format-only change.
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.

discoverMCPEndpoint error should hint at wrong-path registration

1 participant