Context7 MCP: Feed Current Library Docs to an Agent

Configure Context7 MCP in Claude Code, resolve a library or use its exact ID, verify the retrieval trace, and check version-sensitive claims against primary docs.

Updated · Markdown version

Context7 is a hosted MCP server that retrieves indexed library documentation and examples for an agent. Retrieval can reduce reliance on model memory, but it does not guarantee that the indexed material is complete, current, secure, or correct; Context7 says its projects are community-contributed. Verify consequential claims against the library's official documentation and the version your project actually uses.

How the two tools work together

The Context7 README lists two MCP tools. resolve-library-id takes a query and libraryName and returns a Context7-compatible library ID. query-docs takes that libraryId and a query, plus an optional language. Resolve first when you only know the package name. If you already know the exact Context7 library ID, provide it and query the documentation directly; the README says this skips the matching step.

Steps

  1. Check that Node.js 22.13 or newer is installed, then run npx ctx7 setup --claude. The Context7 setup authenticates through OAuth, generates an API key, and lets you choose MCP mode or CLI-plus-skill mode. Choose MCP mode for this guide. If you configure another MCP client manually, Context7 documents https://mcp.context7.com/mcp as the server endpoint and recommends an API key for higher rate limits.
  2. After setup, confirm that Context7 appears as a connected MCP server in Claude Code. If it does not, use Context7's manual client instructions rather than placing a personal key directly in a shared project configuration.
  3. Ask a question that names the library and the version or feature you care about. For example: "Use context7 to show how to define a route in <library> version <x>, and cite the docs you used." Naming Context7 in the prompt makes it more likely the agent calls the server rather than answering from memory.

Check that it worked

Look at the tool calls in the session. For a package-name prompt, expect resolve-library-id followed by query-docs; for a prompt containing an exact Context7 ID, query-docs alone is sufficient. Compare the selected ID and any reported version with the dependency you actually use. If no Context7 call appears, first confirm the server is connected, then retry with an explicit instruction to use Context7.

Pitfalls

  • Wrong library match. The resolver chooses from the name and query you send. Check that the resolved library ID names the package you use, especially for libraries with similar names or forks.
  • Silent fallback to memory. A connected server does not guarantee the agent used it. Inspect the tool trace and ask the agent to identify the resolved library ID and the retrieved material supporting its answer. Treat unsupported claims as unverified; do not require long quotations from source documentation.
  • Scope and secrets. Claude Code's default local MCP scope applies only to the current project and is stored under that project in ~/.claude.json. Project scope writes .mcp.json at the project root for version-controlled team sharing, while user scope applies across your projects and remains private to your account. Do not place a personal API key directly in a shared .mcp.json; for manual project configuration, Claude Code supports environment-variable references in header values.
  • Setup fails on an old Node version. npx ctx7 setup needs Node.js 22.13 or newer. Check with node --version first.
  • Lower limits without a key. Context7 recommends an API key for higher rate limits. If a call reports a limit or authentication error, configure the key and retry; do not diagnose every empty result as rate limiting.

Check the current endpoint, setup flow and limits on the Context7 README at https://github.com/upstash/context7, as of 2026-11-25, since these can change.

When to use a skill instead

Context7 is useful when you want a remote documentation index or have an exact Context7 library ID. When correctness depends on the installed dependency, first inspect the project's lockfile and local package metadata, then query documentation for that exact version if available. library-docs-lookup is a related provisionally scored skill, but its supplied evidence is only a three-task single-run evaluation and a recognition-only install probe. It does not guarantee correct version matching or better answers.

FAQ

What is an MCP server? Over the Model Context Protocol, an open standard, a server publishes tools, data or prompts, and the client decides when to call them. Claude Code is one such client: it connects to the server and chooses when to invoke its tools.

Is Context7 MCP the same as a skill? No. Context7 is an MCP server that provides tools. The ctx7 setup command can also install a skill, so the two can exist side by side in one setup.

Can I use Context7 without MCP? Yes. The README lists CLI commands, ctx7 library <name> <query> and ctx7 docs <libraryId> <query>, that query the same documentation without an MCP client.

Platform Score is our assessment under a published method. It is not a safety guarantee.

Terms this guide uses

This item is a worked example in the AI glossary for:

Next steps

  1. Notion MCP: Agent Read and Write Access and How to Limit It Read next.
  2. Sentry MCP: pull an error into an agent session Read next.
  3. All guides by topic Browse everything.

Sources