diff --git a/README.md b/README.md index 44dbb85..a0d637c 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,15 @@ See the [CLI docs](api/cli.md), and [Type safety](product-handbook/type-safety.m {% endtab %} {% tab title="MCP" %} -You can create flags from your code editor via our [MCP](api/mcp.md). +1. Add Reflag MCP to Claude Code: + + ```sh + claude mcp add --transport http Reflag https://app.reflag.com/api/mcp + ``` +2. Start `claude`, enter `/mcp`, select **Reflag** and choose **Authenticate** to sign in. +3. Ask Claude Code to create a flag, for example: "Create a Reflag flag called My new flag." + +Using Cursor, VS Code or another client? See [MCP](api/mcp.md#other-clients). {% endtab %} {% tab title="Linear" %} diff --git a/SUMMARY.md b/SUMMARY.md index e5c929d..553e557 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -42,6 +42,7 @@ * [Overview](integrations/overview.md) * [Slack](integrations/slack.md) * [Linear](integrations/linear.md) +* [Claude Code](integrations/claude-code.md) * [Cursor](integrations/cursor.md) * [GitHub](integrations/github.md) * [Vercel](https://flags-sdk.dev/providers/reflag) diff --git a/api/mcp.md b/api/mcp.md index 7feadde..38e5748 100644 --- a/api/mcp.md +++ b/api/mcp.md @@ -1,63 +1,71 @@ --- description: >- - Reflag supports the MCP protocol. Understand how to connect the agent in your - code editor to your Reflag account. + Connect Claude Code, Cursor, VS Code or any other MCP client to your Reflag + account. --- # MCP -## Set up MCP +The Reflag MCP server lets your coding agent work with your feature flags. It can create flags, read their targeting and status, check who has access, and change rollouts, all without leaving your editor or terminal. -Model Context Protocol enables seamless integration of your Large Language Model (LLM) with external data sources, such as a code editor. This guide will walk you through connecting your editor to Reflag data efficiently. +Reflag hosts the server, so there's nothing to install. It uses HTTP and you sign in with OAuth, so you don't need an API key: -{% embed url="https://139729605.fs1.hubspotusercontent-eu1.net/hubfs/139729605/Videos/bucketco-website/cursor-mcp-flag-feature_full-height_h264.mp4" %} - -

Guide to Integrating Model Context Protocol with Reflag Data

- -### Get started with Reflag Remote MCP +``` +https://app.reflag.com/api/mcp +``` -The Model Context Protocol (MCP) is an open standard that facilitates seamless integration of AI models with various data sources and tools. In Reflag, MCP enhances your code editor's ability to interpret and manage feature flags, comprehending their states and interconnections within the codebase. This forms an efficient link between feature management workflows and AI-driven development tools. With Reflag hosting the MCP server, getting started is incredibly straightforward. +## Claude Code {% stepper %} {% step %} -#### One-click to add Reflag MCP in your IDE +#### Add the server + +In your project directory, run: -* [Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=Reflag\&config=eyJ1cmwiOiJodHRwczovL2FwcC5yZWZsYWcuY29tL2FwaS9tY3AiLCJ0eXBlIjoiaHR0cCJ9) -* [VSCode](vscode:mcp/install?%7B%22name%22%3A%22Reflag%22%2C%22gallery%22%3Afalse%2C%22url%22%3A%22https%3A%2F%2Fapp.reflag.com%2Fapi%2Fmcp%22%7D) +```sh +claude mcp add --transport http Reflag https://app.reflag.com/api/mcp +``` + +{% hint style="info" %} +Add `--scope project` to save the server to `.mcp.json` in your project. Commit that file and everyone on your team gets Reflag MCP when they open the project in Claude Code. +{% endhint %} {% endstep %} {% step %} -#### That's it! +#### Sign in + +Start `claude`, enter `/mcp`, select **Reflag** and choose **Authenticate**. Finish signing in to Reflag in your browser. {% endstep %} -{% endstepper %} -{% hint style="info" %} -Ensure your editor/client and [Node.js](https://nodejs.org/en/download) versions are up to date. -{% endhint %} +{% step %} +#### Start prompting -### Using Reflag CLI +Try asking Claude Code: -To install the MCP into your preferred editor, use the Reflag CLI. This tool will configure your editor and provide agent guidelines, enhancing editor intelligence. +* "List my Reflag flags." +* "Put this change behind a new Reflag flag." +* "Does the company Acme have access to the `new-checkout` flag?" +* "Roll out `new-checkout` to the beta testers segment." +{% endstep %} +{% endstepper %} -To set up the [MCP support](cli.md#setting-up-mcp), invoke: +To have Claude Code flag new work by default, add instructions to your `CLAUDE.md`. See [Claude Code](../integrations/claude-code.md) for templates. -```sh -npx reflag mcp -``` +## Other clients -### Manual setup +### Claude Desktop and claude.ai -Below are the manual setup steps for some of the popular editors, but there are [more MCP-compatible clients](https://modelcontextprotocol.io/clients). Before you start with the manual setup, you first need the `App ID` from [your app settings page](https://app.reflag.com/env-current/settings/app-general). +1. Go to **Settings > Connectors**. +2. Click **Add custom connector**. +3. Enter `Reflag` as the name and `https://app.reflag.com/api/mcp` as the URL. +4. Click **Connect** and sign in to Reflag. -{% hint style="info" %} -You can use [mcp-remote](https://www.npmjs.com/package/mcp-remote) to enable authentication and remote MCP connections in clients that don't yet support these features. -{% endhint %} +### Cursor -### [Cursor](https://docs.cursor.com/context/model-context-protocol) +[Add Reflag MCP to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=Reflag\&config=eyJ1cmwiOiJodHRwczovL2FwcC5yZWZsYWcuY29tL2FwaS9tY3AiLCJ0eXBlIjoiaHR0cCJ9) with one click, or set it up manually: -1. Open Cursor. -2. Go to `Settings > Cursor Settings`. -3. Click `MCP` and `New MCP Server` and make sure the Reflag MCP server entry is present: +1. Go to **Settings > Cursor Settings > MCP**. +2. Click **New MCP Server** and add the Reflag server: ```json { @@ -70,38 +78,59 @@ You can use [mcp-remote](https://www.npmjs.com/package/mcp-remote) to enable aut ``` {% hint style="info" %} -Cursor also supports workspace-specific MCP servers by adding the above configuration to `.cursor/mcp.json` inside your project directory. +To set up the server for one project only, add the configuration above to `.cursor/mcp.json` in your project directory. {% endhint %} -4. Save, go back to Cursor, and start prompting! +{% embed url="https://139729605.fs1.hubspotusercontent-eu1.net/hubfs/139729605/Videos/bucketco-website/cursor-mcp-flag-feature_full-height_h264.mp4" %} + +

Creating a flag with Reflag MCP in Cursor

+ +### Visual Studio Code -### [Visual Studio Code](https://code.visualstudio.com/docs/copilot/chat/mcp-servers) +[Add Reflag MCP to VS Code](vscode:mcp/install?%7B%22name%22%3A%22Reflag%22%2C%22gallery%22%3Afalse%2C%22url%22%3A%22https%3A%2F%2Fapp.reflag.com%2Fapi%2Fmcp%22%7D) with one click, or set it up manually: {% hint style="info" %} -You must enable the [Copilot agent mode](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode) to use MCP in Visual Studio Code Copilot chat. +You must enable [Copilot agent mode](https://code.visualstudio.com/docs/copilot/chat/chat-agent-mode) to use MCP in Copilot chat. {% endhint %} -1. Open VS Code. -2. Open the command palette, typically `CMD + SHIFT + P` or `CTRL + SHIFT + P`. -3. Type and select `MCP: Add Server...` . -4. Select `HTTP` . -5. Enter `https://app.reflag.com/api/mcp` as the URL -6. Enter `Reflag` as the server ID. +1. Open the command palette (`Cmd+Shift+P` or `Ctrl+Shift+P`). +2. Select **MCP: Add Server...**. +3. Select **HTTP**. +4. Enter `https://app.reflag.com/api/mcp` as the URL. +5. Enter `Reflag` as the server ID. {% hint style="info" %} -VS Code also supports workspace-specific MCP servers by adding the above configuration to `.vscode/mcp.json` inside your project directory. +To set up the server for one project only, add it to `.vscode/mcp.json` in your project directory. {% endhint %} -9. Start prompting! +### Other MCP clients + +Any [MCP client](https://modelcontextprotocol.io/clients) that supports remote HTTP servers with OAuth can connect to `https://app.reflag.com/api/mcp`. -### [Claude Desktop](https://modelcontextprotocol.io/quickstart/user) +For clients that only support local (stdio) servers, use [mcp-remote](https://www.npmjs.com/package/mcp-remote) as a bridge: + +```json +{ + "mcpServers": { + "Reflag": { + "command": "npx", + "args": ["-y", "mcp-remote", "https://app.reflag.com/api/mcp"] + } + } +} +``` + +### Set up with the Reflag CLI + +The [Reflag CLI](cli.md#setting-up-mcp) can write the MCP configuration for Cursor, VS Code, Claude Desktop and Windsurf: + +```sh +npx reflag mcp +``` -1. Open Cursor Desktop. -2. Go to `Settings > General > Claude Settings (Configure) > Connectors` -3. Click Add Custom Connector -4. Enter "Reflag" as the name and paste the MCP URL in: `https://app.reflag.com/api/mcp` +The CLI requires an up-to-date version of [Node.js](https://nodejs.org/en/download). -### Claude Code +## Troubleshooting -1. On the command line inside your project directory, enter: `claude mcp add --transport http Reflag https://app.reflag.com/api/mcp` -2. Start `claude` and enter `/mcp` to begin the authentication process +* **Reflag tools don't show up.** Check that the server is connected: in Claude Code, run `/mcp`; in other clients, open their MCP settings. Then update your client to its latest version. +* **Authentication fails or expires.** Sign in again. In Claude Code, run `/mcp`, select **Reflag** and choose **Authenticate**. diff --git a/integrations/claude-code.md b/integrations/claude-code.md new file mode 100644 index 0000000..7b4a658 --- /dev/null +++ b/integrations/claude-code.md @@ -0,0 +1,45 @@ +--- +description: How to create feature flags in Claude Code +--- + +# Claude Code + +### MCP + +Add Reflag MCP to Claude Code so it can create and manage flags for you: + +```sh +claude mcp add --transport http Reflag https://app.reflag.com/api/mcp +``` + +Then run `/mcp` in Claude Code to sign in. See [MCP](../api/mcp.md#claude-code) for details. + +### CLAUDE.md + +Add instructions to your project's `CLAUDE.md` so Claude Code knows how you use feature flags. Here's a template you can use: + +```markdown +We use Reflag (https://reflag.com) for feature flagging and feature management. + +Reflag's documentation is located at https://docs.reflag.com + +Use the Reflag MCP to create and manage flags. +If the Reflag MCP isn't available, use the Reflag CLI: npx reflag new +``` + +### Slash command + +Create a slash command called `.claude/commands/flag.md`. Here's a template you can use: + +```markdown +Feature flag the changes + +1. Create a feature flag with Reflag with an appropriate name +2. Update the code to ensure changes are flagged + +The Reflag documentation is located at https://docs.reflag.com +If the Reflag MCP is available, use it to create the flag. +Otherwise, use the Reflag CLI: npx reflag new +``` + +Run it in Claude Code with `/flag`. diff --git a/integrations/cursor.md b/integrations/cursor.md index 7925008..a202feb 100644 --- a/integrations/cursor.md +++ b/integrations/cursor.md @@ -35,4 +35,4 @@ If the Reflag MCP is installed, you can create a flag through the Reflag MCP ### MCP -See [mcp.md](../api/mcp.md "mention") page for Cursor instructions +See [MCP](../api/mcp.md#cursor) for how to add Reflag MCP to Cursor.