Back to MCP Servers

Context7 MCP Server

Up-to-date, version-specific library documentation and code examples pulled directly from source and injected into your LLM prompt.

Developer Tools by Upstash API Key active
Overview

Context7 is a documentation platform built by Upstash that fetches up-to-date, version-specific documentation and code examples for libraries straight from the source, then places them directly into an LLM's context window. It exists because models routinely produce outdated APIs, hallucinated method signatures, or generic answers drawn from older training data. By calling Context7 mid-conversation, an AI coding agent can ground its answers in the actual current docs for whatever library is being discussed.

The MCP server exposes two tools: resolve-library-id, which maps a free-form library name (like "next.js" or "mongodb") to a Context7-compatible library ID, and query-docs, which retrieves relevant documentation snippets for that library based on the user's question or task. Context7 is available both as a remote provider-hosted MCP server at https://mcp.context7.com/mcp and as a local stdio server via the @upstash/context7-mcp npm package.

The MCP server code is open source under MIT, while the supporting parsing, ranking, and crawling backend is proprietary and run by Upstash. A free API key from context7.com/dashboard is recommended for higher rate limits. Library documentation entries are community-contributed, so accuracy and completeness vary by library.

Tools

Tool Description
resolve-library-id Resolves a general library name into a Context7-compatible library ID for use with query-docs.
query-docs Retrieves up-to-date, version-specific documentation snippets and code examples for a library.
Setup Guide

Quick setup (recommended)

Run the automated installer, which handles OAuth, API key generation, and client-specific configuration:

npx ctx7 setup

You can target a specific client with --cursor, --claude, or --opencode.

Manual setup

Get a free API key at context7.com/dashboard, then add one of the following config blocks.

Claude Desktop (local stdio)

{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
    }
  }
}

Cursor (remote)

{
  "mcpServers": {
    "context7": {
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "CONTEXT7_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

VS Code (remote)

{
  "servers": {
    "context7": {
      "type": "http",
      "url": "https://mcp.context7.com/mcp",
      "headers": {
        "CONTEXT7_API_KEY": "YOUR_API_KEY"
      }
    }
  }
}

VS Code (local stdio)

{
  "servers": {
    "context7": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp", "--api-key", "YOUR_API_KEY"]
    }
  }
}

Prerequisites

  • Node.js 18+ (for local stdio usage via npx)
  • A Context7 API key (free tier available at context7.com/dashboard)
Use Cases
  • Ground an AI coding assistant in the actual current API of a library before it writes code, eliminating hallucinated method signatures.
  • Pull version-specific examples for frameworks like Next.js, React, MongoDB, or Supabase directly into a Cursor or Claude Desktop session.
  • Verify breaking changes between library versions while migrating a codebase, by querying docs for the target version.
  • Provide an agent with authoritative reference snippets for less-popular libraries that are underrepresented in model training data.
  • Reduce context burn by retrieving only the doc sections relevant to the current question instead of dumping entire READMEs.
Example Prompts
  • "Use Context7 to look up the current Next.js 15 App Router middleware API and show me an auth example."
  • "Resolve the library ID for drizzle-orm and fetch docs on defining a one-to-many relation."
  • "Get the latest Supabase Realtime channel subscription example from Context7."
  • "Look up MongoDB aggregation pipeline $lookup syntax via Context7 and rewrite this query."
  • "Pull the current Stripe Node SDK docs for creating a subscription with a trial period."
Pros
  • Solves a real, common LLM failure mode (stale or hallucinated library APIs) with a focused two-tool surface.
  • Available as both a remote provider-hosted endpoint and a local npm package, so it works with virtually any MCP client.
  • Free tier with optional API key for higher rate limits; MCP server code is MIT-licensed and open source.
  • Maintained by Upstash with first-party setup tooling (npx ctx7 setup) for Cursor, Claude, and OpenCode.
Limitations
  • Library entries are community-contributed, so accuracy, completeness, and freshness vary by library.
  • Coverage depends on whether a library has been indexed by Context7; obscure or private libraries may not be available.
  • Backend parsing and crawling engine is proprietary, so self-hosting the full stack is not possible.
Alternatives
  • GitMCP — turns any public GitHub repo into an MCP documentation server.
  • DeepWiki MCP — Devin's AI-generated repo wikis, exposed via MCP for code Q&A.
  • Ref — an alternative documentation-retrieval MCP server focused on developer reference material.