Context7 MCP Server

Context7 MCP server provides up-to-date, version-specific code documentation directly in LLM context, preventing hallucinated APIs and outdated code generation.

May 3, 2025
MCP ServerDevelopment Tools & DevOpsContext7 MCP Server
GitHub starsnpm version

Overview

Context7 solves one of the biggest problems with AI code generation: LLMs generate code using outdated APIs or libraries that don't exist. Context7 pulls up-to-date, version-specific documentation and code examples from over 9,000 libraries and places them directly into the LLM's context window.

Upstash Project:

Developed and maintained by Upstash

Key Features

📚

Version-Specific Docs

Get documentation for exact library versions — not year-old training data

🧠

Hallucination Prevention

Eliminate hallucinated APIs by grounding code generation in real documentation

📦

9,000+ Libraries

Covers React, Next.js, Supabase, Tailwind, Prisma, Python, Go, Rust, and thousands more

🔌

Dual Mode

Use as CLI + Skills for lightweight setup or as native MCP server for tool integration

One-Command Setup

Single npx ctx7 setup installs everything — skill, API key, configuration

🌐

30+ Client Support

Works with Cursor, Claude Code, VS Code, Windsurf, Cline, Roo Code, and more

Available Tools

Quick Reference

ToolPurposeCategory
resolve-library-idFind the Context7 ID for a library by nameDiscovery
query-docsRetrieve version-specific docs for a libraryDocumentation

Detailed Usage

resolve-library-id

Resolve a library name to its Context7 ID for use with query-docs.

{
  "libraryName": "supabase",
  "query": "authentication setup"
}
query-docs

Retrieve relevant documentation and code examples for a specific library.

{
  "libraryId": "/supabase/supabase",
  "query": "How to implement Row Level Security policies"
}

How It Works

Instead of LLMs guessing API signatures from outdated training data, Context7 injects real, version-specific documentation into the prompt context. Your agent sees actual code examples, parameter signatures, and configuration patterns — not hallucinations.

Without Context7:

  • LLM generates createClient() with wrong parameters
  • Uses deprecated middleware API from Next.js 12
  • Invents Supabase methods that don't exist

With Context7:

  • LLM sees the current createClient() signature from latest docs
  • Uses middleware.ts pattern from Next.js 14 docs
  • Calls real Supabase auth methods verified against source

Installation

npx ctx7 setup

Authenticates via OAuth, generates an API key, and installs the appropriate skill. Use --cursor, --claude, or --opencode to target a specific agent.

API Key:

Get a free API key at context7.com/dashboard for higher rate limits.

Usage Tips

  • Use library IDs directly: Mention /supabase/supabase in your prompt to skip library matching
  • Specify versions: Say "Next.js 14" to get version-specific docs
  • Add a rule: Set a Cursor rule or CLAUDE.md entry: "Always use Context7 when I need library documentation"

Sources