Context7 (Documentation Database) MCP server

Connects to Context7.com's documentation database to provide up-to-date library and framework documentation with intelligent project ranking and customizable token limits.
Back to servers
Provider
Upstash
Release date
Apr 13, 2025
Language
TypeScript
Package
Stats
311.5K downloads
8.8K stars

Context7 MCP brings up-to-date documentation and code examples directly into your LLM prompts. Instead of relying on outdated training data, Context7 fetches current, version-specific documentation from the source and places it into your prompt context, ensuring you get accurate answers based on the latest API information.

Why Use Context7 MCP

Problem

  • Outdated code examples based on old training data
  • Hallucinated APIs that don't exist
  • Generic answers for deprecated package versions

Solution

Context7 MCP integrates directly into your workflow:

  • Ask your question naturally
  • Include "use context7" in your prompt
  • Get working code answers based on current documentation

For example:

How do I use the new Next.js `after` function? use context7
How do I invalidate a query in React Query? use context7
How do I protect a route with NextAuth? use context7

Installation

Requirements

  • Node.js >= v18.0.0
  • An MCP client (Cursor, Windsurf, Claude Desktop, etc.)

Setting Up in Cursor

  1. Navigate to Settings -> Cursor Settings -> MCP -> Add new global MCP server
  2. Add the following to your ~/.cursor/mcp.json file:
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": ["-y", "@upstash/context7-mcp"]
    }
  }
}

Setting Up in Windsurf

Add the following to your Windsurf MCP config file:

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

Using Context7 MCP

Context7 MCP provides two main tools:

resolve-library-id

This tool resolves a general library name into a Context7-compatible library ID.

Parameters:

  • libraryName (optional): Search and rerank results

get-library-docs

This tool fetches documentation for a library using a Context7-compatible library ID.

Parameters:

  • context7CompatibleLibraryID (required): The library ID
  • topic (optional): Focus the docs on a specific topic (e.g., "routing", "hooks")
  • tokens (optional, default 5000): Maximum number of tokens to return

Testing Your Installation

You can verify your installation is working correctly using the MCP Inspector:

npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later