How to Set Up Context7 MCP Server (2026)
Add real-time documentation context to your AI coding assistant
Start Building with Hypereal
Access Kling, Flux, Sora, Veo & more through a single API. Free credits to start, scale to millions.
No credit card required • 100k+ developers • Enterprise ready
How to Set Up Context7 MCP Server (2026)
If you have ever asked an AI coding assistant about a framework and received outdated or hallucinated API advice, Context7 is the solution. Context7 is a Model Context Protocol (MCP) server that provides AI assistants with up-to-date, version-specific documentation pulled directly from official sources. Instead of relying on the LLM's training data (which may be months or years old), Context7 fetches the actual current documentation and injects it into the AI's context.
This guide walks you through installing, configuring, and using Context7 with popular AI coding tools.
What Is MCP (Model Context Protocol)?
Before diving into Context7 specifically, it helps to understand MCP. The Model Context Protocol is an open standard (originally developed by Anthropic) that allows AI assistants to connect with external data sources and tools through a standardized interface. Think of MCP servers as plugins that give AI models access to real-world information and capabilities.
An MCP server can provide:
- Resources: Data the AI can read (files, documentation, database schemas)
- Tools: Functions the AI can call (search, API requests, code execution)
- Prompts: Pre-built prompt templates for common tasks
What Does Context7 Do?
Context7 is an MCP server that specializes in providing accurate, up-to-date library and framework documentation to AI coding assistants. When you ask your AI assistant about a specific library, Context7:
- Identifies the library you are asking about
- Fetches the current documentation from its index
- Provides the relevant docs as context to the AI model
- The AI then generates responses based on actual, current documentation
This eliminates the most common problem with AI coding assistants: outdated or hallucinated API details.
Libraries Supported
Context7 maintains an index of documentation for thousands of popular libraries, including:
- React, Next.js, Vue, Svelte, Angular
- Node.js, Express, Fastify, Hono
- Python (Django, Flask, FastAPI, SQLAlchemy)
- TypeScript, Zod, Prisma, Drizzle
- Tailwind CSS, shadcn/ui
- Rust, Go, Java, and many more
Installation Methods
Context7 can be installed as an MCP server for several AI coding tools. Here are the most common setups.
Method 1: Claude Code (Recommended)
Claude Code has native MCP support. Add Context7 with a single command:
claude mcp add context7 -- npx -y @context7/mcp@latest
That is it. Claude Code will now have access to Context7 documentation in every conversation.
To verify it is working:
claude mcp list
You should see context7 listed as an active MCP server.
Method 2: Cursor
For Cursor, you need to add Context7 to your MCP configuration file. Create or edit .cursor/mcp.json in your project root:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp@latest"]
}
}
}
Restart Cursor, and Context7 will be available in the AI chat panel.
Method 3: VS Code with Copilot
For VS Code with GitHub Copilot's MCP support, add to your .vscode/mcp.json:
{
"servers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp@latest"]
}
}
}
Method 4: Windsurf
Add to your Windsurf MCP configuration file (~/.windsurf/mcp.json):
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp@latest"]
}
}
}
Method 5: Manual / Standalone
If you want to run Context7 as a standalone server for custom integrations:
# Install globally
npm install -g @context7/mcp
# Run the server
context7-mcp
# Or run directly with npx
npx @context7/mcp@latest
The server communicates over stdio by default, following the MCP specification.
Prerequisites
Before installing Context7, ensure you have:
| Requirement | Minimum Version | Check Command |
|---|---|---|
| Node.js | 18.0+ | node --version |
| npm | 9.0+ | npm --version |
| npx | Included with npm | npx --version |
If you do not have Node.js installed:
# macOS (using Homebrew)
brew install node
# Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
# Windows (using winget)
winget install OpenJS.NodeJS
How to Use Context7 Effectively
Once Context7 is installed, it works automatically in most setups. However, you can get better results by being explicit in your prompts.
Basic Usage
Simply mention a library in your prompt, and Context7 will provide relevant documentation:
How do I set up server actions in Next.js 15?
Context7 detects "Next.js 15" and provides the current Server Actions documentation.
Explicit Context7 Trigger
For more reliable results, use the use context7 phrase in your prompts:
use context7 - How do I configure middleware in Hono?
Specifying Library Versions
You can request documentation for specific versions:
use context7 - Show me how to use the new React 19 `use` hook
Comparing Approaches
Context7 is especially useful when you need to compare how things work across versions or frameworks:
use context7 - What's the difference between Drizzle ORM and Prisma
for defining relations? Show both approaches.
Configuration Options
Context7 can be configured through environment variables:
| Variable | Description | Default |
|---|---|---|
CONTEXT7_CACHE_DIR |
Directory for caching documentation | ~/.context7/cache |
CONTEXT7_CACHE_TTL |
Cache time-to-live in seconds | 3600 (1 hour) |
CONTEXT7_MAX_TOKENS |
Maximum tokens to include in context | 10000 |
CONTEXT7_LOG_LEVEL |
Logging verbosity (debug, info, warn, error) | info |
To set these in your MCP configuration:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@context7/mcp@latest"],
"env": {
"CONTEXT7_MAX_TOKENS": "15000",
"CONTEXT7_CACHE_TTL": "7200"
}
}
}
}
Troubleshooting
Context7 Not Providing Documentation
- Check that the server is running: In Claude Code, run
claude mcp list. In Cursor, check the MCP status in the bottom bar. - Be explicit: Use "use context7" in your prompt to force the tool to activate.
- Check Node.js version: Context7 requires Node.js 18+.
Slow Response Times
Context7 caches documentation locally after the first fetch. If the first query is slow, subsequent queries for the same library should be fast. You can increase the cache TTL to reduce re-fetches:
CONTEXT7_CACHE_TTL=86400 # Cache for 24 hours
npx Fails to Install
If npx fails, install the package globally instead:
npm install -g @context7/mcp@latest
Then update your MCP configuration to use the global binary:
{
"mcpServers": {
"context7": {
"command": "context7-mcp"
}
}
}
Context7 vs. Other Documentation MCP Servers
| Feature | Context7 | Docs MCP | DevDocs MCP |
|---|---|---|---|
| Library Coverage | 5,000+ | 500+ | 1,000+ |
| Version-specific Docs | Yes | Partial | No |
| Auto-detection | Yes | No | No |
| Caching | Yes | Yes | No |
| Update Frequency | Daily | Weekly | Monthly |
| Setup Complexity | One command | Moderate | Moderate |
Conclusion
Context7 is one of the most immediately useful MCP servers you can add to your AI coding setup. It solves the single biggest reliability problem with AI coding assistants -- outdated documentation -- with a one-line installation. Whether you use Claude Code, Cursor, VS Code, or another MCP-compatible tool, Context7 is worth adding to your workflow today.
For developers who also work with visual and media content alongside code, Hypereal AI provides API access for AI-powered image generation, video creation, and avatar building. Pair Context7 for accurate coding assistance with Hypereal AI for your media generation needs.
Related Articles
Start Building Today
Get 35 free credits on signup. No credit card required. Generate your first image in under 5 minutes.
