# Context7 MCP: Feed Current Library Docs to an Agent

> Canonical: https://skillalmanac.com/learn/context7-mcp-guide | Updated: 2026-11-25 | Index status: index-eligible

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.

## Facts

- Checked 2026-11-25: Context7 exposes resolve-library-id and query-docs MCP tools; query-docs accepts an exact Context7 library ID, query, and optional language (https://github.com/upstash/context7)
- Checked 2026-11-25: Providing a known Context7 library ID skips library matching (https://github.com/upstash/context7)
- Checked 2026-11-25: npx ctx7 setup requires Node.js 22.13 or newer and can configure CLI-plus-skill or MCP mode (https://github.com/upstash/context7)
- Checked 2026-11-25: Context7 recommends an API key for higher rate limits and documents https://mcp.context7.com/mcp for manual MCP configuration (https://github.com/upstash/context7)
- Checked 2026-11-25: Context7 says indexed projects are community-contributed and does not guarantee their accuracy, completeness, or security (https://github.com/upstash/context7)
- Checked 2026-11-25: MCP is an open standard through which AI applications can connect to external data, tools, and workflows (https://modelcontextprotocol.io/docs/getting-started/intro)

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](/skills/skill-almanac/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.

## Related skills

- [library-docs-lookup](https://skillalmanac.com/skills/skill-almanac/library-docs-lookup.md): Platform Score 52/100 (provisional)

## Related guides

- [Notion MCP: Agent Read and Write Access and How to Limit It](https://skillalmanac.com/learn/notion-mcp-guide.md)
- [Sentry MCP: pull an error into an agent session](https://skillalmanac.com/learn/sentry-mcp-guide.md)
- [AWS MCP Server: Connect an Agent Read-Only First](https://skillalmanac.com/learn/aws-mcp-server-guide.md)
- [Chrome DevTools MCP: Debug a Live Page Through an Agent](https://skillalmanac.com/learn/chrome-devtools-mcp-guide.md)

## Sources

- https://github.com/upstash/context7
- https://code.claude.com/docs/en/mcp
- https://modelcontextprotocol.io/docs/getting-started/intro

Platform Scores report our assessment under a published method. They are not a safety guarantee.
