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:- In Cursor, navigate to Settings > Cursor Settings > Tools & Integrations > MCP Tools.
- Click Add Custom MCP. An “Install MCP Server?” dialog appears.
- Enter the following values:
- Name:
LaunchDarkly - Type:
streamableHttp - URL:
https://mcp.launchdarkly.com/mcp/launchdarkly
- Name:
- Click Install.
- Toggle on the LaunchDarkly server, then click Connect to authorize with your LaunchDarkly account.
.cursor/mcp.json in your project root directly:
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
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!

The Run tool button.

The flags list.

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

Flag configuration for Awesome New Feature .
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!

Updated configuration for the Awesome New Feature flag in the Test 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
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!

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”: “
If you want to see the raw evaluation or check for a different context, let me know!
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.