Context7 MCP Server

Official

Kill hallucinated APIs — version-accurate, up-to-date library documentation injected straight into context.

Local + remotestdiostreamable-httpTypeScriptMIT 32.0k

What is the Context7 MCP server?

Every developer using AI assistants knows the failure mode: confident code against an API that changed two majors ago, imports from packages that don't exist, config options the library never had. The model's training data froze; the ecosystem didn't. Context7 attacks exactly this — on request, it pulls current, version-specific documentation and working code examples for the library you're using and injects them into the model's context.

The workflow is almost invisible, which is its charm. Add "use context7" to a prompt (or let your client's rules invoke it automatically) and the assistant first resolves the library — Next.js 15, say, not Next.js-in-general — then fetches focused documentation for the topic at hand before answering. The difference shows immediately with fast-moving frameworks: App Router idioms instead of pages-directory fossils, current Tailwind syntax, today's Supabase client instead of 2023's.

Under the hood, Upstash maintains parsed, indexed documentation for tens of thousands of libraries, refreshed continuously. The two tools are appropriately boring: resolve-library-id finds the right library, get-library-docs fetches docs for it, optionally scoped to a topic like "routing" or "authentication".

It's free for personal use without an API key, though creating one raises rate limits. Available remotely (mcp.context7.com) or locally via npm. If you install only one documentation-related MCP server, this is the category winner — cheap to run, zero workflow disruption, and it fixes the single most common way AI coding assistance goes wrong.

What trips people up

  • Resolution sometimes lands on a similarly named package. If you already know the ID — /vercel/next.js, /supabase/supabase — hand it over directly and skip the lookup step; version-pinned IDs work the same way.
  • The topic argument matters more than people expect. "Routing" or "middleware" returns a tight, usable slice, while omitting it returns a broad overview that crowds your own code out of context.
  • Typing "use context7" on every prompt gets old fast. Put the instruction in your Cursor rules or CLAUDE.md and it fires whenever the model reaches for library specifics.
  • Private and internal packages aren't in the index. Public repos can be submitted on context7.com, and a context7.json at the repo root tunes how yours gets parsed.

What you can do with it

Stop API hallucinations

Code generation grounded in the library's actual current API instead of training-data memories.

Version-correct upgrades

Ask migration questions with the real changelog and new API in context.

Learn unfamiliar libraries fast

Current examples for the exact version in your package.json, not blog posts from three versions ago.

Available tools

ToolWhat it does
resolve-library-idMatch a library name to Context7's index (e.g. 'nextjs' → /vercel/next.js)
get-library-docsFetch current docs for a library, optionally scoped to a topic

How to install the Context7 MCP server

claude mcp add --transport http context7 https://mcp.context7.com/mcp

Add an API key header for higher rate limits: --header "CONTEXT7_API_KEY: your-key".

Configuration

None for the remote server at light usage. Optional free API key for higher limits; Node.js 18+ if running locally.

VariableDescriptionRequired
CONTEXT7_API_KEYOptional key from context7.com for higher rate limitsOptional

Example prompts to try

  • use context7 — set up NextAuth v5 with a credentials provider in Next.js 15.
  • use context7 — what's the current way to do optimistic updates in TanStack Query?
  • Pull the latest Drizzle ORM docs on migrations and update this schema file accordingly.

Frequently asked questions

It fetches the library's real, current documentation at question time and injects it into context, so the model answers from today's API surface instead of stale training data. Version-specific docs are the whole point.