🔌

Context7 MCP

Documentation58,900

Real-time, version-specific code documentation for LLMs and AI code editors, eliminating outdated API references.

Claude DesktopCursorClaude CodeVS CodeWindsurf

Overview

Real-time, version-specific code documentation for LLMs and AI code editors, eliminating outdated API references.

Setup

Run with npx:

npx ctx7 setup

Configuration

OAuth authentication via setup, then add MCP server configuration with API key

Documentation

Context7 MCP

Overview

Context7 is a platform that provides real-time, version-specific code documentation for LLMs and AI code editors, addressing the common problem of outdated or hallucinated library information in AI-generated code. With over 58,000 GitHub stars, it has become an essential MCP server for developers who need accurate, up-to-date API references during coding sessions.

Context7 solves a critical pain point in AI-assisted development: LLMs often generate code using outdated APIs or incorrect library versions. By fetching live documentation and examples directly into prompts, Context7 ensures that AI agents work with the most current information available, significantly reducing debugging time and code quality issues.

The platform offers two integration modes: CLI with Skills for agent-guided workflows, and native MCP tools for seamless integration with coding agents like Claude Code, Cursor, and VS Code.

Features

  • Real-time Documentation: Fetches live docs and examples directly into prompts
  • Version-Specific Content: Targets specific library versions (e.g., "Next.js 14")
  • Library IDs: Easy reference to popular libraries (e.g., supabase/supabase)
  • CLI Mode: ctx7 docs <libraryId> for direct documentation access
  • MCP Tools: Native query-docs tool for agent integration
  • Multi-Agent Support: Works with Claude Desktop, Cursor, Windsurf, VS Code
  • OAuth Authentication: Secure authentication via OAuth flow
  • Offline Cache: Cached documentation for faster access
  • Broad Library Coverage: Supports hundreds of popular libraries and frameworks

Installation

Quick Setup

# Install and configure Context7
npx ctx7 setup

The setup process:

  1. Authenticates via OAuth
  2. Generates an API key
  3. Configures tools for your agent platform
  4. Sets up MCP server configuration

Manual Configuration

Add to your MCP configuration file:

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["@upstash/context7-mcp"],
      "env": {
        "CONTEXT7_API_KEY": "your-api-key"
      }
    }
  }
}

Available Tools

ToolDescription
query-docsQuery live documentation for a specific library and version
get-examplesGet code examples for a specific API or feature
list-librariesList available libraries with documentation
get-version-infoGet available versions for a library

Usage Examples

CLI Usage

# Get documentation for Next.js 14
ctx7 docs nextjs --version 14

# Get Supabase documentation
ctx7 docs supabase/supabase

# Get examples for a specific feature
ctx7 examples "nextjs middleware jwt"

Agent Usage

User: "Create a Next.js middleware with JWT validation"
Agent: Uses Context7 query-docs to get current Next.js auth patterns
Agent: "Creating middleware with current Next.js 14 patterns..."

User: "Configure Cloudflare Worker caching"
Agent: Fetches up-to-date Cloudflare documentation
Agent: "Setting up caching with current Cloudflare Worker API..."

MCP Tool Usage

{
  "tool": "query-docs",
  "parameters": {
    "libraryId": "nextjs",
    "version": "14",
    "query": "middleware jwt authentication"
  }
}

Advanced Features

Version Targeting

# Get specific version documentation
ctx7 docs react --version 18.3

# Get latest version
ctx7 docs react --version latest

# Compare versions
ctx7 docs nextjs --compare 13,14

Example Generation

# Get code examples for a feature
ctx7 examples "expressjs error handling"

# Get TypeScript examples
ctx7 examples "typescript generics" --language typescript

# Get multiple examples
ctx7 examples "react hooks" --limit 5

Library Discovery

# Search for libraries
ctx7 search "database ORM"

# List available libraries
ctx7 list

# Get library details
ctx7 info supabase/supabase

Claude Desktop Setup

  1. Run npx ctx7 setup to authenticate and get API key
  2. Add Context7 MCP server to Claude Desktop configuration
  3. Restart Claude Desktop
  4. Documentation tools will be available in conversations

Cursor Setup

  1. Install Context7 via npx ctx7 setup
  2. Add to Cursor MCP settings
  3. Restart Cursor
  4. Use @docs command in chat to query documentation

Pros

  • ✅ Eliminates tab-switching for documentation lookups
  • ✅ Ensures accurate, version-specific API references
  • ✅ Reduces AI hallucination about library APIs
  • ✅ Works with multiple agent platforms
  • ✅ Simple OAuth-based authentication
  • ✅ Large library coverage
  • ✅ Active development with 58,000+ stars

Cons

  • ❌ Requires API key and authentication setup
  • ❌ Community-maintained docs may vary in quality
  • ❌ Private backend components not fully open-source
  • ❌ Network dependency for live documentation
  • ❌ Some niche libraries may lack coverage

When to Use

Context7 MCP is ideal for:

  • AI-Assisted Development: Ensure AI agents use current APIs
  • Multi-Framework Projects: Access documentation for many libraries
  • Version Migration: Get version-specific documentation for upgrades
  • Code Review: Verify AI-generated code against current best practices
  • Learning: Explore new libraries with AI-assisted documentation
  • Enterprise Development: Reduce errors from outdated AI knowledge

Resources