~/ai_assets_directory_
MCP Server verified · tested by us 61.7k stars
context7.mcp

Context7

Pulls updated, version-specific documentation and code examples straight from the source into your prompt, so agents stop citing outdated APIs or hallucinating ones that don't exist.

Overview

Context7 solves a specific, common failure mode of coding agents: they rely on training data that's a year (or more) stale, so they hallucinate APIs or generate code for old package versions. Context7 fetches current, version-specific docs and examples and drops them straight into the model's context before it answers.

How it works

Context7 works in two modes. In CLI + Skills mode, it installs a skill that guides the agent to fetch docs with the ctx7 CLI (ctx7 library <name> <query>, ctx7 docs <libraryId> <query>); no MCP required, and it's more token-efficient since it skips loading large tool schemas. In MCP mode, it registers a server with two tools: resolve-library-id (turns a library name into a Context7 ID) and query-docs (fetches docs for that ID).

Add a rule like "Always use Context7 when I need library/API documentation, code generation, setup or configuration steps" to your agent's system prompt/CLAUDE.md so it reaches for it proactively instead of only when you say "use context7".

Examples

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

Implement basic authentication with Supabase. use library /supabase/supabase for
API and docs.

If you already know the exact library, adding its Context7 ID (/org/repo syntax) skips the matching step and goes straight to fetching docs, which helps when several libraries share a similar name.

Installation

You need Node.js 18+.

  1. Run the one-command setup:
    npx ctx7 setup
    
    This handles OAuth login, generates an API key, and installs the right integration for the client it detects (Claude Code, Cursor, VS Code...).
  2. Or configure any MCP client manually by pointing it at https://mcp.context7.com/mcp with an Authorization: Bearer YOUR_API_KEY header (see the sidebar).
  3. Restart your client and add a rule to its system prompt or CLAUDE.md telling it to use Context7 for library and API documentation, so it reaches for it proactively.
  4. Ask it a docs question about a library you use to confirm it's fetching current results.

Related assets