VC

vedanthb/context7-cli

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

21 stars 3 forks 质量 59 趋势 30

Context7 的 CLI — 终端里有最新的库文档。不需要 MCP。

概览

从你的终端获取最新、版本特定的库文档。不需要MCP客户端。 它建立在Context7之上——同样支持Cursor、Claude及其他AI编码助手的文档,现在以简单的CLI形式提供。 该包在 npm 上以 @vedanth/context7 发布。npm 上的 unscoped context7 是一个不同的、无关的项目。 越来越多的共识认为,CLI比MCP服务器更适合开发者工具。MCP会把你锁定在特定的编辑器里。CLI只是给你文本——你可以随意插入。 Context7 有很棒的文档数据,但他们的 MCP 服务器只能在 Cursor 和其他 MCP 客户端内工作。C7 提供与普通标准数据相同的数据: - 导入任何大型语言模型(Claude Code、Ollama、llama.cpp 等)- 用 grep、jq、less、pbcopy 或 shell 脚本进行合成 - 在 CI、自动化、代理提示符中使用——任何能运行命令的地方 基本使用时无需API密钥即可使用。对于更高速率限制: 1. 在 context7.com/dashboard 获得钥匙 2.

概述(AI 翻译)

从你的终端获取最新、版本特定的库文档。不需要MCP客户端。

它建立在Context7之上——同样支持Cursor、Claude及其他AI编码助手的文档,现在以简单的CLI形式提供。

注: 该包在 npm 上以 @vedanth/context7 发布。npm 上的无范围 context7 是一个不同的项目,无关紧要。

为什么?

越来越多的共识认为,CLI比MCP服务器更适合开发者工具。MCP会把你锁定在特定的编辑器里。CLI只是给你文本——你可以随意插入。

Context7 的文档数据很棒,但他们的 MCP 服务器只能在 Cursor 和其他 MCP 客户端内运行。c7 提供与普通标准相同的数据:

  • 导入任何大型语言模型(Claude Code、Ollama、llama.cpp 等)
  • 使用 grep、jq、less、pbcopy 或 shell 脚本进行合成
  • 在CI、自动化、代理提示中——任何可以运行命令的地方

安装

用途

命令

指挥 描述
c7 resolve 查找 Context7 图书馆 ID 以获取搜索词
c7 docs [topic] 获取文档(自动解析姓名至最佳匹配)
c7 [topic] c7 docs 的简写

选项

|旗帜 |描述 |

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

c7 — Context7 CLI

Get up-to-date, version-specific library docs from your terminal. No MCP client needed.

Built on top of Context7 — the same docs that power Cursor, Claude, and other AI coding assistants, now available as a simple CLI.

Note: This package is published as @vedanth/context7 on npm. The unscoped context7 on npm is a different, unrelated project.

Why?

There’s been a growing consensus that CLIs are better than MCP servers for developer tools. MCP locks you into specific editors. A CLI just gives you text — pipe it wherever you want.

Context7 has great docs data, but their MCP server only works inside Cursor and other MCP clients. c7 makes the same data available as plain stdout:

  • Pipe into any LLM (Claude Code, Ollama, llama.cpp, whatever)
  • Compose with grep, jq, less, pbcopy, or shell scripts
  • Use in CI, automation, agent prompts — anywhere you can run a command

Install

npx @vedanth/context7               # Run directly (no install)
npm install -g @vedanth/context7     # Or install globally

Usage

# Find a library
c7 resolve nextjs

# Get docs (auto-resolves library name)
c7 docs nextjs "app router"
c7 docs react "server components" --tokens 10000

# Shorthand — skip the "docs" command
c7 react hooks
c7 express middleware
c7 tailwindcss "dark mode"

# Use exact Context7 ID (from resolve)
c7 docs /vercel/next.js "image optimization"

# Pipe into anything
c7 react hooks | pbcopy
c7 express middleware >> prompt.txt
c7 docs nextjs "api routes" | llm "summarize these docs"

Commands

Command Description
c7 resolve Find Context7 library IDs for a search term
c7 docs [topic] Get docs (auto-resolves name to best match)
c7 [topic] Shorthand for c7 docs

Options

Flag Description
--tokens Max tokens to return (default: 5000)
--api-key Context7 API key (or set CONTEXT7_API_KEY env)
--json Raw JSON output (resolve only)

API Key (optional)

Works without an API key for basic usage. For higher rate limits:

  1. Get a key at context7.com/dashboard
  2. Set it: export CONTEXT7_API_KEY=your-key

Use Cases

Feed docs into coding agents:

DOCS=$(c7 nextjs "app router middleware" --tokens 8000)
claude "Build a Next.js middleware that redirects. Use these docs:\n$DOCS"

Quick API lookup:

c7 prisma "findMany" --tokens 3000
在 GitHub 查看完整 README

安装

npx @vedanth/context7 # Run directly (no install)
新手?先看 mcpskill.org 教程 →