Skip to content

AuthFlow ​

Category: Mcp_client

Source: auth_flow.dart

McpAuthFlowRunner — runs an MCP OAuth flow from discovery through token persistence, emitting state changes for UI consumers.

Used by: • glue mcp auth login <id> (CLI surface — plain stdout) • /mcp auth login <id> (slash command — status panel) • Auto-triggered flow from McpPoolServerAuthRequiredEvent

The runner is platform-neutral. UI surfaces subscribe to [states] and react to each [McpAuthFlowState] variant — including printing the URL, opening a browser, and dismissing on success.

Classes ​

sealed McpAuthFlowState ​

Constructor ​

dart
const McpAuthFlowState()

McpAuthFlowDiscovering ​

Constructor ​

dart
const McpAuthFlowDiscovering()

McpAuthFlowRegistering ​

Constructor ​

dart
const McpAuthFlowRegistering()

McpAuthFlowAwaitingCallback ​

Constructor ​

dart
const McpAuthFlowAwaitingCallback({required this.authUrl})

Properties ​

PropertyTypeDescription
authUrlUri

McpAuthFlowSuccess ​

Constructor ​

dart
const McpAuthFlowSuccess({
    required this.resourceMetadataUrl,
    required this.authorizationServer,
  })

Properties ​

PropertyTypeDescription
resourceMetadataUrlUri?
authorizationServerUri?

McpAuthFlowError ​

Constructor ​

dart
const McpAuthFlowError(this.message)

Properties ​

PropertyTypeDescription
messageString

McpAuthFlowCancelled ​

Constructor ​

dart
const McpAuthFlowCancelled()

McpAuthFlowRunner ​

Constructor ​

dart
McpAuthFlowRunner({
    required this.serverId,
    required this.serverUrl,
    required this.credentials,
    this.wwwAuthenticate,
    this.cachedResourceMetadataUrl,
    this.cachedAuthorizationServer,
    http.Client? httpClient,
    Future<bool> Function(String url)? openBrowser,
    OAuthCodeFlow? codeFlow,
    // ignore: prefer_initializing_formals
  })

Properties ​

PropertyTypeDescription
serverIdString
serverUrlUri
credentialsCredentialStore
wwwAuthenticateString?
cachedResourceMetadataUrlUri?
cachedAuthorizationServerUri?
statesStream&lt;McpAuthFlowState&gt; get
statesStream&lt;McpAuthFlowState&gt; get

Methods ​

void cancel() ​
Future&lt;McpAuthFlowState&gt; run() ​

Runs the flow end-to-end. Resolves with the terminal state.

Released under the MIT License.