Context7 MCP server

OfficialUpstash56,525Config last verified Jun 1, 2026

Pulls version-accurate library docs and code examples into your agent's context on demand.

Context7 is Upstash's documentation retrieval server that solves a specific failure mode of coding agents: hallucinated or stale API usage. When an agent is about to write code against a library, it first resolves the library to a Context7 ID, then fetches focused, version-pinned documentation snippets for the exact topic at hand. The docs are indexed from upstream sources and kept current, so the model writes against the API that actually ships rather than the one it half-remembers from training.

The server runs locally over stdio via npx and can also be reached as a hosted remote endpoint. A free Context7 API key raises rate limits and is passed either as an argument or through the CONTEXT7_API_KEY environment variable. Because the two tools it exposes are deliberately narrow, it composes cleanly with reasoning and version-control servers without flooding the context window.

Quick install

Copy-paste configs are provided for all 8 supported clients. Pick your client below.

Add to ~/.claude.json

~/.claude.json
json
{
  "mcpServers": {
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "Authorization": "Bearer <CONTEXT7_API_KEY>"
      }
    }
  }
}
Or via CLI
bash
claude mcp add --transport http context7 https://mcp.context7.com/mcp

Available tools

ToolDescription
resolve-library-idResolves a package or product name into a Context7-compatible library ID, ranking matches by the user's query.
query-docsRetrieves up-to-date documentation and code examples from Context7 for a resolved library ID, scoped to the user's question.

Required configuration

  • CONTEXT7_API_KEYOptional

    Optional API key that raises rate limits; passable as --api-key arg or env var.

What you can do with it

Stop API hallucinations

Before writing code against a framework, the agent fetches the current docs so it calls real, present-tense APIs instead of guessing from stale training data.

Onboard to an unfamiliar library

Ask for usage of a specific feature and Context7 returns just the relevant snippets, keeping the context window lean while the agent works.

FAQ

Is it free?
Yes. The server is open source and free to run; an optional free API key from Upstash raises rate limits.
Does it support remote/OAuth?
It offers a hosted Streamable HTTP endpoint at https://mcp.context7.com/mcp authenticated with a bearer API key. The local stdio mode uses an API key rather than OAuth.
← Browse all docs-and-context servers