# Context7

> Up-to-date, version-specific library docs piped straight into your coding agent's prompt

- Category: Retrieval & Knowledge (RAG) / RAG Frameworks & Platforms
- Language: TypeScript
- Licence: MIT
- Repository: https://github.com/upstash/context7
- Website: https://context7.com
- Canonical page: https://ai-tldr.dev/tools/context7/

## In short

Context7 is an open-source tool from Upstash that gives AI coding assistants access to current, version-specific documentation for the libraries you actually use. LLMs are trained on data that ages quickly, so they often suggest outdated APIs, hallucinate methods that do not exist, or answer for old package versions. It sits in the RAG Frameworks & Platforms category of the Retrieval & Knowledge (RAG) tools and is open-source, written in TypeScript and licensed MIT.

## Overview

Context7 is an open-source tool from Upstash that gives AI coding assistants access to current, version-specific documentation for the libraries you actually use. LLMs are trained on data that ages quickly, so they often suggest outdated APIs, hallucinate methods that do not exist, or answer for old package versions. Context7 fixes this by retrieving real documentation and code examples from the source and inserting them directly into your prompt.

It works in two modes. The CLI plus Skills mode installs a skill that teaches your agent to fetch docs through the `ctx7` command-line tool, with no MCP needed. The MCP mode registers a Context7 MCP server so your agent can call documentation tools natively. You add the phrase "use context7" to a prompt, or set up a rule so it triggers automatically for library and API questions.

## What it does

- Fetches up-to-date, version-specific documentation and working code examples for any indexed library
- Two setup modes: a CLI + Skills flow using the ctx7 command, or a native MCP server
- Single-command setup with npx ctx7 setup, with flags to target Cursor, Claude, or OpenCode
- Library ID syntax (for example /vercel/next.js) to skip matching and load docs for an exact library
- Version targeting by simply mentioning the version in your prompt
- Rules and skills that trigger Context7 automatically for documentation and configuration questions

## Getting started

The ctx7 CLI requires Node.js 18 or newer. A free API key from context7.com/dashboard is recommended for higher rate limits. One command sets up Context7 for your coding agent.

1. Run the setup command

   Run the setup command, which authenticates via OAuth, generates an API key, and installs the appropriate skill. It lets you choose between CLI + Skills mode and MCP mode. Add a flag like --cursor, --claude, or --opencode to target a specific agent.

```bash
npx ctx7 setup
```

2. Ask with Context7 in your prompt

   Add the phrase "use context7" to any library-related prompt so the agent fetches current docs and code examples before answering.

```txt
Create a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7
```

3. Use the CLI commands directly

   Search the Context7 index by library name, then retrieve documentation for a specific Context7-compatible library ID.

```bash
ctx7 library next.js "middleware auth"
ctx7 docs /vercel/next.js "middleware auth"
```

4. Configure MCP manually (optional)

   For MCP clients, point them at the Context7 server URL and pass your API key via the CONTEXT7_API_KEY header. The server URL is https://mcp.context7.com/mcp; client-specific instructions are in the linked docs. To remove the generated setup later, run npx ctx7 remove.

## When to use it

- Stopping an AI coding assistant from suggesting outdated or hallucinated APIs by grounding it in real, current docs
- Generating code for a specific library version by mentioning the version in the prompt
- Loading exact documentation for a known library via its Context7 ID (for example /supabase/supabase) to skip the matching step
- Setting up a rule or skill so the agent automatically pulls library and configuration docs without being asked each time
