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
| Property | Type | Description |
|---|---|---|
authUrl | Uri |
McpAuthFlowSuccess
Constructor
dart
const McpAuthFlowSuccess({
required this.resourceMetadataUrl,
required this.authorizationServer,
})Properties
| Property | Type | Description |
|---|---|---|
resourceMetadataUrl | Uri? | |
authorizationServer | Uri? |
McpAuthFlowError
Constructor
dart
const McpAuthFlowError(this.message)Properties
| Property | Type | Description |
|---|---|---|
message | String |
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<void> Function(String url)? openBrowser,
OAuthCodeFlow? codeFlow,
// ignore: prefer_initializing_formals
})Properties
| Property | Type | Description |
|---|---|---|
serverId | String | |
serverUrl | Uri | |
credentials | CredentialStore | |
wwwAuthenticate | String? | |
cachedResourceMetadataUrl | Uri? | |
cachedAuthorizationServer | Uri? | |
states | Stream<McpAuthFlowState> get | |
states | Stream<McpAuthFlowState> get |
Methods
void cancel()
Future<McpAuthFlowState> run()
Runs the flow end-to-end. Resolves with the terminal state.
`return runOAuthAuthorizationCodeFlow(
endpoints: endpoints,
client: client,
scopes: scopes,
onAuthUrl: onAuthUrl,
httpClient: httpClient,
preboundServer: preboundServer,
preboundRedirectUri: preboundRedirectUri,
)`