home / mcp / context7 mcp server

Context7 MCP Server

Context7 MCP Server -- Up-to-date code documentation for LLMs and AI code editors

Installation
Add the following to your MCP client configuration file.

Configuration

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

Context7 MCP provides up-to-date, library-specific code documentation and examples directly in your prompts. It helps your coding assistants fetch current APIs, versioned docs, and concrete code snippets without leaving your editor or re-asking for sources.

How to use

You can enable Context7 MCP in your prompts to automatically fetch the latest library docs and code examples. Use cases include generating setup steps, finding correct API usage, and getting version-aware guidance without manual lookup.

How to install

Prerequisites: ensure you have Node.js and npm installed on your machine. You can verify by running node -v and npm -v in your terminal.

HTTP remote server connection

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

STDIO local server connection

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

Install with ctx7 setup

Set up Context7 MCP for your coding agents by running the setup command. This authenticates you, generates an API key, and configures the MCP server and rules for your agents. You can target a specific agent with setup options.

OAuth authentication and other clients

If you use OAuth, point your client to the OAuth endpoint to obtain tokens and enable secure access. For local connections using stdio transport, use API key authentication instead.

Security and keys

Protect your CONTEXT7_API_KEY. Use environment isolation and do not commit keys to public repositories. Rotate keys if you suspect exposure.

Troubleshooting and tips

If prompts fail to fetch docs, verify your API key, confirm the MCP URL, and ensure the library you request exists in Context7. You can also configure a rule in your MCP client to automatically invoke Context7 for coding questions.

Notes

Context7 MCP supports multiple clients and configurations. The remote HTTP configuration is the default approach, while local stdio connections provide a backend-ready option for development environments.

Available tools and endpoints

Context7 MCP exposes a pair of core tools to assist your prompts:

- resolve-library-id: Converts a library name into a Context7-compatible library ID to locate the right docs.

- query-docs: Fetches documentation for a specific library by library ID to return precise, context-aware information.

Available tools

resolve-library-id

Resolves a general library name into a Context7-compatible library ID to rank results by relevance.

query-docs

Retrieves documentation for a library using a Context7-compatible library ID.