Context7: Up-to-Date Library Documentation Injected into AI Coding Prompts
Context7 feeds up-to-date, version-specific library documentation and code examples straight into LLM prompts via MCP, reducing outdated answers and hallucinated APIs.
At a glance
- What is it?
- Context7 is an MCP server and CLI tool that fetches version-specific library documentation and code examples and places them directly into AI agent prompts. It works as a CLI skill or as an MCP server, supports Cursor, Claude Code, OpenCode, and over thirty other clients, and provides a free API key with rate limits.
- Who is it for?
- Teams using AI coding agents who regularly encounter outdated or hallucinated API responses should try Context7. The setup is one command and the free API key covers moderate use.
- Can I use it commercially?
- Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
- Is it still maintained?
- Yes. The repository received new commits within the last day.
- What is it written in?
- Mainly TypeScript, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 29, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What Problem Context7 Solves and Who Needs It
AI coding agents generate code from their training data, which has a fixed cutoff date. When a library ships a new major version after that cutoff, the agent continues generating code for the old API. It may produce method calls that no longer exist, configuration keys that were renamed, or import paths that changed. Context7 addresses this by fetching up-to-date, version-specific documentation from its index and placing the relevant content directly into the prompt before the agent generates code.
The README frames the problem clearly. Without Context7, code examples are based on year-old training data, hallucinated APIs are common, and generic answers target old package versions. With it, the agent receives the current documentation excerpt alongside the user's question.
The intended users are developers who use AI coding agents such as Cursor, Claude Code, or OpenCode and regularly work with libraries that change frequently. If your codebase depends on stable, rarely-changed libraries and your agent handles them accurately already, the benefit is smaller.
Two Operating Modes: CLI Skills and MCP Server
Context7 supports two integration modes. The first is CLI plus Skills. This mode installs a skill that guides the agent to run `ctx7` CLI commands when it encounters library-related questions. It does not require an MCP client. The second is MCP mode, which registers a Context7 MCP server so the agent can call documentation tools natively through the Model Context Protocol.
In MCP mode, the server URL is `https://mcp.context7.com/mcp` and authentication uses an `Authorization: Bearer YOUR_API_KEY` header. The README provides a link to manual setup instructions covering over thirty MCP clients.
The choice between modes depends on the agent's capabilities. Agents that support MCP natively will get a smoother experience from MCP mode, where the agent invokes `resolve-library-id` and `query-docs` as tool calls. CLI mode works in agents that can run shell commands but do not have MCP support.
Installing Context7 and Getting an API Key
The README states that the `ctx7` CLI requires Node.js 18 or newer. The installation command is:
npx ctx7 setupThis authenticates via OAuth, generates an API key, and installs the appropriate skill. During setup, you choose between CLI and MCP mode. The `--cursor`, `--claude`, or `--opencode` flags target a specific agent without prompting.
The README notes that an API key is recommended for higher rate limits and directs users to context7.com/dashboard to get a free one. The free key imposes rate limits; the README does not document the specific limits or any paid tier pricing.
To remove Context7 later:
npx ctx7 removeFor manual configuration, add the server URL to your MCP client and include the API key in the Authorization header. The README links to per-client instructions at context7.com/docs/resources/all-clients for cases where `npx ctx7 setup` does not cover the target client.
The CLI Commands and MCP Tools
After installation, two CLI commands are available. `ctx7 library` searches the Context7 index by library name and returns matching libraries with their IDs:
ctx7 library <name> <query>`ctx7 docs` retrieves documentation for a library using its Context7-compatible ID:
ctx7 docs <libraryId> <query>The ID format uses a leading slash, for example `/mongodb/docs` or `/vercel/next.js`. This slash syntax tells Context7 which library to load docs for directly, skipping the name-matching step.
In MCP mode, two tools are available. `resolve-library-id` takes a `libraryName` and a `query` and returns the matching Context7 library ID. `query-docs` takes a `libraryId` and a `query` and returns the relevant documentation excerpt. Both `query` parameters are used to rank results by relevance, not just to filter by keyword.
The README also shows a rule that can be added to CLAUDE.md (or the equivalent for other agents):
Always use Context7 when I need library/API documentation, code generation, setup or configuration steps without me having to explicitly ask.With this rule in place, the agent invokes Context7 automatically for library questions rather than requiring the user to append "use context7" to each prompt.
Library ID Syntax, Version Pinning, and Coverage
When the library ID is known, using it directly in the prompt bypasses the library-matching step and reduces latency:
Implement basic authentication with Supabase. use library /supabase/supabase for API and docs.Version-specific documentation is requested by mentioning the version in the prompt. The README shows this example:
How do I set up Next.js 14 middleware? use context7Context7 matches the version mentioned in the prompt against its index and returns the corresponding documentation.
Coverage depends on community contributions. The README includes a link to the process for submitting a library. Not every package available on npm or PyPI is indexed; teams that depend on a niche or internal library may find it absent. The README's disclaimer states that Context7 cannot guarantee the accuracy, completeness, or security of all community-contributed documentation.
What This Repository Does Not Include and Its Limitations
The repository hosts the MCP server source code. The API backend, parsing engine, and crawling engine are private and not part of the repository. That means the infrastructure that actually fetches, parses, and indexes library documentation cannot be self-hosted from this code alone. Teams that need on-premises documentation delivery without a dependency on context7.com cannot replicate the full stack from what is published here.
The .env.example file lists the environment variables needed to run the MCP server. Several are clearly tied to the hosted service: CONTEXT7_API_URL defaults to `https://context7.com/api`, and variables like OAUTH_AUTH_SERVER_URL and VERCEL_MARKETPLACE_OIDC_ISSUER refer to hosted infrastructure. The README's developer guide at context7.com/docs/resources/developer covers running the MCP server locally, but local operation still queries the hosted API.
GitHub Copilot Chat is Microsoft's AI coding assistant with built-in access to some library documentation through its own indexing pipeline. It does not require separate MCP configuration. Context7 offers a broader integration surface: it works with any MCP-compatible agent and allows community-contributed library additions. The trade-off is that Context7 requires an external API call at inference time, while Copilot Chat's documentation access is internal to its pipeline.
Editorial conclusion
Teams using AI coding agents who regularly encounter outdated or hallucinated API responses should try Context7. The setup is one command and the free API key covers moderate use. Before committing, check that the libraries you rely on are indexed at context7.com; documentation coverage depends on community contributions and is not guaranteed for every package. For in-house or unpublished libraries, the README does not document a self-hosting path for the indexing backend.
Frequently asked questions
What is Context7 for?
Context7 fetches up-to-date, version-specific library documentation and code examples and injects them into AI agent prompts. It prevents agents from generating code based on outdated training data by supplying current documentation at inference time.
How do you install Context7?
Run `npx ctx7 setup` in a Node.js 18 or newer environment. The command authenticates via OAuth, generates an API key, and installs the appropriate skill or MCP configuration. Use the `--cursor`, `--claude`, or `--opencode` flags to target a specific agent.
How much does Context7 cost?
The README mentions a free API key available at context7.com/dashboard that provides higher rate limits than the unauthenticated path. The README does not document specific rate limits or paid tier pricing.
How do you use Context7 with Claude Code?
Add a rule to your CLAUDE.md file directing the agent to use Context7 for library documentation questions. The README gives an example rule that instructs the agent to invoke Context7 automatically without requiring an explicit prompt each time.
Official sources
Add this badge to your README
If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.
[](https://hysenlabs.com/projects/upstash-context7)
Community notes