Context7 and its tool Context7 MCP is so popular in AI-Vibe Coding world, nowadays. I want to mention it and create an article about it.
Context7 MCP is a tool that supercharges AI prompts with real-time, version-specific documentation and code examples. Whether you're using Claude, Cursor, VS Code, or another Model Context Protocol (MCP) client, Context7 helps eliminate hallucinated APIs and outdated examples by injecting live data into your LLM interactions.
We can see their popularity on github star graphics:
π Why Use Context7?
β Without Context7:
- Outdated examples based on old training data.
- AI hallucinations about APIs that donβt exist.
- Generalized help for outdated package versions.
β With Context7:
- Accurate, live documentation and examples pulled from the actual library.
- Instant, relevant answers based on real packages and versions.
- All you have to do is add
use context7
to your prompt.
Examples:
Create a basic Next.js project with app router. use context7
Create a script to delete the rows where the city is "" given PostgreSQL credentials. use context7
π οΈ Getting Started
Requirements
- Node.js β₯ v18.0.0
- One of the following MCP clients:
- Cursor
- Windsurf
- Claude Desktop
- VS Code
- Docker (optional)
π¦ Installation Methods
1. Install via Smithery (for Claude Desktop)
npx -y @smithery/cli install @upstash/context7-mcp --client claude
π§ Installation for Specific Clients
π Cursor
Steps:
- Go to:
Settings
βCursor Settings
βMCP
βAdd new global MCP server
- Or directly update
~/.cursor/mcp.json
:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
Alternative Runtimes:
Using Bun
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
Using Deno
{
"mcpServers": {
"context7": {
"command": "deno",
"args": ["run", "--allow-net", "npm:@upstash/context7-mcp"]
}
}
}
π Windsurf
Add to your windsurf.mcp.json
:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
π§© VS Code / VS Code Insiders
Install via VS Code MCP Docs
{
"servers": {
"Context7": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
Install buttons:
π§ Claude Code
claude mcp add context7 -- npx -y @upstash/context7-mcp@latest
π» Claude Desktop
Update claude_desktop_config.json
:
{
"mcpServers": {
"Context7": {
"command": "npx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
π³ Using Docker
1. Dockerfile
Create a file named Dockerfile
:
FROM node:18-alpine
WORKDIR /app
RUN npm install -g @upstash/context7-mcp@latest
CMD ["context7-mcp"]
2. Build the Docker Image
docker build -t context7-mcp .
3. Configure MCP Client
Example client_mcp_settings.json
:
{
"mcpServers": {
"Context7": {
"autoApprove": [],
"disabled": false,
"timeout": 60,
"command": "docker",
"args": ["run", "-i", "--rm", "context7-mcp"],
"transportType": "stdio"
}
}
}
Note: The tag
context7-mcp
should match yourdocker build
tag.
π§° Available Tools
resolve-library-id
Resolves a general library name into a Context7-compatible ID.
-
libraryName
(required)
get-library-docs
Fetch docs using Context7 ID.
-
context7CompatibleLibraryID
(required) -
topic
(optional): e.g.,"routing"
,"hooks"
-
tokens
(optional, default 5000)
βοΈ Development
Clone the repo and install dependencies:
bun i
Build the project:
bun run build
Local config example:
{
"mcpServers": {
"context7": {
"command": "npx",
"args": ["tsx", "/path/to/folder/context7-mcp/src/index.ts"]
}
}
}
π¬ Test with MCP Inspector
npx -y @modelcontextprotocol/inspector npx @upstash/context7-mcp@latest
π§― Context7 Troubleshooting
ERR_MODULE_NOT_FOUND
?
Switch from npx
to bunx
:
{
"mcpServers": {
"context7": {
"command": "bunx",
"args": ["-y", "@upstash/context7-mcp@latest"]
}
}
}
Context7 MCP Errors?
- Remove
@latest
from package name. - Try
bunx
. - Try
deno
.
Top comments (0)