Skip to content

ConnectionState

Category: Mcp_client

Source: connection_state.dart

Connection state machine for an [McpClient] against a single MCP server, plus the backoff-with-jitter helper.

Pure data + a pure function. The state-transition logic itself lives in client.dart and pool.dart.

[McpDisconnectReason] re-exports from glue_core so the wire enum stays single-sourced — the same value flows through events and the state machine.

Classes

sealed McpConnectionState

Constructor

dart
const McpConnectionState()

McpDisconnected

Constructor

dart
const McpDisconnected()

McpConnecting

Constructor

dart
const McpConnecting({this.attempt = 1})

Properties

PropertyTypeDescription
attemptint

McpConnected

Constructor

dart
const McpConnected({
    required this.connectedAt,
    required this.serverName,
    required this.serverVersion,
    required this.protocolVersion,
  })

Properties

PropertyTypeDescription
connectedAtDateTime
serverNameString
serverVersionString
protocolVersionString

McpReconnecting

Constructor

dart
const McpReconnecting({
    required this.attempt,
    required this.nextAttemptIn,
    this.lastError,
  })

Properties

PropertyTypeDescription
attemptint
nextAttemptInDuration
lastErrorString?

McpDead

Constructor

dart
const McpDead({required this.reason})

Properties

PropertyTypeDescription
reasonString

McpAwaitingAuth

Server is parked because OAuth is required. Distinct from [McpDead]: no reconnect timer armed, no budget consumed. Cleared by a successful auth flow (via pool.reconnect).

Constructor

dart
const McpAwaitingAuth({this.lastError})

Properties

PropertyTypeDescription
lastErrorString?

Released under the MIT License.