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

# LaunchDarkly local MCP server

<View title="Developer">
  <Warning>
    **The local Model Context Protocol (MCP) server is for federal and European Union (EU) environments**

    LaunchDarkly provides the hosted MCP server for use in federal or EU environments, where the hosted MCP server is not available. We strongly recommend using the LaunchDarkly hosted MCP server where available. To learn more, read [LaunchDarkly hosted MCP server](/docs/home/getting-started/mcp-hosted).
  </Warning>
</View>

This topic explains how to get started with the LaunchDarkly local Model Context Protocol (MCP) server, for use with the LaunchDarkly federal and EU environments.

## Get started

To get started, you need an API access token with permission to execute any of the MCP tools available. Then, you need to add the MCP server definition to your AI client.

You also need a JavaScript runtime that supports ECMAScript 2020 or newer.

### Authentication

First, create an API access token:

1. Click the **gear** icon in the left sidebar to view Organization settings.

2. Click **Authorization**.

3. In the "Access tokens" section, click **Create token**.

4. Give your token a human-readable **Name**.

5. Assign a **Role** to the token by choosing one from the menu.

   * The LaunchDarkly MCP server provides tools for managing flags and AgentControl configs, so your token should have permission to create, read, update, and delete flags and AgentControl configs in the projects you want to work in. We recommend that you use a token with a Writer [base role](/docs/home/account/roles/role-concepts#base-roles), a LaunchDarkly Developer [preset role](/docs/home/account/roles/role-concepts#preset-roles), or another role that provides this access.

6. Click **Save token**. The new token appears in the **Authorization** page.

7. Copy and save the token somewhere secure. After you leave this page, the token is obscured.

To learn more, read [Creating API access tokens](/docs/home/account/api-create).

<Accordion title="Expand Example roles recommended for MCP server access tokens">
  #### Example roles recommended for MCP server access tokens

  Customers on select plans can [create their own roles](/docs/home/account/roles/role-create). If you have this ability, we recommend that you create the following role and assign it to the access token used for the LaunchDarkly MCP server:

  <CodeGroup>
    ```json title="Recommend role for MCP server access tokens" expandable lines wrap theme={null}
    [
      {
        "effect": "allow",
        "actions": ["*"],
        "resources": ["proj/${roleAttribute/projectKey}:env/*:flag/*"]
      },
      {
        "effect": "allow",
        "actions": ["*"],
        "resources": ["proj/${roleAttribute/projectKey}:env/*:aiconfig/*"]
      },
      {
        "effect": "allow",
        "actions": ["viewProject"],
        "resources": ["proj/${roleAttribute/projectKey}"]
      }
    ]
    ```
  </CodeGroup>
</Accordion>

### Installation methods

You can install the LaunchDarkly MCP server in any AI client that supports the MCP protocol. For most AI clients, this means creating or updating an MCP server JSON configuration file. LaunchDarkly customers on the EU or Federal instances of LaunchDarkly may want to use this method so they can include the correct server URLs.

Here's what the JSON file looks like:

<CodeGroup>
  ```json title="LaunchDarkly MCP server JSON configuration" lines wrap theme={null}
  {
    "mcpServers": {
      "LaunchDarkly": {
        "command": "npx",
        "args": [
          "-y", "--package", "@launchdarkly/mcp-server", "--", "mcp", "start",
          "--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        ]
      }
    }
  }
  ```
</CodeGroup>

Replace `api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` with your API access token.

<Warning>
  **Use caution with API keys in configuration files**

  Depending on how you use the LaunchDarkly MCP server, your AI client may end up listing the details of this configuration file in your conversation. This can be a security risk because the configuration file includes your API key. We strongly recommend using environment variables instead if your AI client supports their use with MCP servers.

  For example, GitHub Copilot can use variables prefixed with `COPILOT_MCP_` in the JSON file to import secrets from your environment.
</Warning>

<View title="Federal docs">
  <Warning>
    **Include a server URL to use the LaunchDarkly MCP server in federal environments**

    If you are working in a LaunchDarkly federal environment, you must additionally include `"--server-url", "https://app.launchdarkly.us"` in the `args` in your configuration.
  </Warning>
</View>

<View title="EU docs">
  <Warning>
    **Include a server URL to use the LaunchDarkly MCP server in LaunchDarkly's European Union (EU) instance**

    If you are working in LaunchDarkly's European Union (EU) instance, you must additionally include `"--server-url", "https://app.eu.launchdarkly.com"` in the `args` in your configuration.
  </Warning>
</View>

Follow the instructions below to install the MCP configuration to Cursor, Claude, or Copilot. For other IDEs, refer to your client's instructions to learn where this configuration is located.

<AccordionGroup>
  <Accordion title="Expand Cursor installation instructions">
    A quick installer for the LaunchDarkly MCP server is available on Cursor's website.

    Here's how to find and use it:

    1. Navigate to Cursor's list of [supported MCP servers](https://cursor.com/docs/context/mcp/directory) and scroll to "LaunchDarkly."
    2. Click **Add to Cursor**. On your local machine, Cursor launches and the "Cursor Settings" page opens, preconfigured to install LaunchDarkly's MCP server.
    3. Replace the example API key `api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` with your LaunchDarkly API access token.
    4. Click **Install**.
  </Accordion>

  <Accordion title="Expand Claude installation instructions">
    To install to Claude:

    1. Update the `claude_desktop_config.json` file to include the LaunchDarkly MCP server JSON configuration.
  </Accordion>

  <Accordion title="Expand GitHub Copilot instructions">
    To install to GitHub Copilot:

    1. Navigate to a target repository on GitHub.
    2. Select **Settings** > **Code and automation** > **Copilot** > **Coding agent**.
    3. Navigate to the "MCP configuration" section and add the LaunchDarkly MCP server JSON configuration.
    4. Click **Save**.
  </Accordion>
</AccordionGroup>

#### Run the MCP server from a local build

Optionally, you can run LaunchDarkly's MCP server from a local build instead of from your AI client.

First, install and build the MCP server:

<CodeGroup>
  ```bash title="Install LaunchDarkly's MCP server locally" lines wrap theme={null}
  git clone git@github.com:launchdarkly/mcp-server.git

  npm install
  npm run build
  ```
</CodeGroup>

Then, configure your server definition to reference your local clone. For example:

<CodeGroup>
  ```json title="Configure MCP server definition" lines wrap theme={null}
  {
    "mcpServers": {
      "LaunchDarkly": {
        "command": "node",
        "args": [
          "/path/to/mcp-server/bin/mcp-server.js", "start",
          "--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        ]
      }
    }
  }
  ```
</CodeGroup>

### Enable the MCP server

Depending on your client, after you update your JSON configuration file, you may have additional steps to enable the LaunchDarkly MCP server:

* Restart your AI client. This ensures the updates to the configuration file take effect. Most AI clients read their list of MCP servers when they start and do not pick up servers added while they are running.
* You may need to toggle on the LaunchDarkly MCP server configuration. For example, in Cursor you must enable each MCP server separately:

  <Frame caption="A list of MCP servers in Cursor, with the LaunchDarkly MCP server toggled on.">
    <img src="https://mintcdn.com/launchdarkly/6toei-i72Mf97ImT/images/__third_party/mcp-tools-cursor.png?fit=max&auto=format&n=6toei-i72Mf97ImT&q=85&s=d0e76e096f42bca380acd945c6d4c178" alt="A list of MCP servers in Cursor, with the LaunchDarkly MCP server toggled on." width="1778" height="538" data-path="images/__third_party/mcp-tools-cursor.png" />
  </Frame>

## Restrict usage

You can specify additional options in your server configuration if you want to restrict the MCP server's access to your LaunchDarkly account.

To give the MCP server only read-only access, we recommend using both of the following options:

* When you [create your API access token](#authentication), specify a Reader base role, or another role with read-only access.
* In your server configuration, add `"--scope", "read"` to the `args` array.

To enable only specific [tools](/docs/home/getting-started/mcp#available-mcp-tools) in your server configuration, add `"--tool", "<tool>"` to the `args` array for each tool you want to enable. For example:

<CodeGroup>
  ```json title="Enable only specific MCP tools" lines wrap theme={null}
  {
    "mcpServers": {
      "LaunchDarkly": {
        "command": "npx",
        "args": [
          "-y", "--package", "@launchdarkly/mcp-server", "--", "mcp", "start",
          "--tool", "create-feature-flag", "--tool", "update-feature-flag",
          "--api-key", "api-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        ]
      }
    }
  }
  ```
</CodeGroup>
