Skip to main content
Context7 Hero

Context7 - Up-to-date Code Docs For Any Prompt

Context7 provides an MCP server and SDK for accessing up-to-date, version-specific documentation and code examples for any programming library or framework. Stop getting outdated code from AI assistants - Context7 pulls fresh documentation directly into your LLM’s context.

The Problem

LLMs rely on outdated or generic information about the libraries you use:
  • Code examples are outdated and based on year-old training data
  • Hallucinated APIs that don’t even exist
  • Generic answers for old package versions

The Solution

Context7 MCP pulls up-to-date, version-specific documentation and code examples straight from the source and places them directly into your prompt. Add use context7 to your prompt (or set up a rule to auto-invoke):
Create a Next.js middleware that checks for a valid JWT in cookies
and redirects unauthenticated users to `/login`. use context7
Configure a Cloudflare Worker script to cache
JSON API responses for five minutes. use context7
Context7 fetches up-to-date code examples and documentation right into your LLM’s context. No tab-switching, no hallucinated APIs that don’t exist, no outdated code generation.

Key Features

MCP Server Integration

Connect Context7 to Cursor, Claude Code, OpenCode, and 30+ other AI coding assistants

TypeScript SDK

Programmatic access to Context7’s documentation API with full TypeScript support

CLI Tools

Quick setup with ctx7 CLI for authentication and MCP configuration

AI SDK Tools

Pre-built tools for Vercel AI SDK with automatic library resolution

Available Tools

Context7 MCP provides two main tools that LLMs can use:

resolve-library-id

Resolves a general library name into a Context7-compatible library ID.
  • query - The user’s question or task (used to rank results by relevance)
  • libraryName - The name of the library to search for
Returns matching libraries with:
  • Library ID in format /org/project
  • Name and description
  • Code snippets count
  • Source reputation (High, Medium, Low, Unknown)
  • Benchmark score (quality indicator, max 100)
  • Available versions

query-docs

Retrieves documentation for a library using a Context7-compatible library ID.
  • libraryId - Exact Context7-compatible library ID (e.g., /mongodb/docs, /vercel/next.js)
  • query - The question or task to get relevant documentation for
Returns up-to-date documentation and code examples specific to your query.

Use Cases

  • AI Coding Assistants: Cursor, Claude Code, OpenCode, and more
  • Custom AI Agents: Build agents with access to current library docs
  • Documentation Automation: Fetch fresh docs programmatically
  • Code Generation: Generate code with accurate, version-specific APIs

Next Steps

Quickstart

Get Context7 running in your AI coding assistant in under 5 minutes

Installation Guide

Detailed installation instructions for all components

Build docs developers (and LLMs) love