Context7
Up-to-date, version-specific library docs and code examples in your agent's context, via MCP or a CLI plus skill
Install
npx ctx7 setupUse --cursor, --claude or --opencode to target an agent.
This is third-party code. Review the repository files before installing.
What it does
Context7 pulls current documentation and code examples for specific libraries into the prompt so the agent does not rely on stale training data or invent APIs. It runs in two modes: an MCP server with resolve-library-id and query-docs tools, or the ctx7 CLI with a skill that teaches the agent to call library and docs commands. You can name a library ID and version directly in the request.
Who it is for. Developers whose agents often get APIs wrong for fast-moving libraries.
Good fit when
- You are coding against a new framework version such as Next.js
- The agent suggests library methods that do not exist
- You need setup examples for a specific SDK or cloud service
Not a fit when
- Internal company libraries not in the Context7 index
- You cannot send queries to an external service
Example request
Create a Next.js middleware that checks for a valid JWT in cookies and redirects unauthenticated users to /login. use context7Limitations
Context7 documentation is community-contributed and Upstash does not guarantee its accuracy or safety. The API backend, parser and crawler are private; this repo holds only the MCP server. Without an API key rate limits are lower. The ctx7 CLI needs Node.js 18+.
How to disable. Run npx ctx7 remove. If you installed the CLI globally, also run npm uninstall -g ctx7.
MCP
- Transport
- http
- Authentication
- API key
Security check
- Sends library queries to an external service
- Uses an API key
- Documentation content is community-contributed and not fully vetted
README in short
Upstash's Context7 addresses outdated and hallucinated APIs in LLM output by injecting current documentation into context. Setup is one command, npx ctx7 setup, with a choice of mode and agent (Cursor, Claude Code, OpenCode). The README suggests naming the library ID and version in prompts and adding a rule to CLAUDE.md or Cursor settings. It documents CLI commands and MCP tools and lists npm packages: the MCP server, CLI, SDK and Vercel AI SDK tools. MIT licensed.
SKILL.md
--- name: find-docs description: >- Retrieves up-to-date documentation, API references, and code examples for any developer technology. Use this skill whenever the user asks about a specific library, framework, SDK, CLI tool, or cloud service — even for well-known ones like React, Next.js, Prisma, Express, Tailwind, Django, or Spring Boot. Your training data may not reflect recent API changes or version updates. Always use for: API syntax questions, configuration options, version migration issues, "how do I" questions mentioning a library name, debugging that involves library-specific behavior, setup instructions, and CLI tool usage. Use even when you think you know the answer — do not rely on training data for API details, signatures, or configuration options as they are frequently outdated. Always verify against current docs. Prefer this over web search for library documentation and API details. --- # Documentation Lookup Retrieve current documentation and code examples for any library using the Context7 CLI. Run commands with `npx ctx7@latest` so setup always uses the latest CLI without a global install: ```bash npx ctx7@latest library <name> "<query>" npx ctx7@latest docs <libraryId> "<query>" ``` Optionally install globally if you prefer a bare `ctx7` command: ```bash npm install -g ctx7@latest ``` ## Workflow Two-step process: resolve the library name to an ID, then query docs with that ID. ```bash # Step 1: Resolve library ID npx ctx7@latest library <name> "<query>" # Step 2: Query documentation npx ctx7@latest docs <libraryId> "<query>" ``` You MUST call `library` first to obtain a valid library ID UNLESS the user explicitly provides a library ID in the format `/org/project` or `/org/project/version`. IMPORTANT: Do not run these commands more than 3 times per question. If you cannot find what you need after 3 attempts, use the best result you have. ## Step 1: Resolve a Library Resolves a package/product name to a Context7-compatible library ID and returns matching libraries. ```bash npx ctx7@latest library React "How to clean up useEffect with async operations" npx ctx7@latest library "Next.js" "How to set up app router with middleware" npx ctx7@latest library Prisma "How to define one-to-many relations with cascade delete"
FAQ
Do I need an API key?
It is recommended for higher rate limits; a free key is available in the context7.com dashboard. ctx7 setup authenticates via OAuth and generates one.
How do I configure it manually?
Point your MCP client at https://mcp.context7.com/mcp and pass the key in an Authorization: Bearer header.
Related
A skills library that gives coding agents a development process: brainstorming, planning, TDD, subagents and code review
Skills for real engineers by Matt Pocock
Skills For Real Engineers
Small composable skills for engineering with agents: plan grilling, TDD, bug diagnosis, code review and architecture
Reference MCP servers
Model Context Protocol servers
Official reference MCP servers: Filesystem, Fetch, Git, Memory, Sequential Thinking, Time and Everything
Skills covering the full 1C:Enterprise 8.3 development cycle, from XML sources to publishing and web client testing