# Connect Context7 to Claude Code

> One command gives Claude Code the current documentation for the libraries you use, so its answers match the version you have, not the one it remembers.

- **For:** Anyone who uses Claude Code to write or change code that depends on libraries and frameworks
- **Outcome:** Claude Code that looks up a library's current docs when you ask, and a check that proves it did
- **Time:** 5 minutes
- **Last verified:** 2026-10-24
- **Tested with:** Claude Code 2.1.310, macOS 26.5, Context7 hosted server 4.4.3

Claude Code knows a lot about popular libraries, but what it knows has a date on it. When a framework renames something (Next.js 16 renamed Middleware to Proxy), Claude can confidently write the old way. Context7 is an MCP server that fetches the current docs for a library, for the version you name, while Claude is answering. Adding it takes one command, and you don't need an account or a key.

## Give this to Claude

```claude text="Claude Code checks your version, makes sure Context7 isn't already set up, adds it for your user account and shows you the line that says it connected. It changes nothing else." where="Paste it into Claude Code, opened in any folder."
Connect the Context7 MCP server to Claude Code for my user account, then check it works.

1. Run `claude --version` and tell me the version.
2. Run `claude mcp list`. If a server called context7 is already listed, stop and tell me: don't add a second one.
3. Run this, exactly: claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp
4. Run `claude mcp list` again and show me the line for context7. It should end in "✔ Connected". If it says "Failed to connect", stop and tell me; that is usually a network or proxy problem, not the command.
5. Tell me to start a new Claude Code session so the new tools load, and give me one prompt to try in it: How do I set up a proxy in Next.js 16? use context7

Don't add an API key and don't change any other setting.
```

## Steps

### 1. Check Claude Code is installed

Open a terminal and run:

```bash label="Run in your terminal"
claude --version
```

You should see a version number, like `2.1.310 (Claude Code)`. If you see "command not found", install Claude Code first and sign in.

### 2. See what is connected now

```bash label="Run in your terminal"
claude mcp list
```

On a new setup this prints `No MCP servers configured.` If you already see a line with context7 in it, it is set up: skip to step 5.

### 3. Add Context7

This adds the hosted Context7 server for your user account, so it works in every project on this computer:

```bash label="Run in your terminal"
claude mcp add --scope user --transport http context7 https://mcp.context7.com/mcp
```

It answers:

```output label="What you should see"
Added HTTP MCP server context7 with URL: https://mcp.context7.com/mcp to user config
File modified: /Users/you/.claude.json
```

The `--scope user` part is what makes it work everywhere. Leave it out and Claude Code adds it to the current folder only.

### 4. Check the connection

```bash label="Run in your terminal"
claude mcp list
```

The line for Context7 should end in a tick:

```output label="What you should see"
context7: https://mcp.context7.com/mcp (HTTP) - ✔ Connected
```

### 5. Check Claude Code uses it

Start a new Claude Code session (the tools load when a session starts) and ask something whose answer changed recently. Add "use context7" so it knows to look:

```text label="Paste into a new Claude Code session"
How do I set up a proxy in Next.js 16? use context7
```

In the session you'll see two tool calls before the answer: `resolve-library-id` (Context7 finding the library) and `query-docs` (reading its docs). If both appear, it is working. On the clean run for this page (24 October 2026) the answer opened with "In Next.js 16, Middleware has been renamed to Proxy", which is the current behaviour.

## If something goes wrong

### "✘ Failed to connect"

The command was right; your computer couldn't reach mcp.context7.com. This is usually a company network, a VPN or a proxy. Try another network to confirm, then ask whoever runs your network to allow the address.

### Context7 is already there under another name

`claude mcp list` may show `claude.ai Context7` (a connector from your claude.ai account) or `plugin:context7:context7` (from a Claude Code plugin). Either one already gives Claude Code Context7. Don't add a second one; use what you have. The plugin's entry may say "Needs authentication": type `/mcp` in a session and sign in from there.

### "Pending approval" next to other servers

If you run `claude mcp list` inside a project that has its own `.mcp.json`, you'll see that project's servers too, marked "Pending approval" until you allow them. They aren't Context7 and don't affect it.

### Claude answers without calling Context7

Check you started a new session after adding it, and that your prompt includes "use context7". To make it automatic, add one line to your project's `CLAUDE.md`: "Use Context7 when you need library or API documentation."

### It works, then stops answering for a while

The free, keyless service has rate limits. If you use it heavily, create a free API key at context7.com and add it with the header option in Context7's own instructions. Paste the key into your terminal only, never into a chat.

## Common mistakes

- **Leaving out `--scope user`.** The server is then added for the folder you were in, and seems to vanish in every other project.
- **Testing in the same session.** Tools load when a session starts. Start a new one after adding it.
- **Pasting an API key into Claude.** You don't need one to start. If you add one later, type it in your own terminal.
- **Running `claude mcp get` for a screenshot.** It prints the server's settings in full, including any key you added. Use `claude mcp list` instead.

## Remove it

One command undoes it:

```bash label="Run in your terminal"
claude mcp remove --scope user context7
```

Source: https://inspiredworkx.com/library/guide/connect-context7-to-claude-code
