Context7 MCP - Intelligent documentation search and context for any library
数据来源:ClawHub。 在 ClawSkills 查看
选择你使用的 Agent
方法一:命令行安装(推荐)
推荐(无需提前安装 clawhub)
npx clawhub@latest --dir ~/.claude/skills install context7或使用 clawhub CLI(需提前安装)
clawhub --dir ~/.claude/skills install context7⚠️ 需要 Node.js 18+,没有 Node?请使用下方方法二直接下载 ZIP。 安装 Node.js →
方法二:手动下载安装(无需 Node)
下载 ZIP,解压后将文件夹放到以下路径,重启 Agent 即可:
安装路径
~/.claude/skills/context7/💡解压后将文件夹放到上方路径,重启 Agent 即可生效
--- name: context7 description: Context7 MCP - Intelligent documentation search and context for any library metadata: version: 1.0.3 tags: ["documentation", "search", "context", "mcp", "llm"] clawdbot: requires: bins: ["node"] npm: true install: - id: "skill-install" kind: "skill" source: "clawdhub" slug: "context7" label: "Install Context7 skill" ---
Context7 provides intelligent documentation search and context for any library, powered by LLMs.
.env.example to .env and add your Context7 API key:```bash cp .env.example .env ```
Add your API key to .env: ``` CONTEXT7_API_KEY=your-api-key-here ```
Get your key from context7.com/dashboard
```bash npm install ```
Context7 provides two main commands:
Search for libraries by name with intelligent LLM-powered ranking:
npx tsx query.ts search <library_name> <query>
# Examples:
npx tsx query.ts search "nextjs" "setup ssr"
npx tsx query.ts search "react" "useEffect cleanup"
npx tsx query.ts search "better-auth" "authentication flow"
This calls the Context7 Search API:
GET https://context7.com/api/v2/libs/search?libraryName=<name>&query=<query>
Response includes:
/vercel/next.js)Retrieve intelligent, LLM-reranked documentation context:
npx tsx query.ts context <owner/repo> <query>
# Examples:
npx tsx query.ts context "vercel/next.js" "setup ssr"
npx tsx query.ts context "facebook/react" "useState hook"
This calls the Context7 Context API:
GET https://context7.com/api/v2/context?libraryId=<repo>&query=<query>&type=txt
Response includes:
# Search for documentation
npx tsx query.ts search "library-name" "your search query"
# Get context from a specific repo
npx tsx query.ts context "owner/repo" "your question"
Get the most out of the Context7 API with these best practices:
When using the /libs/search endpoint, always include the user's original question in the query parameter. This allows the API to use LLM-powered ranking to find the most relevant library for the specific task, rather than relying on a simple name match.
Example: If a user asks about SSR in Next.js, search with:
libraryName=nextjsquery=setup+ssrThis ensures the best ranking for the specific task.
For the fastest and most accurate results with the /context endpoint, provide the full libraryId (e.g., /vercel/next.js). If you already know the library the user is asking about, skipping the search step and calling the context endpoint directly reduces latency.
To ensure documentation accuracy for older or specific project requirements, include the version in the libraryId using the /owner/repo/version format. You can find available version tags in the response from the search endpoint.
Tailor the /context response to your needs using the type parameter:
type=json when you need to programmatically handle titles, content snippets, and source URLs (ideal for UI display).type=txt when you want to pipe the documentation directly into an LLM prompt as plain text.When programmatically selecting a library from search results, use the trustScore and benchmarkScore to prioritize high-quality, reputable documentation sources for your users.
Find navigation and other pages in this documentation by fetching the llms.txt file at:
https://context7.com/docs/llms.txt
Search Endpoint:
GET https://context7.com/api/v2/libs/search
?libraryName=<library_name>
&query=<user_query>
Context Endpoint:
GET https://context7.com/api/v2/context
?libraryId=<owner/repo>
&query=<user_query>
&type=txt|json
No results found?
Authentication errors?
.envMIT
安装 Context7 MCP 后,可以对 AI 说这些话来触发它
Help me get started with Context7 MCP
Explains what Context7 MCP does, walks through the setup, and runs a quick demo based on your current project
Use Context7 MCP to context7 MCP - Intelligent documentation search and context for any...
Invokes Context7 MCP with the right parameters and returns the result directly in the conversation
What can I do with Context7 MCP in my documents & notes workflow?
Lists the top use cases for Context7 MCP, with example commands for each scenario
将技能文件夹放到 ~/.claude/skills/context7/ 目录(个人级,所有项目可用),或 .claude/skills/context7/(项目级)。重启 AI 客户端后,用 /context7 主动调用,或让 AI 根据上下文自动发现并使用。
Context7 MCP 支持 Claude、Cursor、OpenClaw,可与这些 AI 平台无缝集成,扩展其能力。
Context7 MCP 可免费安装使用。请查阅仓库了解许可证信息。
Context7 MCP - Intelligent documentation search and context for any library
Context7 MCP 属于「Documents & Notes」分类,该分类的技能帮助 AI 智能体在此领域执行专业任务。
Automate my documents & notes tasks using Context7 MCP
Identifies repetitive steps in your workflow and sets up Context7 MCP to handle them automatically