Create a feature flag in your IDE in 5 minutes with the LaunchDarkly MCP server

Published May 28, 2025

Portrait of Tilde Thurium.

by Tilde Thurium

This topic explains how to create, evaluate, and modify flags from within your IDE or AI client using natural language with the LaunchDarkly model-context protocol (MCP) server.

This tutorial uses the LaunchDarkly hosted MCP server, which connects your AI client to LaunchDarkly over HTTP and authenticates with OAuth. To learn more, read LaunchDarkly MCP server and LaunchDarkly hosted MCP server.

Prerequisites

To complete this tutorial, you must have the following prerequisites:

  • A LaunchDarkly account. Sign up for free.
  • Any AI client that supports MCP, such as Cursor. The examples in this tutorial use Cursor.

What is MCP?

Model-context protocol (MCP) is an open protocol that lets you interact with APIs using natural language.

The LaunchDarkly hosted MCP server covers multiple product areas, including feature management for managing feature flags, AgentControl for managing configs, and observability for querying logs, traces, and errors. To learn more about the available capabilities, read Available MCP tools.

Authenticating with the hosted MCP server

The hosted MCP server uses OAuth to authenticate with your LaunchDarkly account, so you don’t need to create or manage an API access token. When you connect your AI client, LaunchDarkly prompts you to authorize access in your browser, and your existing permissions apply automatically.

Using the federal or EU instance?

The hosted MCP server is not available in the LaunchDarkly federal or European Union (EU) instances. Instead, use the local MCP server, which authenticates with an API access token. To learn more, read LaunchDarkly in federal environments or LaunchDarkly in the European Union (EU).

Installing the MCP server

The quickest way to connect is the MCP server install page. Visit this page, select your AI client, and follow the prompts to authorize and connect. This tutorial uses Cursor, which you can also configure manually.

To add the hosted MCP server in Cursor:

  1. In Cursor, navigate to Settings > Cursor Settings > Tools & Integrations > MCP Tools.
  2. Click Add Custom MCP. An “Install MCP Server?” dialog appears.
  3. Enter the following values:
    • Name: LaunchDarkly
    • Type: streamableHttp
    • URL: https://mcp.launchdarkly.com/mcp/launchdarkly
  4. Click Install.
  5. Toggle on the LaunchDarkly server, then click Connect to authorize with your LaunchDarkly account.

Alternatively, you can edit .cursor/mcp.json in your project root directly:

Add the MCP server from the project root
1{
2 "mcpServers": {
3 "launchdarkly": {
4 "url": "https://mcp.launchdarkly.com/mcp/launchdarkly",
5 "headers": {}
6 }
7 }
8}

After you save the file, toggle on the LaunchDarkly server in Cursor and click Connect to authorize your account.

For manual configuration steps for Claude Code, Windsurf, and GitHub Copilot, or to migrate from an earlier npx-based local server, read LaunchDarkly hosted MCP server.

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

Model responses are non-deterministic, so your response may not exactly match the following, but it should be something like this:

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!

Oops, we forgot to specify which LaunchDarkly project we wanted to use. Luckily the agent retains context between queries, and knows how to ask us for the info it needs. The MCP protocol is forgiving and you don’t have to get prompts perfect on the first try.

My example LaunchDarkly project is named raccoon-api-facts. 🦝 Don’t judge me. Input your own project name in the AI chat pane and hit Enter. Although these flag and project names are technically called keys when referenced in code, the LaunchDarkly MCP server can understand what we are asking for without that level of specificity. Hooray for natural language interfaces.

Click Run tool in your AI pane in Cursor to finish creating the flag. You’ll need to do this every time the AI agent attempts to interact with the LaunchDarkly API. MCP servers require explicit approval before calling external APIs as a security measure.

Screenshot of the Run tool button in the AI chat pane of the Cursor IDE.

The Run tool button.

Next, roll over to the LaunchDarkly UI. You should see the awesome-new-feature flag in your list. If it’s not there, double-check that you’re in the correct project.

Screenshot of a list of feature flags in the LaunchDarkly user interface. The top flag is called Awesome New Feature.

The flags list.

Back in Cursor, if you click on called MCP tool you can see the details of the request the MCP server sent to the LaunchDarkly API:

Screenshot of request parameters used to call the LaunchDarkly flag creation API within the Cursor IDE, via MCP.

Request parameters for the create flag API call.

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?

Your response should be something like this:

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!

This matches what we see in the LaunchDarkly UI:

Screenshot of flag configuration in the LaunchDarkly UI. The flag is Off, serving false to all users in the Test environment.

Flag configuration for Awesome New Feature .

Let’s try to turn the flag on and see what happens!

Prompt:

Turn the awesome new feature flag ON, serving True to all users.

Don’t forget to click Run tool after submitting your prompt to the agent.

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!

You may need to reload the LaunchDarkly UI in your browser to see the updated flag state:

Screenshot of flag configuration in the LaunchDarkly UI. The flag is On, serving true to all users in the Test environment.

Updated configuration for the Awesome New Feature flag in the Test environment.

Screenshot of flag configuration in the LaunchDarkly UI. The flag is On, serving true to all users in the Production environment.

Updated configuration for the Awesome New Feature flag in the Production environment.

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 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!

Checking the AI agent’s work in the LaunchDarkly UI, it looks like the targeting updates were successful:

Screenshot of flag configuration in the LaunchDarkly UI. The flag is On, serving true to users whose email addresses end in launchdarkly.com and false to everyone else.

Updated configuration for the Awesome New Feature flag, including a targeting rule.

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: {“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.com matches this rule.

Result: The awesome-new-feature flag will be enabled (true) for this user.
If you want to see the raw evaluation or check for a different context, let me know!

Great. What about evaluating a context that should be false?

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.com does not match this rule.

Result: The awesome-new-feature flag will be disabled (false) for this user. If you want to check for another context or need the raw evaluation details, let me know!

You can even pass in the context in natural language rather than JSON.

Prompt:

Evaluate the value of Awesome New Feature flag with a context where the user has an email address foo@bar.com

Response:

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.

The LaunchDarkly API doesn’t have an endpoint for evaluating feature flags. For that, you can use one of the SDKs. When you evaluate a feature flag through the MCP server, the AI model is running the evaluation logic.

Conclusion

In this tutorial you learned how to create and manage feature flags from within your IDE, using the LaunchDarkly hosted MCP server. This can save you time and the mental energy of context switching, which will ultimately help you ship more quickly.

For more complex, multi-step workflows, you can pair the MCP server with LaunchDarkly agent skills, which guide your agent through the right sequence of tool calls.

If you enjoyed this tutorial, here’s some related reading: