cqbase.net · English & Chinese

CQBase

Context & Query Base

MCP

Context7

An MCP that feeds current library docs to an agent so it writes against the API you have.

Upstash Context7 serves library documentation to coding agents. The repository is MIT and the product site is context7.com. The problem is narrow: the agent remembers the API from training, and the docs have moved on.

After you connect it to an MCP client, name the library in the question so the agent fetches docs before writing. Still check that the pages it retrieved match the version you have pinned.

This page is a guide, not the original text.

What problem it solves

A coding agent often answers from the library APIs it saw in training. Those APIs move on, so you can get a function that no longer exists, or a pattern the current major version has replaced. Context7’s job is narrow: when you ask, it pulls version-aware docs and examples from its index into the agent’s context.

Official docs describe two modes. In MCP mode, the client exposes resolve-library-id and query-docs. In CLI + Skills mode, a skill tells the agent to run ctx7 commands, without MCP. This guide focuses on MCP in Claude Code and Cursor.

Libraries in the index are community-contributed and maintained by their owners. The README states that accuracy is not guaranteed for every page. After a snippet arrives, check it against the version your project pins.

Who it is for

It is for people who already use Claude Code, Cursor, or another MCP client and need current library usage, or want to pin a library ID or version. To browse docs only, open context7.com. For the REST API, see the official API Guide.

How to install it

The commands below were checked on 15 November 2026 (Asia/Shanghai) and come from official docs only. Create a free API key in the Context7 dashboard if you want the higher limits. Keys start with ctx7sk and are shown once; do not commit them.

The ctx7 CLI requires Node.js 22.13 or newer. For the local MCP package, troubleshooting asks for v20.18.1 or later. To skip local Node, use https://mcp.context7.com/mcp.

One-command setup

Run npx ctx7 setup. The flow signs you in with OAuth, creates an API key, and installs MCP or CLI + Skills. To target one agent, pass --claude or --cursor. Login uses a device-code flow, including on SSH. To undo setup, run npx ctx7 remove.

Claude Code

Besides setup, a plugin talks to the hosted MCP server and does not need local Node.js. Run /plugin marketplace add upstash/context7, then /plugin install context7@context7-marketplace. Restart, run /mcp, select Context7, and finish the browser sign-in. The plugin does not require a pasted key and does not read CONTEXT7_API_KEY. On a headless, SSH, or CI host that needs a key, use npx ctx7 setup --claude or add the server manually.

Remote: claude mcp add --scope user --header "Authorization: Bearer YOUR_API_KEY" --transport http context7 https://mcp.context7.com/mcp

Local: claude mcp add --scope user context7 -- npx -y @upstash/context7-mcp --api-key YOUR_API_KEY

--scope user is user-level; omit it for the current project only. Check with claude mcp list.

Cursor

The shortcut is npx ctx7 setup --cursor. For a manual config, official docs recommend ~/.cursor/mcp.json, or .cursor/mcp.json in one repo. Remote example:

{
  "mcpServers": {
    "context7": {
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY"
      }
    }
  }
}

Local: run npx with @upstash/context7-mcp and --api-key. Restart afterward. Full JSON is in the Cursor docs.

Cursor Cloud Agents do not read a local or repo mcp.json. Add an HTTP server in the Cloud Agent UI, at the same URL, with the header Context7-API-Key (underscore names may be dropped by the proxy). Remote HTTP can also use https://mcp.context7.com/mcp/oauth; OAuth is remote-only, and local stdio still needs an API key.

Free allowance

Without a key, official docs only say limits are low and do not publish a number, so this page does not invent one. With a free account and a key, you get 1,000 calls per month across MCP, the CLI, and the APIs. After that, requests pause until the next month, with 20 bonus calls each day. Each search or docs lookup counts as one call. Check usage in the dashboard or with GET /api/v2/usage (it does not count).

A worked example

