Skip to content

Add an error event to InspectorClientEventMap so mid-session transport failures surface #1323

@cliffhall

Description

@cliffhall

Background

useInspectorClient exposes status driven by the OAuth/XState machine inside InspectorClient. The status can transition connected → error when a transport dies mid-session (stdio subprocess crash, SSE stream drop, HTTP 5xx). Callers see the status flip but don't get the reason.

#1244 wired App.tsx to useInspectorClient and captures errorMessage only from client.connect() Promise rejection (handshake-only). A state-machine transition to "error" after a successful connect bypasses that path and leaves the UI's errorMessage stale (or unset).

Scope

  • Add error: { detail: string; cause?: unknown } (or similar shape) to InspectorClientEventMap in core/mcp/inspectorClientEventTarget.ts.
  • Dispatch from every code path inside core/mcp/inspectorClient.ts that sets status to "error" outside of an awaited promise.
  • Expose lastError?: string on useInspectorClient's return type so consumers can render it without subscribing to the event directly.
  • Update App.tsx to consume the new field instead of the connect() catch (or in addition to, for the handshake case).

Out of scope

  • Reconnection UX. This is just about surfacing the reason.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    v2Issues and PRs for v2

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions