Guides · Cursor
How to connect the Context7 MCP server to Cursor
Context7 gives Cursor current, version-specific library docs through two tools, resolve-library-id and query-docs. The hosted server at https://mcp.context7.com/mcp needs no local Node.js; an API key is optional but Upstash recommends a free one for higher rate limits. Your library names and queries are sent to Context7's hosted service, whose backend is private.
Steps summarize the official docs linked below, checked 2026-10-30. Client UIs change; if a menu name differs, the linked docs win.
1. Check what you need
Nothing for the hosted server except outbound HTTPS. For an API key, create one in the Context7 dashboard (context7.com/dashboard); keys start with ctx7sk. The local npx server needs Node.js 20 or newer, and the ctx7 setup CLI needs Node.js 22.13 or newer. Context7's troubleshooting page recommends Cursor 1.0 or later.
2. Fastest: let ctx7 set it up
Context7's own setup command for Cursor. It signs you in with OAuth, generates an API key and installs a skill that triggers Context7 for library questions; you choose CLI + skill mode or MCP mode. Undo it later with npx ctx7 remove.
npx ctx7 setup --cursor3. Or install the Context7 plugin from the Cursor Marketplace
The Add to Cursor button in Context7's README opens the Context7 plugin on the Cursor Marketplace (cursor.com/marketplace/upstash/context7). The plugin uses Context7's OAuth endpoint and has no field for an API key, so finish the sign-in prompt after installing it. Use the mcp.json route below when you want explicit API-key authentication.
4. Manual: add the hosted server to mcp.json with the key from an env var
This is the remote config from Context7's client docs, with the key read from your environment instead of pasted into the file. Cursor resolves ${env:NAME} in url and headers, so the file stays secret-free. Use ~/.cursor/mcp.json to have it in every project, or .cursor/mcp.json to share the setup with the repository; each teammate then sets their own CONTEXT7_API_KEY. Remote servers don't support envFile, so set the variable in your shell profile or system environment.
# once, in your shell profile or secret manager: export CONTEXT7_API_KEY="YOUR_API_KEY" # ~/.cursor/mcp.json or .cursor/mcp.json { "mcpServers": { "context7": { "url": "https://mcp.context7.com/mcp", "headers": { "Authorization": "Bearer ${env:CONTEXT7_API_KEY}" } } } }5. No key? Sign in with OAuth instead
Context7 supports OAuth on remote connections: change the endpoint from /mcp to /mcp/oauth and leave out the header. Cursor signs in with the authorization code flow with PKCE the first time it connects. OAuth is not available for the local stdio server.
{ "mcpServers": { "context7": { "url": "https://mcp.context7.com/mcp/oauth" } } }6. Or run it locally over stdio
Context7's local example passes --api-key in args, which puts the key in the file. The local server also reads CONTEXT7_API_KEY from its environment, and Cursor resolves ${env:NAME} in env, so pass it that way. For stdio servers you can also point envFile at a .env file that is in your .gitignore.
{ "mcpServers": { "context7": { "command": "npx", "args": [ "-y", "@upstash/context7-mcp" ], "env": { "CONTEXT7_API_KEY": "${env:CONTEXT7_API_KEY}" } } } }7. Cloud Agents: add it in the Cloud Agent UI
Cloud Agents don't read your local ~/.cursor/mcp.json or the repository's .cursor/mcp.json. Context7's Cursor page says to start an agent at cursor.com/agents, open + (Add context and tools) → MCP Servers → Add MCP → Custom MCP, and add a URL server named context7-api-key at https://mcp.context7.com/mcp with the header Context7-API-Key set to your key. Use the hyphenated header name: Cursor's proxy can drop header names with underscores. A green status only means the server started; Context7 suggests querying one of your private libraries to confirm the key is applied.
8. Check that it works
Context7's two tools appear under Available Tools. Ask for docs with "use context7", or give the library ID (/owner/repo) to skip the lookup step. If it doesn't connect, open the Output panel (Cmd+Shift+U) and select MCP Logs, and restart Cursor after editing mcp.json. Toggle the server off from Customize in the sidebar without deleting the config.
use context7 to show me how to set up a proxy in Next.js 16 use context7 with /vercel/next.js for app router setup
Good to know
- Context7 exposes 2 tools; we measured their definitions at about 1,060 tokens (o200k) on @upstash/context7-mcp 4.4.4, one of the lightest servers on the /mcp-tool-budget page.
- Cursor asks for approval before running MCP tools by default, and MCP tools follow the same Run Modes as terminal commands. Both Context7 tools only fetch documentation, but the text of every query leaves your machine, so don't put secrets or proprietary code in a query before you allowlist them.
- To have Cursor use Context7 without being asked, Context7 suggests a rule under Cursor Settings → Rules (ctx7 setup installs a skill that does this for you).
- If the Marketplace plugin and an API-key server are both installed, give the second one a different name (Context7 uses context7-api-key) to avoid a tool namespace collision.
- Library docs on Context7 are community-contributed; Upstash says it can't guarantee their accuracy or security, and pages have a Report button.
- On Enterprise, admins can approve the server by URL in the MCP Allowlist and restrict which of its tools run automatically.
Troubleshooting
Only errors documented in the official docs; each fix links to its source.
- Rate-limit errors
- Add a free API key from context7.com/dashboard as an Authorization: Bearer header (remote) or CONTEXT7_API_KEY (local). source ↗
- 401 Unauthorized
- Check the key starts with ctx7sk and the header reads exactly Authorization: Bearer <key>. If you use ${env:CONTEXT7_API_KEY}, make sure the variable is set in the environment Cursor was started from, then restart Cursor. source ↗
- Changes to mcp.json don't take effect
- Restart Cursor after changing the MCP configuration, and try the global (~/.cursor/mcp.json) and project (.cursor/mcp.json) files to see which one Cursor is loading. source ↗
- Works in the IDE but not in a Cloud Agent
- Cloud Agents use MCP servers configured for the cloud agent, not your local or repository mcp.json. Add the server from + → MCP Servers in the Cloud Agent, enable it before the run, and start a new run so its tools are exposed. source ↗
- Cloud Agent shows a ready server, but private docs are unavailable
- A ready status only confirms the server started. Check the URL is https://mcp.context7.com/mcp, the header is named Context7-API-Key with your current key, and the library belongs to the same Context7 account as the key. source ↗
- ERR_MODULE_NOT_FOUND or timeouts with the local server
- Use Node.js 20+ and @upstash/context7-mcp@latest, try bunx or deno instead of npx, or skip local Node entirely with the hosted URL. source ↗
Sources
- Context7 README (GitHub, upstash/context7) ↗
- Context7 docs: Cursor ↗
- Context7 docs: All MCP clients ↗
- Context7 docs: Troubleshooting ↗
- Context7 plugin on the Cursor Marketplace ↗
- Cursor docs: Model Context Protocol (MCP) ↗
Catalog verdict
From the AgentTask Atlas catalog entry (verified 2026-10-26). Based on official docs, not hands-on tested. New to MCP in Cursor? Start with the general How to add an MCP server to Cursor.
- Context7 · Upstash · credentials optional
Pick it for up-to-date library docs in prompts; queries go to Context7's hosted service.
Ask the catalog from inside Cursor: the AgentTask Atlas MCP server is free, read-only and needs no account.
Compare by task: Databases & SQL · Git & GitHub repos · Code review · CI/CD · Infra & deploy · Debugging & observability · Library docs & research · Web fetching & scraping · Frontend & UI · Local files · Docs & writing · Build AI apps · Planning & reasoning · Utilities
Same server in other clients: How to connect the Context7 MCP server to Claude Code
⚠ No independent security audit: entries summarize official sources only. Review permissions and code before installing.