The goal is to have a connected agent look up current App Router setup notes for Next.js. The prompts come from official docs. This review did not run them in a live client, so the page does not invent returned docs or generated code.

  1. After install, confirm the client can see Context7 (/mcp or claude mcp list in Claude Code; Tools & MCP in Cursor).
  2. In a fresh chat, send: use context7 with /vercel/next.js for app router setup. If you do not know the library ID, use: use context7 to show me how to set up a proxy in Next.js 16.
  3. Based on official tool descriptions, not a run recorded here: if the prompt already has an ID such as /vercel/next.js, the agent should call query-docs. If you only gave a library name, it should call resolve-library-id first, then fetch docs. After npx ctx7 setup, a skill can trigger even if you omit “use context7”.
  4. When the docs arrive, check that they cover App Router or Next.js 16, not a similarly named library or the wrong version. Official tips say naming the version helps.
  5. Treat the answer as current index content, not a permanent contract. For anything you ship, compare it with your pinned dependency and upstream docs.

Common pitfalls

Each item below is from official troubleshooting or a public issue.

  • Rate limits or HTTP 429. Missing keys, or a used-up free allowance, can throttle you. Official docs recommend adding a key. Over-limit responses include Retry-After. See Troubleshooting and the API Guide.
  • 401 Unauthorized. Confirm the key is current and starts with ctx7sk. Remote HTTP should send Authorization: Bearer …; local stdio should pass --api-key. The plugin does not read CONTEXT7_API_KEY. Issue #716 reported this even with new keys; it was closed on 12 December 2025, so start by checking the header format.
  • Local npx fails with ERR_MODULE_NOT_FOUND, or the server never comes up. Try @upstash/context7-mcp@latest, bunx or deno, or the remote URL. Issue #12 started working after @latest. If local npx on Windows knocks out MCP, issue #829 recovered by switching to the remote URL. Official troubleshooting also lists cmd /c npx and a full Node path for timeouts.
  • 404, library not found. IDs should look like /owner/repo or /owner/repo/version. Search with resolve-library-id, or confirm the library on context7.com.
  • Cursor shows no tools after a config change. Use Cursor 1.0 or later and restart. Cloud Agents also need the server enabled for that run.
  • Docs come back, but the answer still looks like an old API. The agent may have resolved the wrong library or version. Put the ID and version in the prompt, and read the excerpt.

See the troubleshooting page for the full list. Check the hosted server with curl https://mcp.context7.com/ping; a healthy response includes pong.

FAQ

Do I have to have an API key?

No. Most lookup commands can run without a login, but official docs recommend a key for higher limits. The Claude Code plugin signs in through the browser and does not require a pasted key. A free account with a key includes 1,000 calls per month.

Do I have to type “use context7”?

No. After ctx7 setup, a skill can fire on library or API questions by itself. You can still say it explicitly, or add the official rule in Cursor or CLAUDE.md.

What do the two MCP tools do?

resolve-library-id turns a library name and a short task into an ID such as /vercel/next.js. query-docs uses that ID plus a question to fetch docs. An optional language parameter ranks examples in that language first. The CLI equivalents are ctx7 library and ctx7 docs.

Can I pin a version?

Yes. Official examples mention “Next.js 16”, or use /vercel/next.js/v16.2.9. If that exact release is not indexed, the request can still return the closest indexed version and say which one was served.

Is the documentation always right?

No. The README says projects are community-contributed and accuracy is not guaranteed. Treat the result as an excerpt from the current index, and check it against your pinned dependency and upstream docs.

Sources and license

The repository upstash/context7 is MIT licensed. The product site is context7.com. This page follows the README and official CLI, Claude Code, Cursor, troubleshooting, pricing, and API docs as of 15 November 2026, rewritten for CQBase — Context & Query Base. If those pages change, follow them.

Subscribe to CQBase Weekly

One email a week with newly catalogued public AI skills, prompts, MCP servers, and methods. Unsubscribe at any time. We will not hand your address to a third party for their marketing.