CLI tool to connect and interact with Context7 MCP server for up-to-date code documentation
npm install context7-cli
A command-line interface for connecting to and interacting with Context7 MCP server. Get up-to-date, version-specific code documentation and examples directly from your terminal.
- 📡 Persistent connection to Context7 MCP server
- 💻 Interactive REPL for documentation queries
- 🚀 Headless mode for one-off command execution
- 📚 Resolve library IDs and fetch current documentation
- 🔧 Command-specific help and documentation
- 🎯 Topic-focused documentation retrieval
``bash`
npm install -g context7-cli
Start the CLI and interact with Context7 through a REPL:
`bash`
npx context7-cli
Once started, you'll see the context7> prompt:
`
Context7 CLI
Usage:
commands list all the available commands
clear clear the screen
exit, quit, q exit the CLI
context7> commands
context7> resolve-library-id {"libraryName":"mongodb"}
context7> get-library-docs {"context7CompatibleLibraryID":"/mongodb/docs","topic":"aggregation"}
context7> exit
`
Execute single commands without starting the interactive REPL:
`bashGeneral format
npx context7-cli
$3
`bash
Show version
npx context7-cli --version
npx context7-cli -vList all commands
npx context7-cli --commandsGet help for specific command
npx context7-cli resolve-library-id -h
npx context7-cli get-library-docs -hGeneral help
npx context7-cli --help
npx context7-cli -h
`Available Tools
The CLI exposes 2 documentation tools from the Context7 MCP server:
$3
Resolves a package/product name to a Context7-compatible library ID and returns a list of matching libraries.
Parameters:
-
libraryName (required): string - The package/product name to resolve (e.g., "mongodb", "next.js", "react")Example:
`bash
context7> resolve-library-id {"libraryName":"mongodb"}
`$3
Fetches up-to-date documentation for a specific library, with optional topic focus and pagination.
Parameters:
-
context7CompatibleLibraryID (required): string - Exact Context7-compatible library ID (e.g., "/mongodb/docs", "/vercel/next.js")
- topic (optional): string - Focus topic for the docs (e.g., "routing", "hooks", "authentication")
- page (optional): number - Page number for pagination (1-10). If the context is not sufficient, try page=2, page=3, etc. with the same topic.Examples:
`bash
context7> get-library-docs {"context7CompatibleLibraryID":"/mongodb/docs"}
context7> get-library-docs {"context7CompatibleLibraryID":"/vercel/next.js","topic":"routing"}
context7> get-library-docs {"context7CompatibleLibraryID":"/vercel/next.js","topic":"routing","page":2}
`Use Cases
$3
`bash
1. Resolve the library ID
context7> resolve-library-id {"libraryName":"mongodb"}2. Get general documentation
context7> get-library-docs {"context7CompatibleLibraryID":"/mongodb/docs"}3. Get topic-specific documentation
context7> get-library-docs {"context7CompatibleLibraryID":"/mongodb/docs","topic":"aggregation"}
`$3
`bash
Get Next.js routing documentation
npx context7-cli get-library-docs '{"context7CompatibleLibraryID":"/vercel/next.js","topic":"routing"}'Get React hooks documentation
npx context7-cli get-library-docs '{"context7CompatibleLibraryID":"/facebook/react","topic":"hooks"}'
``Context7 is an MCP server that delivers up-to-date, version-specific code documentation and examples directly into LLM prompts and AI code editors. It solves the problem of outdated training data by pulling current documentation straight from the source.
Learn more at context7.com or github.com/upstash/context7.
Apache-2.0