All tools
HarnessCommunity30k

Context7 MCP

Updated Jul 7, 2026

An MCP server by Upstash that fetches current, version-pinned library documentation into the agent's context when needed. Eliminates the stale-training-data problem for fast-moving libraries: Claude answers with the real API as it exists today. Ships two integration modes — MCP (native tool calls) and CLI+Skills (ctx7 CLI commands, more token-efficient). Works with Claude Code, Cursor, and others.

View on GitHub

What it does

  • npx ctx7 setup --claude

    Interactive setup: authenticates via OAuth, generates an API key, and installs Context7 for Claude Code in either MCP or CLI+Skills mode.

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

    Manually register the hosted Context7 MCP HTTP endpoint in Claude Code — no local install needed.

  • resolve-library-id

    MCP tool that resolves a general library name (e.g. "next.js") to a Context7-compatible library ID for use in query-docs.

  • query-docs

    MCP tool that fetches up-to-date documentation for a library by its Context7 ID, filtered to a specific query.

  • ctx7 docs <libraryId> <query>

    CLI command (Skills mode) that retrieves documentation for a library ID, called by the installed skill instead of MCP tools.

Files (1)

OVERVIEW.mdprimary · markdown · 1.8 KB
## What it does

Context7 resolves library documentation at request time against a live index of versioned package docs. When you append "use context7" to a prompt, or ask about a library in a session where a Context7 rule is configured, the tool fetches current docs and injects them before Claude composes its answer. The result is answers grounded in the real, current API rather than training-cutoff knowledge.

Two integration modes:
- **MCP mode** — registers a Context7 MCP server; Claude calls `resolve-library-id` and `query-docs` natively as tool calls
- **CLI+Skills mode** — installs the `ctx7` CLI and a skill that guides Claude to call `ctx7 library` and `ctx7 docs` commands; more token-efficient than MCP for coding agents

## Install

The fastest setup path is the interactive CLI, which authenticates via OAuth, generates an API key, and installs the appropriate mode:

npx ctx7 setup

To target Claude Code specifically: npx ctx7 setup --claude

To configure the MCP server manually in Claude Code:
claude mcp add --transport http context7 https://mcp.context7.com/mcp

A free API key (higher rate limits) is available at context7.com/dashboard. Pass it via the CONTEXT7_API_KEY header.

## MCP tools (MCP mode)

resolve-library-id — resolves a library name to a Context7-compatible ID (e.g. /vercel/next.js)

query-docs — fetches documentation for a library ID filtered to a specific query

## CLI commands (CLI+Skills mode)

ctx7 library <name> <query> — search the index by name and return matching library IDs

ctx7 docs <libraryId> <query> — retrieve documentation for a library

## When to use

Append "use context7" to any prompt asking about a library API or SDK — especially for fast-moving packages like Next.js, React, or Supabase where training data is quickly outdated. Add a CLAUDE.md rule to trigger it automatically without explicit prompting.