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

# Cursor

> Using Context7 with Cursor

Context7 brings up-to-date library documentation directly into Cursor. Instead of getting outdated code examples from training data, you get current documentation from source repositories.

## Installation

Run the setup command to configure Context7 for Cursor:

```bash theme={null}
npx ctx7 setup --cursor
```

Authenticates via OAuth, generates an API key, and installs the appropriate skill. You can choose between CLI or MCP mode.

For manual MCP installation or other configuration options, see [All MCP Clients](https://context7.com/docs/resources/all-clients.md).

***

## Setting Up Rules

With `ctx7 setup`, a skill is installed that triggers Context7 automatically. If you prefer to use a rule instead, add one in Cursor.

> [tab] Cursor Settings
>
> **1. Open Settings**
>
> Go to `Cursor` → `Settings...` → `Cursor Settings` → `Rules and Commands`. You can also press `Cmd+Shift+P` (or `Ctrl+Shift+P` on Windows/Linux) and type "Cursor Settings".
>
> ![Cursor Rules and Commands](https://mintcdn.com/context7/KkeagQxZJ8JBG-ut/images/clients/cursor/rules.png?fit=max\&auto=format\&n=KkeagQxZJ8JBG-ut\&q=85\&s=7cd0fb4f6895713d8bbae5a5cecc96c9)
>
> **2. Add the Rule**
>
> ```
> Always use Context7 MCP when I ask about library documentation,
> API references, or need code examples from external packages.
> ```

> [tab] .cursorrules File
>
> Create a `.cursorrules` file in your project root:
>
> ```
> # Context7 Integration
>
> When the user asks about:
> - Library APIs or documentation
> - Framework setup or configuration
> - Code examples for external packages
> - How to use a specific library feature
>
> Automatically use Context7 MCP to fetch current documentation. Don't rely on training data for library-specific code.
> ```
>
> This makes Context7 part of your project's standard workflow and can be version-controlled.

***

## Using Context7

Add "use context7" to your prompts to fetch current documentation:

```
use context7 to show me how to set up a proxy in Next.js 16
use context7 for Prisma query examples with relations
use context7 for the Supabase syntax for row-level security
```

If you know the library ID, use it directly to skip resolution:

```
use context7 with /supabase/supabase for authentication docs
use context7 with /vercel/next.js for app router setup
```

***

## Cursor Cloud Agents

Cursor Cloud Agents use MCP servers configured for the cloud agent, not the MCP configuration from your local Cursor installation. If Context7 works in the IDE but not in a Cloud Agent, add an authenticated HTTP server in the Cloud Agent UI.

> [!NOTE]
>
> The MCP connection is independent of the model selected for the agent. You can
> use the same Context7 server with any model available in Cursor Cloud Agents.

### Before you begin

Create an API key in the [Context7 dashboard](https://context7.com/dashboard?tab=settings). Keep the key available while you complete the steps below, but do not commit it to your repository or include it in screenshots.

### Add Context7 to Cursor Cloud Agents

**1. Open a Cloud Agent**

Go to [cursor.com/agents](https://cursor.com/agents) and start a new agent. If you start the agent from the Cursor desktop app, select **Cloud** from the environment menu below the agent input.

![New Cursor Cloud Agent composer](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/01-new-cloud-agent.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=40382bb7833224823e352c303a333a5c)

**2. Open the MCP server menu**

Select **+** (**Add context and tools**), then **MCP Servers** and **Add MCP**.

![MCP Servers menu in a Cursor Cloud Agent](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/02-open-mcp-servers.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=e7a734451167218c134139fc6d4c7130)

**3. Choose Custom MCP**

In the MCP browser, select **Custom MCP**.

![Custom MCP option in Cursor's MCP browser](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/03-add-custom-mcp.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=c72bf6a68269a16fe60184a57ad43e39)

**4. Configure the authenticated Context7 server**

Enter the following values:

| Field | Value |
| - | - |
| **Name** | `context7-api-key` |
| **Type** | `URL` |
| **Server URL** | `https://mcp.context7.com/mcp` |
| **Header key** | `Context7-API-Key` |
| **Header value** | Your Context7 API key |

The distinct `context7-api-key` name avoids a namespace collision when the OAuth-based Context7 plugin is also installed. If you do not use the plugin, you can name the server `context7`.

Context7 also accepts `Authorization: Bearer YOUR_API_KEY`, as shown in the general MCP client examples. This guide uses `Context7-API-Key` because that configuration was verified with Cursor Cloud Agents and keeps API-key authentication separate from the plugin's OAuth connection.

> [!WARNING]
>
> Use a hyphenated header name in Cursor Cloud. Header names containing
> underscores, such as `CONTEXT7_API_KEY`, can be dropped by Cursor's proxy.
> `CONTEXT7_API_KEY` remains the environment variable name for local stdio
> connections.

![Context7 URL and API key header in Cursor's custom MCP form](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/04-configure-context7-api-key.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=0ffb4f0c069dfdfcd432421f272fbc86)

Alternatively, select **Edit JSON** and use this configuration:

```json theme={null}
{
  "mcpServers": {
    "context7-api-key": {
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "Context7-API-Key": "YOUR_CONTEXT7_API_KEY"
      }
    }
  }
}
```

![Context7 custom MCP JSON configuration in Cursor Cloud Agents](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/05-context7-json-config.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=3d51a723428e14fbe59265dc427b483b)

**5. Add and enable the server**

Select **Add MCP**. Before starting the run, open **+** → **MCP Servers** again and confirm that `context7-api-key` is enabled.

A green status confirms that Cursor initialized the MCP server. It does not by itself prove that the request was authenticated.

**6. Verify authenticated access**

Start a new Cloud Agent run and test both tools:

```text theme={null}
Use Context7 to resolve the library ID for Next.js, then query its documentation
for the proxy file. Tell me which Context7 tools you called.
```

To verify authentication conclusively, query a private library that belongs to the Context7 account associated with the API key:

```text theme={null}
Use Context7 to query <YOUR_PRIVATE_LIBRARY_ID>. Summarize its installation docs.
```

If the private library can be read, the Cloud Agent is using the API key. If the private library cannot be read, Context7 did not receive the key; recheck the header name and start a new run after saving the MCP server.

After the API-key header is applied, the same Cloud Agent should be able to resolve a library and return documentation:

![Successful Context7 documentation query from a Cursor Cloud Agent](https://mintcdn.com/context7/chd46X9OGLuSwByW/images/clients/cursor/cloud-agents/06-verify-context7.png?fit=max\&auto=format\&n=chd46X9OGLuSwByW\&q=85\&s=285b8a74cd55fb4168e6fdd295067dc0)

### OAuth and the Context7 Cursor plugin

The Context7 plugin uses the OAuth endpoint and does not currently provide a field for an API key. Cursor supports OAuth for Cloud MCP servers, but installing or enabling the plugin does not guarantee that its OAuth sign-in flow has completed.

* Use the plugin when you want OAuth and complete the sign-in prompt for the same Cursor account that launches the Cloud Agent.
* Use the custom HTTP setup above when you need explicit API-key authentication, including access to private Context7 libraries.

See Cursor's documentation for [custom MCP servers](https://cursor.com/docs/cloud-agent/capabilities#custom-mcp-servers) and [Cloud Agent MCP support](https://cursor.com/docs/cloud-agent#mcp-support).

### Troubleshooting

> [accordion] The API key is not applied
>
> Confirm that the custom server URL is `https://mcp.context7.com/mcp`, the header is named `Context7-API-Key`, and the saved value is the current API key. Then enable the server and start a new Cloud Agent run. The server can report a ready status without the key, so use the private-library check above to verify.

> [accordion] The server is ready, but private docs are unavailable
>
> A ready status only confirms MCP initialization. Test a private library ID to verify authentication, then confirm that the library belongs to the same Context7 account as the API key.

> [accordion] Context7 tools or namespace are missing
>
> Open **+** → **MCP Servers** before starting the run and enable `context7-api-key`. If the run was already started, enable the server and create a new run so Cursor can expose its tools to the agent.

> [accordion] A repository mcp.json or symlink does not work in Cloud Agents
>
> Configure the personal HTTP MCP server from the Cloud Agent UI. A local `~/.cursor/mcp.json`, a repository `.cursor/mcp.json`, or a symlink created inside the Cloud Agent VM does not configure the backend-proxied personal HTTP connection.

***

## Tips

> [accordion] Project vs Global Config
>
> Use **global config** (`~/.cursor/mcp.json`) when:
>
> * You want Context7 available in all projects
> * You're using a personal API key
>
> Use **project config** (`.cursor/mcp.json`) when:
>
> * The project has specific Context7 requirements
> * You want to share the setup with teammates
> * Different projects need different API keys

> [accordion] Combining with Cursor Composer
>
> Context7 works well with Cursor's Composer feature. When you're building something that involves external libraries:
>
> 1. Start with a prompt that mentions the libraries you need
> 2. Context7 fetches the relevant docs
> 3. Composer uses those docs to generate accurate code
>
> This is especially useful for newer library versions that might not be in Cursor's training data.

> [accordion] Getting Better Results
>
> * Be specific about what you're trying to do, not just which library
> * Mention versions when they matter
> * If the first result isn't right, ask for a different part of the docs
>
> ```
> # Good
> How do I handle file uploads with the Supabase Storage API?
>
> # Less specific
> How does Supabase storage work?
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.