Documentation Index
Fetch the complete documentation index at: https://launchdarkly-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Overview
You can now create, evaluate, and modify flags from within your IDE or AI client using natural language with LaunchDarkly’s new MCP server. Follow along with this tutorial for step by step instructions. This MCP server is currently in beta. For the most up to date instructions, read LaunchDarkly MCP server in the product documentation.Prerequisites
In order to complete this tutorial, you must have the following prerequisites:- A LaunchDarkly account — sign up for a free one here.
- The Cursor IDE installed on your local machine. Although this tutorial is Cursor-focused, our MCP server also works with any AI client that supports MCP, such as Windsurf or even Raycast.
- A JavaScript runtime on your local machine that supports ECMAScript 2020 or newer. Functionally, this means Node.js v18 or v20, Bun v1 or newer, or Deno 1.39 and above.
What is MCP?
*Model-context protocol (MCP)- is an open protocol that lets you interact with APIs using natural language.
Creating a Launch
Darkly API access token To use the LaunchDarkly MCP server, you’ll need to create a LaunchDarkly API access token with appropriately scoped permissions. Go to the the LaunchDarkly Authorization page. (If you’re an EU or Federal user, that link won’t work – instead, navigate to Organization settings > Authorization in the left nav menu.) Click Create token. Give the token a memorable name, such as “Tilde’s MCP server.” The Role should be Writer. Leave the service token box unchecked. The MCP server will be running on your local machine, so a personal API token is a better fit. Also, leave the API version set to the most recent version (currently20240415).

Installing the MCP server
In Cursor, go to Settings > Cursor Settings > Tools & Integrations > MCP Tools > New MCP server. Copy the example configuration, using your API token instead of the dummy key in this example.server-url argument like so. Replace <host> with your host URL.
Creating a feature flag with MCP
Toggle Cursor’s AI pane. Try asking the agent to create a flag using the following prompt:Prompt:
create a feature flag to gate my awesome new feature
Response:
To create a feature flag for your awesome new feature, I’ll need to know which LaunchDarkly project you want to add the flag to. Could you please provide the project key (the unique identifier for your LaunchDarkly project)? If you have a preferred flag key or description, let me know as well, or I can generate them for you!



Enabling a feature flag
Ask the AI agent to check the value of the flag:Prompt:
what is the value of the awesome-new-feature flag?
Response:
The value of the awesome-new-feature flag is currently set to off (false) by default in both the production and test environments. If you want to enable it or check its value for a specific user or context, let me know!

Prompt:
Turn the awesome new feature flag ON, serving True to all users.
Response:
The awesome-new-feature flag is now turned ON in both the production and test environments! Your awesome new feature is now enabled for all users in these environments.
If you want to target specific users, add rules, or need to verify the flag’s status, just let me know!
If you want to target specific users, add rules, or need to verify the flag’s status, just let me know!


Adding a flag targeting rule
What if we ask the AI agent to do something a little more complicated? Let’s create a targeting rule so that the flag is serving true for users whose email addresses end in launchdarkly.com. This could be useful if we wanted to roll out our awesome new feature to internal users first, to test for bugs.Prompt:
For the awesome new feature flag, update the targeting rules so the flag is only enabled and serving true for users who have email addresses ending with
launchdarkly.com. Everyone else should get the false variation.Response:
The awesome-new-feature flag is now enabled only for users whose email addresses end with
If you need to further adjust the targeting or want to verify the setup, let me know!
launchdarkly.com in both production and test environments. For all other users, the flag will be off.If you need to further adjust the targeting or want to verify the setup, let me know!

Evaluating a feature flag
Now that our targeting rule is set up, let’s try evaluating our awesome feature flag using a few different contexts.Prompt:
Evaluate the awesome new feature flag using the following context:
{"name": "tilde", "email": "tthurium@launchdarkly.com"}Response:
To evaluate the awesome-new-feature flag for the context:
If you want to see the raw evaluation or check for a different context, let me know!
{"name": "tilde", "email": "tthurium@launchdarkly.com"}- The flag is ON, but only enabled for users whose email ends with
@launchdarkly.com. - The provided email
tthurium@launchdarkly.commatches this rule.
If you want to see the raw evaluation or check for a different context, let me know!
Prompt:
Evaluate the awesome new feature flag using the following context:
{"name": "tilde", "email": "tthurium@foo.com"}Response:
For the context
{"name": "tilde", "email": "tthurium@foo.com"}:- The awesome-new-feature flag is ON, but only enabled for users whose email ends with “
@launchdarkly.com”. - The email
tthurium@foo.comdoes not match this rule.
Prompt:
Evaluate the value of Awesome New Feature flag with a context where the user has an email address
foo@bar.comResponse:
Given the current targeting rules for the “Awesome New Feature” flag:
- The only users who receive the true variation are those whose email ends with
launchdarkly.com. - All other users receive the false variation.
For a user with the email address
foo@bar.com, the flag will evaluate to false in both the Production and Test environments.
Additional feature flag MCP prompts
Most flag-related actions you can do with the LaunchDarkly REST API can now be done from the comfort of your editor. Here are some examples of additional prompts that you may find useful. Replace the placeholders with the names/keys of your actual flags and projects. | Task| Prompt |
|---|
tthurium@launchdarkly.com receives the true variation. |
| Copying a feature flag
| Create a new feature flag that copies the configuration of the $FEATURE_FLAG_KEY flag, but add V2 to the flag key. |
| Archiving a feature flag
| Archive the feature flag $FEATURE_FLAG_KEY. |
| Deleting a feature flag. (Be careful with this one — the action can’t be undone!)
| Delete the feature flag $FEATURE_FLAG_KEY. |
Conclusion
In this tutorial you learned how to create and manage feature flags from within your IDE, using the magic of MCP. This can save you time, as well as the mental energy of context switching, which will ultimately help you ship more quickly. Stay tuned for updates. We’re actively working on adding more functionality to our MCP server. If you enjoyed this tutorial, here’s some related reading:- A list of awesome MCP servers
- Getting started with the LaunchDarkly REST API
- Customizing user experiences using FastAPI and LaunchDarkly segment targeting