---
title: Cursor
description: Using Context7 with Cursor
---
export const InstallOption = ({ title, children, recommended }) => {
return (
<div className="p-5 rounded-xl border border-zinc-200 dark:border-zinc-700 bg-zinc-50/50 dark:bg-zinc-800/50">
<div className="flex items-center gap-2 mb-3">
<span className="font-semibold text-zinc-900 dark:text-zinc-100">{title}</span>
{recommended && (
<span className="px-2 py-0.5 text-xs font-medium rounded-full bg-emerald-100 dark:bg-emerald-900/30 text-emerald-700 dark:text-emerald-400">
Recommended
</span>
)}
</div>
<div className="text-zinc-600 dark:text-zinc-400">{children}</div>
</div>
);
};
export const CursorInstallButton = ({ url, type = "remote" }) => {
return (
<a
href={url}
target="_blank"
rel="noopener noreferrer"
className="group inline-flex items-center gap-3 px-5 py-3 rounded-xl border-2 border-zinc-900 dark:border-zinc-100 bg-zinc-900 dark:bg-zinc-100 hover:bg-zinc-800 dark:hover:bg-zinc-200 transition-all duration-200 no-underline w-fit"
>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 21 22"
className="w-6 h-6 text-white dark:text-zinc-900"
fill="currentColor"
>
<path d="M19.162 5.452 10.698.565a.88.88 0 0 0-.879 0L1.356 5.452a.74.74 0 0 0-.37.64v9.853a.74.74 0 0 0 .37.64l8.464 4.887a.879.879 0 0 0 .879 0l8.464-4.886a.74.74 0 0 0 .37-.64V6.091a.74.74 0 0 0-.37-.64Zm-.531 1.035L10.46 20.639c-.055.095-.201.056-.201-.055v-9.266a.52.52 0 0 0-.26-.45L1.975 6.237c-.096-.056-.057-.202.054-.202h16.34c.233 0 .378.252.262.453Z" />
</svg>
<span className="text-sm font-semibold text-white dark:text-zinc-900">
Add to Cursor
</span>
<svg
className="w-4 h-4 text-white/70 dark:text-zinc-900/70 group-hover:translate-x-0.5 transition-transform"
fill="none"
viewBox="0 0 24 24"
stroke="currentColor"
strokeWidth={2}
>
<path strokeLinecap="round" strokeLinejoin="round" d="M9 5l7 7-7 7" />
</svg>
</a>
);
};
export const Divider = ({ text }) => {
return (
<div className="flex items-center gap-4 my-6">
<div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-700" />
<span className="text-sm text-zinc-500 dark:text-zinc-400 font-medium">{text}</span>
<div className="flex-1 h-px bg-zinc-200 dark:bg-zinc-700" />
</div>
);
};
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
<Tabs>
<Tab title="Remote Server (Recommended)" icon="cloud">
No dependencies required. Connects to Context7's hosted server.
<InstallOption title="One-Click Install" recommended>
Click the button to add Context7 to Cursor automatically:
<div className="mt-3">
<CursorInstallButton url="https://cursor.com/en/install-mcp?name=context7&config=eyJ1cmwiOiJodHRwczovL21jcC5jb250ZXh0Ny5jb20vbWNwIiwiaGVhZGVycyI6eyJDT05URVhUN19BUElfS0VZIjoiWU9VUl9BUElfS0VZIn19" type="remote" />
</div>
</InstallOption>
<Divider text="or" />
<InstallOption title="Manual Installation">
<Steps>
<Step title="Open Cursor Settings">
Go to `Cursor` → `Settings...` → `Cursor Settings` → `MCP`.
You can also press `Cmd+Shift+P` (or `Ctrl+Shift+P` on Windows/Linux) and type "Cursor Settings".
<Frame>
<img src="/images/clients/cursor/mcp-settings.png" alt="Cursor MCP Settings" />
</Frame>
</Step>
<Step title="Add Context7 Server">
Click "Add a Custom MCP Server" or edit `~/.cursor/mcp.json` directly:
<CodeGroup>
```json With API Key
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp",
"headers": {
"CONTEXT7_API_KEY": "YOUR_API_KEY"
}
}
}
}
```
```json With OAuth
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp/oauth"
}
}
}
```
```json Without API Key
{
"mcpServers": {
"context7": {
"url": "https://mcp.context7.com/mcp"
}
}
}
```
</CodeGroup>
<Tip>
Using OAuth? You'll be redirected to sign in the first time you connect. After that, tokens refresh automatically. See [OAuth authentication](/howto/oauth) for details.
</Tip>
</Step>
</Steps>
</InstallOption>
</Tab>
<Tab title="Local Server" icon="computer">
Runs on your machine. Requires Node.js 18+.
<InstallOption title="One-Click Install" recommended>
Click the button to add Context7 to Cursor automatically:
<div className="mt-3">
<CursorInstallButton
url="https://cursor.com/en/install-mcp?name=context7&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkB1cHN0YXNoL2NvbnRleHQ3LW1jcCIsIi0tYXBpLWtleSIsIllPVVJfQVBJX0tFWSJdfQ=="
type="local"
/>
</div>
</InstallOption>
<Divider text="or" />
<InstallOption title="Manual Installation">
<Steps>
<Step title="Open Cursor Settings">
Go to `Cursor` → `Settings...` → `Cursor Settings` → `MCP`.
You can also press `Cmd+Shift+P` (or `Ctrl+Shift+P` on Windows/Linux) and type "Cursor Settings".
<Frame>
<img src="/images/clients/cursor/mcp-settings.png" alt="Cursor MCP Settings" />
</Frame>
</Step>
<Step title="Add Context7 Server">
Click "Add a Custom MCP Server" or edit `~/.cursor/mcp.json` directly:
<CodeGroup>
```json With API Key
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
}
}
}
```
```json Without API Key
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp"]
}
}
}
```
</CodeGroup>
</Step>
</Steps>
</InstallOption>
</Tab>
</Tabs>
### Project-Level Configuration
You can also configure Context7 for a specific project by creating `.cursor/mcp.json` in your project folder. This is useful when:
- Different projects need different API keys
- You want to share the config with your team via version control
- A project requires specific Context7 settings
The project config uses the same format as the global config.
---
## Setting Up Rules
To make Context7 trigger automatically (without typing "use context7" every time), add a rule in Cursor.
<Tabs>
<Tab title="Cursor Settings" icon="settings">
<Steps>
<Step title="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".
<Frame>
<img src="/images/clients/cursor/rules.png" alt="Cursor Rules and Commands" />
</Frame>
</Step>
<Step title="Add the Rule">
```
Always use Context7 MCP when I ask about library documentation,
API references, or need code examples from external packages.
```
</Step>
</Steps>
</Tab>
<Tab title=".cursorrules File" icon="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.
</Tab>
</Tabs>
---
## Using Context7
Add "use context7" to your prompts to fetch current documentation:
```
use context7 to show me how to set up middleware in Next.js 15
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
```
---
## Tips
<AccordionGroup>
<Accordion title="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>
<Accordion title="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>
<Accordion title="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?
```
</Accordion>
</AccordionGroup>