Context7 MCP Server
Provides access to the Context7 API for searching up-to-date documentation, code examples, API references, and troubleshooting help across thousands of programming libraries and frameworks. Enables developers and AI agents to quickly find accurate documentation, compare libraries, get migration guides, and resolve coding issues.
README
Context7 MCP Server
MCP server providing access to Context7 API for up-to-date code documentation retrieval.
Features
Core Capabilities
- Documentation Search - Search across thousands of libraries and frameworks
- Code Examples - Get working code examples for specific use cases
- API Reference - Detailed API documentation for functions and classes
- Code Explanation - Understand code with line-by-line explanations
- Troubleshooting - Get help with error messages and bugs
- Best Practices - Learn recommended patterns and anti-patterns
- Migration Guides - Upgrade between versions or switch libraries
- Library Comparison - Compare different libraries for your use case
- Changelog Access - View release notes and breaking changes
Installation
- Clone this repository
- Install dependencies:
pip install -r requirements.txt
- Set up your environment variables:
cp .env.example .env
# Edit .env and add your Context7 API key
Configuration
Get Your Context7 API Key
- Go to https://context7.com/api
- Sign up or sign in
- Generate an API key
- Copy the key and add it to your
.envfile
Claude Desktop Configuration
{
"mcpServers": {
"context7": {
"command": "fastmcp",
"args": ["run", "server.py"],
"env": {
"CONTEXT7_API_KEY": "your_api_key_here"
}
}
}
}
Available Tools
search_documentation
Search for documentation across supported libraries.
Parameters:
query(required): Search querylanguage: Filter by language (javascript, python, go, etc.)framework: Filter by framework (react, django, nextjs, etc.)limit: Max results (default: 10, max: 50)
Example:
{
"query": "how to use useState in React",
"framework": "react",
"limit": 5
}
get_library_docs
Get documentation for a specific library.
Parameters:
library(required): Library nameversion: Specific version (default: latest)topic: Specific topic or module
Example:
{
"library": "react",
"version": "18.2.0",
"topic": "hooks"
}
get_code_examples
Get code examples for a specific use case.
Parameters:
library(required): Library nameuse_case(required): What you're trying to accomplishlanguage: Programming language
Example:
{
"library": "express",
"use_case": "JWT authentication middleware"
}
explain_code
Get explanation of code with documentation references.
Parameters:
code(required): Code snippet to explainlanguage: Programming language (auto-detected)context: Additional context
Example:
{
"code": "const [count, setCount] = useState(0);",
"language": "javascript",
"context": "React component"
}
get_api_reference
Get detailed API reference for a function or class.
Parameters:
library(required): Library nameapi_name(required): API/function/class nameversion: Library version (default: latest)
Example:
{
"library": "react",
"api_name": "useState",
"version": "18.2.0"
}
compare_libraries
Compare multiple libraries for a use case.
Parameters:
libraries(required): List of library namesuse_case(required): What you're buildinglanguage: Programming language
Example:
{
"libraries": ["react", "vue", "svelte"],
"use_case": "building a todo app"
}
get_migration_guide
Get migration guide between libraries or versions.
Parameters:
from_library(required): Current libraryto_library(required): Target libraryfrom_version: Current versionto_version: Target version
Example:
{
"from_library": "react",
"to_library": "react",
"from_version": "17.0.0",
"to_version": "18.0.0"
}
get_best_practices
Get best practices for a library.
Parameters:
library(required): Library nametopic: Specific topic (performance, security, testing, etc.)
Example:
{
"library": "react",
"topic": "performance"
}
troubleshoot_error
Get help with error messages.
Parameters:
error_message(required): The error you're seeinglibrary: Library where error occurredcode_context: Code causing the error
Example:
{
"error_message": "Cannot read property 'map' of undefined",
"library": "react",
"code_context": "data.map(item => <div>{item}</div>)"
}
list_supported_libraries
List all supported libraries.
Parameters:
language: Filter by languagecategory: Filter by category
Example:
{
"language": "python",
"category": "data-science"
}
get_changelog
Get changelog and release notes.
Parameters:
library(required): Library namefrom_version: Starting versionto_version: Ending version (default: latest)
Example:
{
"library": "react",
"from_version": "17.0.0",
"to_version": "18.2.0"
}
Usage Examples
Search for Documentation
{
"tool": "search_documentation",
"query": "authentication with JWT",
"language": "javascript"
}
Get Code Examples
{
"tool": "get_code_examples",
"library": "pandas",
"use_case": "filter dataframe by multiple conditions"
}
Explain Complex Code
{
"tool": "explain_code",
"code": "useEffect(() => { fetchData(); }, [id]);",
"language": "javascript"
}
Compare Frameworks
{
"tool": "compare_libraries",
"libraries": ["express", "fastify", "koa"],
"use_case": "REST API server"
}
Troubleshoot an Error
{
"tool": "troubleshoot_error",
"error_message": "Module not found: Can't resolve 'react'",
"library": "react"
}
Migration Help
{
"tool": "get_migration_guide",
"from_library": "webpack",
"to_library": "vite"
}
Supported Languages & Frameworks
Context7 supports documentation for:
Languages
- JavaScript/TypeScript
- Python
- Go
- Rust
- Java
- C#
- PHP
- Ruby
- Swift
- Kotlin
Popular Frameworks
- Web: React, Vue, Angular, Svelte, Next.js, Nuxt
- Backend: Express, Django, FastAPI, Spring Boot, Rails
- Mobile: React Native, Flutter, SwiftUI
- Data Science: Pandas, NumPy, Scikit-learn, TensorFlow
- DevOps: Docker, Kubernetes, Terraform, Ansible
Use Cases
For Developers
- Quick documentation lookup while coding
- Find working code examples
- Understand unfamiliar code
- Troubleshoot errors faster
- Learn best practices
For AI Agents
- Provide accurate, up-to-date documentation
- Generate code with proper library usage
- Help debug issues with context
- Recommend appropriate libraries
- Assist with migrations and upgrades
Error Handling
The server handles:
- Invalid API keys
- Rate limiting
- Network timeouts
- Invalid library names
- Malformed queries
Rate Limits
Context7 API rate limits depend on your plan:
- Free tier: 100 requests/day
- Pro tier: 10,000 requests/day
- Enterprise: Custom limits
Check your usage at: https://context7.com/dashboard
Best Practices
- Be Specific: Include library names and versions when possible
- Use Filters: Narrow searches with language/framework filters
- Cache Results: Store frequently accessed documentation
- Combine Tools: Use search + get_api_reference for comprehensive info
- Error Context: Provide code context for better troubleshooting
Security Notes
- Never commit API keys to version control
- Use environment variables
- Rotate keys regularly
- Monitor usage in dashboard
- Set up usage alerts
Troubleshooting
"Invalid API Key" Error
- Verify key in
.envfile - Check key is active at context7.com
- Ensure no extra spaces
Rate Limit Errors
- Check current usage in dashboard
- Upgrade plan if needed
- Implement caching
Library Not Found
- Check library name spelling
- Use list_supported_libraries to verify
- Some libraries may not be indexed yet
Resources
License
MIT License - feel free to use in your projects!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.