Context7 Cli

作者 upstashfeef1b2f6078无许可证62K 个星标收录于 2026年10月8日更新于 2026年10月8日仓库今天更新

Use the ctx7 CLI to fetch library documentation and configure Context7 MCP. Activate when the user mentions "ctx7" or "context7", needs current docs for any library, or needs to set up Context7 for their AI coding agent.

AI 生成的概览

通过 ctx7 CLI 获取最新的库文档,并为 AI 编程编辑器配置 Context7 MCP。

功能
该技能说明如何使用 ctx7 命令行工具解析库 ID 并获取该库的最新文档。它还介绍如何为 Claude Code、Cursor 和 OpenCode 等编辑器配置 Context7 MCP,以及登录、登出和状态查询等认证命令。这是一个仅含说明的技能,附带两份参考文档,分别介绍文档查询和配置。
适用场景
当用户提到 ctx7 或 Context7、需要某个库的最新文档,或希望在其 AI 编程代理中配置 Context7 MCP 时使用。它也适用于核对 API 签名或训练数据可能过时的情形。
运行要求
需要 ctx7 CLI,可通过 npm 全局安装或使用 npx 直接运行,因此需要 Node.js、npm 和网络访问。可选的 Context7 API 密钥或 OAuth 登录可获得更高速率限制;setup 命令需要登录,除非传入 API 密钥或 OAuth 参数。该技能不附带脚本。

ctx7 CLI

The Context7 CLI does two things: fetches up-to-date library documentation and sets up Context7 MCP for your editor.

Make sure the CLI is up to date before running commands:

bash
npm install -g ctx7@latest

Or run directly without installing:

bash
npx ctx7@latest <command>

What this skill covers

  • Documentation [blocked] — Fetch current docs for any library. Use when writing code, verifying API signatures, or when training data may be outdated.
  • Setup [blocked] — Configure Context7 MCP for Claude Code / Cursor / OpenCode.

Quick Reference

bash
# Documentationctx7 library <name> <query>           # Step 1: resolve library IDctx7 docs <libraryId> <query>         # Step 2: fetch docs
# Setupctx7 setup                            # Configure Context7 MCP (interactive)ctx7 login                            # Log in for higher rate limitsctx7 whoami                           # Check current login status

Authentication

bash
ctx7 login               # Opens browser for OAuthctx7 login --no-browser  # Prints URL instead of opening browserctx7 logout              # Clear stored tokensctx7 whoami              # Show current login status (name + email)

Most commands work without login. Exception: ctx7 setup requires it unless --api-key or --oauth is passed. Login also unlocks higher rate limits on docs commands.

Set an API key via environment variable to skip interactive login entirely:

bash
export CONTEXT7_API_KEY=your_key

Common Mistakes

  • Library IDs require a / prefix — /facebook/react not facebook/react
  • Always run ctx7 library first — ctx7 docs react "hooks" will fail without a valid ID

来源与署名

来源:upstash/context7位于skills/context7-cli提交feef1b2

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架