# Is the Context7 MCP server safe? What it can reach

> The Context7 MCP server fetches library docs for your AI agent. See who runs it, what it sends, its two tools and how to limit it in Claude Code and Codex.

The Context7 MCP server is maintained by Upstash. It looks up current library documentation for an AI agent through two tools, `resolve-library-id` and `query-docs`. It has no write or delete tools and no access to your files. The main risk is that documentation text comes from third-party sources and can carry instructions an agent might follow. The README says Upstash cannot guarantee the accuracy, completeness or security of all library documentation.

## Who runs it and where

The repo is [upstash/context7](https://github.com/upstash/context7). It holds the MCP server source, published as the npm package `@upstash/context7-mcp`. The README says the API backend, parsing engine and crawling engine are private and not part of the repository. You can connect to Upstash’s hosted server at `https://mcp.context7.com/mcp` or run the npm package locally. Either way the documentation comes from Context7’s service.

## How it signs in

The README shows an API key passed as an `Authorization: Bearer YOUR_API_KEY` header. It says a free key from the dashboard raises rate limits. The README doesn’t say whether a key is required to use the server at all, so check the current docs when you set it up. It also doesn’t document a `CONTEXT7_API_KEY` environment variable, so don’t assume one.

## What the tools can do

| Tool | Inputs | Effect |
| --- | --- | --- |
| `resolve-library-id` | `query`, `libraryName` (both required) | Finds the library ID for a name |
| `query-docs` | `libraryId`, `query` (required), `language` (optional) | Returns documentation and code examples, with the language used to rank examples |

Both tools read. Neither changes anything on your Mac or in your accounts. The README doesn’t describe in detail what is sent to Context7 beyond these inputs. Treat your `query` text as leaving your machine, because it goes to the service. If your agent writes the query from private code or a proprietary name, that text goes with it. The README also doesn’t say whether private repositories are supported.

## Risks that remain

- Prompt injection through documentation. Library docs, READMEs and examples are written by many people, and an agent reads them into its context. The README tells users to report suspicious content with its Report button.
- Over-trust. The documentation can be wrong or out of date, and code the agent writes from it may be too.
- Query leakage. A search for an internal package name tells the service that name exists.
- A bearer token in config. If you put an API key in `.mcp.json` and commit the file, the key travels with it.

## Limit it in Claude Code

```bash
claude mcp add --transport http context7 https://mcp.context7.com/mcp
```

Add `--header "Authorization: Bearer your-key"` if you use a key. Claude Code stores the server in `~/.claude.json` for the current project by default. `--scope project` writes it to `.mcp.json`, which your team shares, and `--scope user` makes it available in all your projects. Since both tools only read, you can auto-approve them and deny nothing else.

```json
{
  "permissions": {
    "allow": ["mcp__context7__resolve-library-id", "mcp__context7__query-docs"]
  }
}
```

Settings go in `.claude/settings.json` or `~/.claude/settings.json`. Use `${VAR}` references in `.mcp.json` rather than pasting a key.

## Limit it in Codex

The Codex docs show Context7 as their stdio example. Use `enabled_tools` to pin the two tools:

```toml
[mcp_servers.context7]
command = "npx"
args = ["-y", "@upstash/context7-mcp"]
enabled_tools = ["resolve-library-id", "query-docs"]
```

## Checklist

1. Use only the two documented tools.
2. Keep any API key in an environment variable, out of committed files.
3. Don’t put private names or code in a documentation query.
4. Read generated code that came from a docs lookup, and run tests.
5. Pin a version of the npm package if you run it locally.

Checked against the vendor documentation on November 25, 2026. [Context7 repo](https://github.com/upstash/context7) · [Claude Code MCP](https://code.claude.com/docs/en/mcp) · [Claude Code permissions](https://code.claude.com/docs/en/permissions) · [Codex MCP](https://learn.chatgpt.com/docs/extend/mcp?surface=cli)

## Where Excellent fits

Excellent’s free scan reads supported logs on the Mac and reports findings for review. It reads the session logs of Claude Code, Codex, Grok Build, GitHub Copilot CLI, Gemini CLI and Qwen Code. It does not inspect MCP servers themselves. For a local report without installing an app, [run the free scan](https://www.excellent.so/scan). [See a sample report](https://www.excellent.so/r/sample). For more on what agents record, see [Keeping keys and your email out of agent logs](https://www.excellent.so/guides/keep-keys-and-email-out-of-agent-logs).

Source: https://www.excellent.so/guides/context7-mcp-server
