AgentSkillsCN

context7

当您需要获取当前的API参考、函数签名,或了解库的使用模式时,这一工具能帮您快速查询文档。它通过Context7 API查找文档,涵盖文档查询、库文档、API参考以及库的使用方法。注意:此工具不适用于网络搜索(请使用WebSearch),也不适用于特定项目的代码(请直接阅读代码库)。

SKILL.md
--- frontmatter
name: context7
description: Use when needing current API references, function signatures, or library usage patterns. Looks up documentation via Context7 API. Covers docs lookup, library documentation, API reference, how to use library. NOT for: web search (use WebSearch), project-specific code (read the codebase).
execute: scripts/default.sh

Context7 - Library Documentation Lookup

Look up current library documentation using Context7 API.

Context7 provides up-to-date documentation and code examples for programming libraries. This skill replaces the Context7 MCP server with direct API calls.

Quick Reference

ActionScriptExample
Search for libraryscripts/resolve-library.sh./resolve-library.sh react
Query documentationscripts/query-docs.sh./query-docs.sh /vercel/next.js 'app router'
Show usagescripts/default.shAuto-runs when skill loaded

Usage

1. Find a Library ID

First, search for the library to get its Context7 ID:

bash
./scripts/resolve-library.sh react

Output example:

markdown
## Library Search Results

| Name | ID | Snippets | Score |
|------|-----|----------|-------|
| React | /facebook/react | 1250 | 95 |
| React Native | /facebook/react-native | 890 | 92 |

2. Query Documentation

Then use the library ID to query specific documentation:

bash
./scripts/query-docs.sh /vercel/next.js 'how to use app router'

Output: Markdown-formatted documentation snippets with code examples.

Authentication

The scripts automatically get the API key from:

  1. Environment variable CONTEXT7_API_KEY (if set)
  2. 1Password - item context7 in vault development, field API_KEY

1Password Setup (Recommended)

The key is already stored in 1Password. No setup needed if you have op CLI authenticated.

Manual Setup

If not using 1Password, set the environment variable:

bash
export CONTEXT7_API_KEY="ctx7sk_your_key_here"

Get a key from context7.com → API settings.

Disabling Context7 MCP

Once this skill works, you can disable the MCP server to reduce overhead:

In Claude Code

Edit your MCP config (~/.config/claude-code/mcp.json or mcp_config.json):

json
{
  "mcpServers": {
    "context7": {
      "disabled": true
    }
  }
}

Or remove the entry entirely.

In Claude Desktop

Edit ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) and remove or disable the context7 server.

Workflows

  • lookup.md - Step-by-step library documentation lookup

API Reference

This skill calls the Context7 REST API:

  • Base URL: https://context7.com/api
  • Search endpoint: GET /v2/libs/search?query=...&libraryName=...
  • Docs endpoint: GET /v2/context?query=...&libraryId=...&type=txt
  • Auth: Bearer token header

See Also