MCP Server
The MCP server enables AI coding assistants to access Context7’s documentation database.Package Information
- Package:
@upstash/context7-mcp - Version: Latest on npm
- Repository: github.com/upstash/context7
Installation Options
- Remote Server (Recommended)
- Local Server
- OAuth Authentication
Connect to Context7’s hosted MCP server - no installation required.
Running as HTTP Server
You can also run the MCP server as a standalone HTTP server:http://localhost:3000/mcp.
Available endpoints:
/mcp- MCP protocol endpoint (anonymous access)/mcp/oauth- OAuth-protected endpoint/ping- Health check/.well-known/oauth-protected-resource- OAuth metadata
SDK
The TypeScript/JavaScript SDK provides programmatic access to Context7’s API.Installation
Usage
API Methods
searchLibrary
Search for libraries matching a query.getContext
Get documentation for a specific library.Error Handling
CLI
Thectx7 CLI provides tools for authentication and quick MCP setup.
Installation
Commands
setup
Configure Context7 MCP for your AI coding agents:- Authenticates via OAuth (or uses provided API key)
- Generates API key automatically if using OAuth
- Configures MCP server in your agent’s config file
- Adds a rule to auto-invoke Context7
- Installs Context7 skill
auth
Manage authentication:skills
Manage Context7 skills:AI SDK Tools
Pre-built tools for Vercel AI SDK that provide Context7 functionality.Installation
Requires peer dependencies:
@upstash/context7-sdk, ai (v6.0.0+), and zod (v4.0.0+)Usage
Available Tools
resolveLibraryId
Resolves a library name to a Context7-compatible library ID.queryDocs
Fetches documentation for a library using its Context7 library ID.Context7 Agent
A pre-configured agent that combines both tools:System Prompts
The package exports system prompts that you can use in your own agents:Getting an API Key
1
Visit the dashboard
Go to context7.com/dashboard
2
Sign in
Authenticate with your GitHub, Google, or email account
3
Generate API key
Click “Create API Key” and give it a name
4
Copy the key
Copy your API key (starts with
ctx7sk_) and store it securelyEnvironment Variables
All packages support theCONTEXT7_API_KEY environment variable:
.env file:
Next Steps
Quickstart Guide
Get Context7 running in under 5 minutes
API Reference
Explore the REST API documentation
Adding Libraries
Submit your library to Context7
Troubleshooting
Common issues and solutions