Context7 MCP Server – Live Code Documentation
Context7 by Upstash gives AI coding agents live, version-aware documentation and examples for software libraries and frameworks. Use it to resolve library IDs and retrieve current API guidance directly inside an MCP-compatible coding assistant.
Overview
Context7 is an Upstash project that provides up-to-date, version-specific
documentation and code examples for AI coding tools. Its MCP server lets an
agent fetch current library and framework guidance directly into the model
context, reducing hallucinated APIs and outdated examples.
What the MCP server enables
Context7's MCP integration exposes a focused documentation workflow. An AI
agent can:
- Resolve a general package or framework name into a Context7-compatible
library ID. - Retrieve documentation for a known Context7 library ID.
- Search documentation using the user's current programming task as relevance
context. - Pull code examples and API guidance from Context7's indexed documentation.
- Use exact library IDs such as
/vercel/next.jsor/mongodb/docsto skip
library matching when the target project is already known. - Retrieve version-specific guidance when the user mentions a library version.
When to use it
Use Context7 MCP whenever an AI coding agent needs current package, framework,
SDK, or API documentation. Practical examples include generating code against a
recent framework version, checking the current API for an authentication SDK,
writing middleware, configuring deployment tools, comparing library usage
patterns, or fixing code that appears to rely on obsolete documentation.
Connection and authentication
Context7 supports a hosted MCP endpoint at https://mcp.context7.com/mcp.
Manual client configuration can pass a Context7 API key using the
CONTEXT7_API_KEY header. Context7 also provides a setup command,
npx ctx7 setup, which authenticates with OAuth, can generate an API key, and
can install either MCP mode or a CLI-plus-skills workflow for supported coding
agents.
For local MCP use, the official npm package is @upstash/context7-mcp. A common
local stdio configuration runs npx -y @upstash/context7-mcp@latest and can
receive CONTEXT7_API_KEY through the environment.
Key considerations
Context7 indexes community-contributed projects and documentation. Upstash
notes that it strives for quality but does not guarantee the accuracy,
completeness, or security of every indexed project. Agents should still verify
generated code against official library behavior, especially for security,
authentication, billing, or migration workflows. Use a Context7 API key for
higher rate limits, keep that key outside source control, and prefer exact
library IDs when accuracy matters.
Supported Transports
streamable_http
URL: https://mcp.context7.com/mcp
stdio
Command: npx
Args:
-y@upstash/context7-mcp@latest
Frequently Asked Questions
- When should an AI agent use the Context7 MCP server?
- Use it when a coding workflow needs current library, framework, SDK, or API documentation, especially when generating code for recent versions or avoiding outdated examples and hallucinated APIs.
- What does the Context7 MCP server add to an AI agent's capabilities?
- It gives the agent live access to Context7's documentation index, allowing it to resolve library IDs and retrieve relevant, version-aware documentation and code examples instead of relying only on static model training data.
- What can an AI agent access or manage through Context7 MCP?
- The agent can resolve library names into Context7-compatible IDs and query documentation for those IDs. Context7 is a documentation retrieval server; it does not manage source repositories, deploy applications, or modify user projects.
- How is authentication configured for the Context7 MCP server?
- Context7 recommends getting a free API key for higher rate limits. The hosted MCP endpoint accepts the key in the CONTEXT7_API_KEY header, and the local @upstash/context7-mcp package can receive CONTEXT7_API_KEY through the environment. The ctx7 setup flow can authenticate with OAuth and generate a key.
- Which transport should be used for the Context7 MCP server?
- Use the hosted Streamable HTTP endpoint at https://mcp.context7.com/mcp for clients that support remote MCP servers. Use local stdio with @upstash/context7-mcp when an IDE or desktop client expects a local MCP process.