> ## Documentation Index
> Fetch the complete documentation index at: https://confidence.spotify.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Flags MCP Server

> Reference for the Confidence Flags MCP server: endpoint, authentication, and the 56 tools for clients, flags, rules, metrics, warehouses, events, and session recordings.

The Flags MCP server lets an AI assistant manage clients, flags, rules, evaluation context, metrics, warehouses, events, and session recording policies in your Confidence account. To connect it, see [MCP Servers](/docs/reference/agent/mcp-servers#integration-setup). For worked examples, see the [MCP Cookbook](/docs/reference/agent/mcp-cookbook).

<Warning>
  The Confidence MCP servers are experimental. Tools and their parameters can change.
</Warning>

## Endpoint and Authentication

Endpoint: `https://mcp.confidence.dev/mcp/flags`. Transport: streamable HTTP. Authentication: sign in to Confidence from your AI assistant. The server registers 56 tools. Where a tool returns one page of results, pass the returned `nextPageToken` as `pageToken` to get the next page.

## Clients

| Tool | Description | Key parameters |
| - | - | - |
| `listClients` | Lists Confidence clients with their display name and resource name (`clients/<id>`). | `pageToken` |
| `createClient` | Creates a client for resolving flags. The client type is `Frontend` or `Backend`. Returns the display name, resource name, and client secret. | `displayName`, `clientType` |
| `getClientSecret` | Returns the client secret that applications use to authenticate when they resolve flags. | `clientName`, `credentialId` |

## Flags

| Tool | Description | Key parameters |
| - | - | - |
| `listFlags` | Lists flags. In list mode, narrow results with `state`, `owner`, and `filter`. In search mode, pass `query` for full-text search ordered by relevance. Search mode ignores the other filters. | `query`, `state`, `owner`, `filter`, `pageToken` |
| `getFlag` | Returns a flag. Set `summary=false` for detailed rule information, including rollout percentages and timestamps. | `flagName`, `summary` |
| `createFlag` | Creates a flag with a name, description, schema, and variants. | `flagName`, `description`, `clientName`, `schemaObject`, `variants` |
| `batchCreateFlags` | Creates many flags in one call, using the same definition format as `createFlag`. Skips flags that already exist and returns created, existing, and failed counts. | `clientName`, `flags`, `labels` |
| `addFlagVariant` | Adds a variant to an existing flag. | `flagName`, `variantName`, `value` |
| `updateFlagSchema` | Updates a flag's schema. You can add properties when variants exist. The backend rejects incompatible changes, such as removing a property that variants use. | `flagName`, `schemaObject` |
| `addFlagToClient` | Enables a flag for a client. | `flagName`, `clientName` |
| `removeFlagFromClient` | Disables a flag for a client. | `flagName`, `clientName` |
| `archiveFlag` | Archives a flag. An archived flag can't resolve and isn't included in batch resolves. | `flagName` |
| `unarchiveFlag` | Restores an archived flag so it resolves again. | `flagName` |
| `updateFlagOwner` | Changes the owner of a flag. The owner must be an exact identity name from `getIdentityInfo` or `searchIdentities`. | `flagName`, `owner` |
| `batchUpdateFlagOwner` | Changes the owner of many flags. Select flags with a comma-separated `flagNames` list, or with `currentOwner` to move every flag that identity owns. | `owner`, `flagNames`, `currentOwner`, `state` |
| `getFlagHistory` | Returns the audit log of changes to a flag within a required date range: what changed, when, and by whom. | `flagName`, `fromDate`, `toDate`, `pageToken` |
| `analyzeFlagUsage` | Finds flags on a client that nothing uses or that are at full rollout, to help you clean up flag code. | `clientName` |

## Rules

| Tool | Description | Key parameters |
| - | - | - |
| `addOverrideRule` | Adds an override rule that forces a variant for one entity, such as a user, visitor, or organization. | `flagName`, `entity`, `entityValue`, `variantName` |
| `updateOverrideRule` | Changes the enabled state or assigned variant of an override rule. | `ruleName`, `enabled`, `variantName` |
| `addTargetingRule` | Adds a conditional targeting rule that splits traffic across variants. Variant percentages must sum to 100. For version attributes, use `versionValue` in the payload instead of `stringValue`. | `flagName`, `variantAllocations`, `payload`, `targetingKey`, `rolloutPercentage` |
| `batchAddTargetingRules` | Adds targeting rules to many flags in one call, using the same format as `addTargetingRule`. Returns succeeded and failed counts. | `rules`, `completionLabels` |
| `updateTargetingRule` | Changes the enabled state, variant split, targeting conditions, or targeting key of a targeting rule. | `ruleName`, `enabled`, `variantAllocations`, `targetingPayload`, `targetingKey` |
| `deleteRule` | Deletes a targeting or override rule. Entities that matched it fall through to the next rule. You can't undo this. | `ruleName` |

Use `getFlag` with `summary=false` to find rule names.

## Resolve

| Tool | Description | Key parameters |
| - | - | - |
| `resolveFlag` | Resolves a flag for a client and entity and explains each evaluation step. Pass `context` to add attributes, such as country or plan, that targeting rules depend on. | `flagName`, `clientName`, `entity`, `entityValue`, `context` |

## Evaluation Context

| Tool | Description | Key parameters |
| - | - | - |
| `getContextSchema` | Returns a client's evaluation context schema: every field you can target on, with its type. | `clientName` |
| `addContextField` | Adds an entity field (used for bucketing) or attribute field (used for targeting conditions) to the evaluation context schema. | `fieldName`, `fieldType`, `displayName`, `isEntity`, `entityReference`, `clientNames` |

## Identities and Users

| Tool | Description | Key parameters |
| - | - | - |
| `getIdentityInfo` | Without arguments, returns the identity of the authenticated user. With `identityName`, returns details for that exact identity. | `identityName` |
| `searchIdentities` | Searches users and groups by name and returns identities you can use as flag owners. Set `kind` to `USER` or `GROUP`, or omit it to search both. | `query`, `kind`, `pageToken` |
| `inviteUser` | Invites a user to the Confidence account by email. | `email`, `disableInvitationEmail` |

Identity names are opaque. Copy them from `getIdentityInfo` or `searchIdentities`. Never build them from a display name or ID.

## Metrics

| Tool | Description | Key parameters |
| - | - | - |
| `listMetrics` | Lists metrics with their names, display names, entities, fact tables, and type specifications. | `pageToken` |
| `getMetric` | Returns a metric. | `metricName` |
| `createMetric` | Creates a metric that aggregates measurements from a fact table for an entity. | `displayName`, `entity`, `factTable`, `typeSpec`, `description`, `metricId`, `preferredDirection` |
| `createMetricCalculation` | Starts an asynchronous calculation of a metric over a historical time window in the warehouse. | `metric`, `exposureTable`, `startTime`, `endTime`, `metricCalculationId`, `labels` |
| `getMetricCalculation` | Returns the state of a metric calculation: `STATE_RUNNING`, `STATE_COMPLETED`, or `STATE_FAILED`. | `name` |
| `queryMetricCalculation` | Returns per-dimension rows with count, mean, variance, and sum for a completed calculation. For a time series, set `groupByDimensions` and `accumulateDimension` to `cohort_date`. | `name`, `groupByDimensions`, `accumulateDimension`, `timeZone` |
| `listEntities` | Lists entities: classes of instances you can identify and measure, such as users or transactions. | `pageToken` |
| `listFactTables` | Lists fact tables with their entity columns, timestamp columns, measures, and dimensions. | `pageToken` |
| `listExposureTables` | Lists exposure tables. Pass an exposure table name as `exposureTable` to `createMetricCalculation`. | `pageToken` |

## Warehouses

| Tool | Description | Key parameters |
| - | - | - |
| `checkWarehouseExists` | Checks whether the account has a data warehouse. Metric calculations require one. | None |
| `validateWarehouseConfig` | Checks that access to datasets, schemas, and roles is set up before you create a warehouse. | `warehouseType`, `configJson` |
| `createWarehouse` | Connects a BigQuery, Snowflake, Databricks, or Redshift warehouse. | `warehouseType`, `configJson`, `warehouseId` |
| `createCryptoKey` | Creates a key for Snowflake key-pair authentication. You register the public key in Snowflake. | `cryptoKeyId`, `kind` |
| `createAssignmentTable` | Creates an assignment table that defines how to read flag and experiment assignments from the warehouse. | `displayName`, `sql`, `entityColumn`, `timestampColumn`, `exposureKeyColumn`, `variantKeyColumn`, `description`, `assignmentTableId` |
| `createFlagAppliedConnection` | Creates a connection that exports flag resolve events to the warehouse, so Confidence can write assignment data. | `warehouseType`, `configJson`, `connectionId` |
| `createEventConnection` | Creates a connection that exports custom events to the warehouse, so Confidence can write event data for metrics. | `warehouseType`, `configJson`, `connectionId` |

## Events

| Tool | Description | Key parameters |
| - | - | - |
| `createEventDefinition` | Registers a typed schema for custom events that the SDK `track()` method sends. Confidence creates a matching fact table when events start arriving. | `eventDefinitionId`, `schema`, `owner` |
| `getEventDefinition` | Returns an event definition with its schema, publish count, validation failures, and timestamps. | `name` |
| `listEventDefinitions` | Lists event definitions with their schema fields and publish counts. | `pageToken` |
| `updateEventDefinition` | Adds fields to an event definition schema. You can't change the type of an existing field. | `name`, `schema` |
| `deleteEventDefinition` | Deletes an event definition. Confidence rejects later events sent to it and doesn't remove the warehouse fact table. | `name` |
| `queryEventsUsage` | Returns hourly publish and validation failure counts for the last 1 to 7 days. Use it to verify that events arrive. | `eventDefinitionName`, `daysBack` |

## Session Recordings

| Tool | Description | Key parameters |
| - | - | - |
| `listRecordingPolicies` | Lists session recording policies with their resource names, display names, and clients. | `pageSize`, `pageToken` |
| `getRecordingPolicy` | Returns a policy and its rules in evaluation order. | `recordingPolicy` |
| `createRecordingPolicy` | Creates an empty recording policy for one client. Add rules separately. | `displayName`, `clientName`, `aiAnalysisEnabled` |
| `addRecordingRule` | Adds an ordered rule to a policy, with targeting, a stable audience percentage, environments, and a per-session sample rate. Rules are drafts by default. | `recordingPolicy`, `displayName`, `targetingKeySelector`, `targetingJson`, `stableAudiencePercentage`, `sessionSampleRate`, `environments`, `enabled` |
| `setRecordingRuleEnabled` | Enables or disables a recording rule. | `recordingRule`, `enabled` |
