deliberate.codes

Weblog of Marco N. - a software guy in data. I build with AI.

Using Context7 MCP for up-to-date library documentation

LLMs have stale training data. When working with Next.js 15, React 19, or any library that evolved after the model’s cutoff date, you get hallucinated APIs and deprecated patterns.

Context7 solves this by pulling version-specific documentation directly into your prompt.

Setup with Claude Code#

claude mcp add context7 npx -y @upstash/context7-mcp@latest

For higher rate limits, get a free API key at context7.com/dashboard and add it:

claude mcp add context7 npx \
  -y @upstash/context7-mcp@latest \
  -e CONTEXT7_API_KEY=your-api-key

Usage#

Add “use context7” to your prompt:

Use context7. How do I set up middleware in Next.js 15?

Context7 will fetch current documentation before the model responds.

How it works#

Two tools power it:

ToolPurpose
resolve-library-idMatches library names to Context7 IDs (e.g., “next.js” → “/vercel/next.js/v15.0.0”)
get-library-docsFetches documentation chunks and code examples (default 5000 tokens)

The documentation comes directly from official sources, ranked by trust score and coverage.