> AI agents: this is one page from PostHog's docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt # Manage feature flags over PostHog MCP The [PostHog MCP server](/docs/model-context-protocol.md) lets your AI coding agent create, manage, and schedule [feature flags](/docs/feature-flags.md) directly from your code editor. Create flags, configure targeting rules, check rollout status, and schedule future changes – without switching to the PostHog app. This works in any MCP client – Cursor, Codex, Claude Code, Windsurf, VS Code, and others. ## Before you start 1. **Set up Feature Flags** – [install a PostHog SDK](/docs/feature-flags/installation.md) so your app can evaluate flags. 2. **Connect the MCP server** – [install it in your AI tool](#install-the-mcp-server) and give it access to your project. ## How it works With MCP, your coding agent can: - **Create flags while building features** – "Create a flag called `new-search` rolled out to 10% of users" as part of your development workflow - **Check flag status before deploying** – "Which feature flags are active in production?" to verify your deploy won't conflict - **Clean up stale flags** – "Find flags not evaluated in 90 days" and remove the dead code. See [cleaning up stale flags](/docs/feature-flags/cleaning-up-stale-flags.md) for the full workflow. - **Update rollout rules** – "Roll out `dark-mode` to 50%" or "add the beta-testers cohort to the `new-dashboard` flag" - **Schedule future flag changes** – "Schedule the `new-checkout` flag to enable at midnight" or "Set up a recurring weekly disable for maintenance windows" - **Bulk operations** – "Delete all flags tagged 'deprecated'" or "Add the 'production' tag to these flags" to manage flags in bulk - **Test flag evaluation** – "Test how `new-checkout-flow` evaluates for user abc123" to debug targeting rules without deploying ## Feature flag tools The MCP server provides these tools for working with feature flags: | Tool | Description | | --- | --- | | `create-feature-flag` | Create a new feature flag with rollout percentage, targeting rules, and optional variants. | | `feature-flag-get-definition` | Get the full definition of a flag, including filters, groups, and payloads. | | `feature-flag-get-all` | List feature flags in the current project. Supports search by flag key or name. | | `update-feature-flag` | Update a flag's rollout percentage, targeting rules, or variants. | | `delete-feature-flag` | Soft-delete a feature flag. | The `create-feature-flag` and `update-feature-flag` tools accept these optional parameters: | Parameter | Description | | --- | --- | | `evaluation_runtime` | Where the flag evaluates: `server` (server-side SDKs only), `client` (client-side SDKs only), or `all` (both). Defaults to `all`. See [evaluation runtime](/docs/feature-flags/creating-feature-flags.md#evaluation-runtime-optional). | | `bucketing_identifier` | Identifier used to bucket users: `distinct_id` (default) or `device_id`. Using `device_id` is incompatible with `ensure_experience_continuity` set to `true`. See [device bucketing](/docs/feature-flags/device-bucketing.md). | | `ensure_experience_continuity` | Whether to persist a user's flag value across the anonymous-to-identified transition. Incompatible with `device_id` bucketing. See [persisting flags across authentication](/docs/feature-flags/creating-feature-flags.md#persisting-feature-flags-across-authentication-steps-optional). | ## Debugging and impact tools These read-only tools help your agent understand a flag before and after it changes it: | Tool | Description | | --- | --- | | `feature-flags-status-retrieve` | Check whether a flag is active, stale, or deleted, plus its rollout state. | | `feature-flags-evaluation-reasons-retrieve` | See how flags evaluate for a `distinct_id` and why – condition match, no match, or disabled. | | `feature-flags-test-evaluation-create` | Test how one flag evaluates for a specific user, with the condition analysis behind the result. | | `feature-flags-user-blast-radius-create` | Estimate how many users a release condition would affect before you apply it. | | `feature-flags-dependent-flags-retrieve` | List other active flags that depend on this one, so you don't break a [dependency](/docs/feature-flags/dependencies.md) chain. | | `feature-flags-my-flags-retrieve` | List every flag with its evaluated value for the authenticated user. | | `feature-flags-activity-retrieve` | Read the audit trail for a flag: who changed what, and when. | | `feature-flags-copy-flags-create` | Copy a flag into other projects in the same organization. | ## Bulk operation tools These tools operate on multiple feature flags at once: | Tool | Description | | --- | --- | | `feature-flags-bulk-delete-create` | Soft-delete multiple flags in one call. Filter by tags, search, or pass explicit IDs. | | `feature-flags-bulk-keys-retrieve` | Resolve flag IDs to their string keys, for when another tool handed you IDs. | | `feature-flags-bulk-update-tags-create` | Add, remove, or replace tags on multiple flags at once (up to 500). | ## Scheduled change tools Schedule future flag changes programmatically using these tools: | Tool | Description | | --- | --- | | `scheduled-changes-list` | List scheduled changes in the current project. Filter by flag ID to see pending, executed, and failed schedules. | | `scheduled-changes-get` | Get the full details of a specific scheduled change by ID, including payload, timing, and execution status. | | `scheduled-changes-create` | Schedule a future change to a feature flag – enable/disable, add release conditions, or update variants. Supports recurring schedules (daily, weekly, monthly, yearly). | | `scheduled-changes-update` | Update a pending scheduled change's timing, payload, or recurrence settings. | | `scheduled-changes-delete` | Delete a scheduled change by ID. The change is permanently removed and won't execute. | ## Example prompts Try these with your MCP-enabled agent: - `Create a feature flag called new-checkout-flow rolled out to 20% of users on the pro plan.` - `Show me all active feature flags.` - `Which flags haven't been modified in the last 90 days?` - `Update the dark-mode flag to roll out to 100% of users.` - `Create a multivariate flag called button-color with three variants: red, blue, and green.` - `Delete the old-pricing-test flag.` - `Create a server-side-only flag called internal-api-v2 with evaluation_runtime set to server.` - `Create a flag called device-experiment using device_id bucketing for consistent mobile app experience.` ### Bulk operation prompts - `Delete all feature flags tagged 'deprecated' in this project.` - `Add the 'production' tag to flags 123, 456, and 789.` - `What are the keys for flag IDs 101, 102, and 103?` ### Testing prompts - `Test how the new-checkout-flow flag evaluates for user with distinct ID abc123.` - `Why doesn't the dark-mode flag match for user john@example.com?` - `Show me the evaluation details for the beta-features flag for person ID xyz789.` ### Scheduling prompts - `Schedule the new-checkout-flow flag to enable at midnight tomorrow.` - `List all pending scheduled changes for my feature flags.` - `Create a recurring schedule to disable the maintenance-mode flag every Sunday at 2am.` - `Cancel the scheduled rollout for the dark-mode flag.` - `Update the scheduled change for beta-features to trigger at 9am instead of noon.` ## Install the MCP server The recommended way to install is with the [AI wizard](/docs/ai-engineering/ai-wizard.md): Terminal ```bash npx @posthog/wizard mcp add ``` The wizard supports Claude, Cursor, Windsurf, VS Code, and more. You can also [configure it manually](/docs/model-context-protocol.md#get-started-in-30-seconds). See the [MCP server docs](/docs/model-context-protocol.md) for full setup instructions. ## Related - Create and roll out flags in the [web app](/docs/feature-flags/surfaces/web-app.md). - Evaluate flags at runtime with the [API](/docs/feature-flags/surfaces/api.md). - Work through a retirement with [cleaning up stale flags](/docs/feature-flags/cleaning-up-stale-flags.md). ### Still have questions? Ask PostHog AI ### Was this page useful? HelpfulCould be better