# Context7 MCP server

> Fetches up-to-date, version-specific library documentation and code examples into an AI coding agent's context.

- Repository: https://github.com/upstash/context7
- Page: https://hostedmcp.org/servers/upstash/context7
- Transport: stdio, remote
- Stars: 64810
- License: MIT
- Latest version: 4.7.0

## Install

### Claude Code

```sh
claude mcp add --env 'CONTEXT7_API_KEY=<YOUR_CONTEXT7_API_KEY>' context7 -- npx -y @upstash/context7-mcp
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp"
      ],
      "env": {
        "CONTEXT7_API_KEY": "<YOUR_CONTEXT7_API_KEY>"
      }
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "context7": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp"
      ],
      "env": {
        "CONTEXT7_API_KEY": "<YOUR_CONTEXT7_API_KEY>"
      }
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"context7","type":"stdio","command":"npx","args":["-y","@upstash/context7-mcp"],"env":{"CONTEXT7_API_KEY":"<YOUR_CONTEXT7_API_KEY>"}}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp"
      ],
      "env": {
        "CONTEXT7_API_KEY": "<YOUR_CONTEXT7_API_KEY>"
      }
    }
  }
}
```

### Codex

```sh
codex mcp add context7 --env 'CONTEXT7_API_KEY=<YOUR_CONTEXT7_API_KEY>' --env 'CONTEXT7_API_KEY=<YOUR_CONTEXT7_API_KEY>' -- npx -y @upstash/context7-mcp
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]

[mcp_servers.context7.env]
CONTEXT7_API_KEY = "<YOUR_CONTEXT7_API_KEY>"
```

### Gemini CLI

```sh
gemini mcp add -s user -e 'CONTEXT7_API_KEY=<YOUR_CONTEXT7_API_KEY>' -e 'CONTEXT7_API_KEY=<YOUR_CONTEXT7_API_KEY>' context7 npx -- -y @upstash/context7-mcp
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "context7": {
      "command": "npx",
      "args": [
        "-y",
        "@upstash/context7-mcp"
      ],
      "env": {
        "CONTEXT7_API_KEY": "<YOUR_CONTEXT7_API_KEY>"
      }
    }
  }
}
```

## Environment variables

| Name | Required | Secret | Description |
|---|---|---|---|
| `CONTEXT7_API_KEY` | no | yes | API key for authentication |
| `CONTEXT7_API_KEY` | no | yes | API key for authentication |

## Tools (2)

- `resolve-library-id`
- `query-docs`

## FAQ

### What does Context7 do for AI coding agents?

It pulls current, version-specific documentation and code examples from the source and injects them into your agent's context, reducing outdated or hallucinated APIs.

### How do I install Context7?

Run the ctx7 setup command, which requires Node.js 22.13 or newer and lets you choose CLI + Skills or MCP mode.

### Which MCP tools does Context7 provide?

It provides resolve-library-id to turn a library name into a Context7 ID and query-docs to retrieve documentation for that ID.

### How do I get documentation for a specific library version?

Mention the version in your prompt and Context7 will match the appropriate version automatically.

### How do I authenticate with the Context7 MCP server?

Get a free API key from the dashboard and pass it in the Authorization Bearer header when connecting to the server URL.
