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!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
mcp-server-qdrant
这个仓库展示了如何为向量搜索引擎 Qdrant 创建一个 MCP (Managed Control Plane) 服务器的示例。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。