Skip to content

Config

Category: Mcp_client

Source: config.dart

Typed configuration types for MCP servers.

Pure data — no I/O, no parsing. The YAML→config parser lives in glue_harness/src/config/mcp_config.dart (which can depend on these types) so the layered architecture stays clean: strategies don't import from harness.

See docs/plans/2026-04-29-mcp-client.md for the wire-config shape.

Enums

McpSubprocessEnvMode

ValueDescription
allowlist
full

Classes

sealed McpServerSpec

Where the server lives and how to talk to it.

Constructor

dart
const McpServerSpec({
    required this.id,
    this.enabled = true,
    this.callTimeoutSeconds,
  })

Properties

PropertyTypeDescription
idStringUser-chosen local id (the YAML key). Used for namespacing tools (<id>.<tool>) and as the credential-store namespace.
enabledboolfalse parks the server without removing it from config.
callTimeoutSecondsint?Per-server override of [McpConfig.callTimeoutSeconds].

McpStdioServerSpec

Constructor

dart
const McpStdioServerSpec({
    required super.id,
    required this.command,
    this.args = const [],
    this.env = const {},
    this.workingDirectory,
    super.enabled,
    super.callTimeoutSeconds,
  })

Properties

PropertyTypeDescription
commandString
argsList<String>
envMap<String, String>Server-config env keys (after ${VAR} expansion) added to the scrubbed child environment.
workingDirectoryString?

McpHttpServerSpec

Constructor

dart
const McpHttpServerSpec({
    required super.id,
    required this.url,
    this.auth = const McpNoAuth(),
    this.resourceMetadataUrl,
    this.authorizationServer,
    super.enabled,
    super.callTimeoutSeconds,
  })

Properties

PropertyTypeDescription
urlUri
authMcpAuthSpec
resourceMetadataUrlUri?Cached RFC 9728 resource-metadata URL discovered on a prior session. Skips one HTTP round-trip at startup. Self-healing — stale value just falls back to fresh discovery.
authorizationServerUri?Cached authorization server URL discovered on a prior session.

McpWebSocketServerSpec

Constructor

dart
const McpWebSocketServerSpec({
    required super.id,
    required this.url,
    this.auth = const McpNoAuth(),
    this.resourceMetadataUrl,
    this.authorizationServer,
    super.enabled,
    super.callTimeoutSeconds,
  })

Properties

PropertyTypeDescription
urlUri
authMcpAuthSpec
resourceMetadataUrlUri?Cached RFC 9728 resource-metadata URL discovered on a prior session. Skips one HTTP round-trip at startup. Self-healing — stale value just falls back to fresh discovery.
authorizationServerUri?Cached authorization server URL discovered on a prior session.

sealed McpAuthSpec

Constructor

dart
const McpAuthSpec()

McpNoAuth

No auth header. Stdio servers default to this; HTTP servers can opt in.

Constructor

dart
const McpNoAuth()

McpBearerAuth

Bearer token. [token] is null when the value comes from the credential store at session start (mcp:<id>:bearer). When non-null it's the literal token (post env-var expansion).

Constructor

dart
const McpBearerAuth({this.token})

Properties

PropertyTypeDescription
tokenString?

McpOAuthAuth

OAuth 2.1 with PKCE + DCR. Credentials live in the credential store under mcp:<id>:oauth.* — config carries no secrets.

Constructor

dart
const McpOAuthAuth()

McpToolPolicy

Constructor

dart
const McpToolPolicy({this.autoApprove = const [], this.deny = const []})

Properties

PropertyTypeDescription
autoApproveList<String>Namespaced names or glob patterns (*.read_file).
denyList<String>Namespaced names or glob patterns (*.delete_file).

Methods

bool isAutoApproved(String namespacedName)

Returns true if [namespacedName] matches any [autoApprove] pattern.

bool isDenied(String namespacedName)

Returns true if [namespacedName] matches any [deny] pattern.

McpReconnectPolicy

Constructor

dart
const McpReconnectPolicy({
    this.enabled = true,
    this.initialDelayMs = 500,
    this.maxDelayMs = 30000,
    this.maxAttempts = 10,
  })

Properties

PropertyTypeDescription
enabledbool
initialDelayMsint
maxDelayMsint
maxAttemptsint

McpConfig

Constructor

dart
const McpConfig({
    this.servers = const [],
    this.toolPolicy = const McpToolPolicy(),
    this.reconnect = const McpReconnectPolicy(),
    this.callTimeoutSeconds = 30,
    this.subprocessEnv = McpSubprocessEnvMode.allowlist,
  })

Properties

PropertyTypeDescription
serversList<McpServerSpec>All configured servers, in YAML order.
toolPolicyMcpToolPolicy
reconnectMcpReconnectPolicy
callTimeoutSecondsintDefault per-call timeout. May be overridden per server.
subprocessEnvMcpSubprocessEnvModeallowlist (default) scrubs the parent env for stdio subprocesses; full inherits everything (matches Claude Desktop's behaviour).
hasAnyServerbool get
buffinal
hasAnyServerbool get

Methods

return RegExp(buf.toString())

Released under the MIT License.