promptgarten ๐ŸŒฑ
๐ŸŒ ES

Add-ons & integrations ยท MCP

Context7

โ˜… 58.979

MCP server that loads current, version-accurate library documentation directly into your agent's context.

Context7 solves a core problem of coding assistants: the model only knows library APIs up to its training cutoff and therefore likes to suggest outdated or even nonexistent functions. According to the README, the MCP server fetches current, version-specific documentation and code examples "straight from the source" and places them directly into the agent's prompt.

Technically, Context7 provides two MCP tools: resolve-library-id translates a library name (e.g. "Next.js") into a unique Context7 ID, and query-docs then retrieves the matching docs for that ID and the specific question. This is triggered either automatically by the agent โ€” or simply by appending "use context7" to your request, for example: "How do I set up Next.js 14 middleware? use context7".

The service runs as a hosted endpoint at https://mcp.context7.com/mcp; a free API key (via OAuth through the dashboard) is recommended for higher rate limits and is sent along as a CONTEXT7_API_KEY header. The CLI tool ctx7 handles setup, generating the key and automatically installing the integration for clients like Claude Code, Cursor, or OpenCode. The only requirement: Node.js 18 or newer. This way the agent reads the actual documentation of the library version really in use, instead of guessing API calls from memory.

๐Ÿ”ง SETUP

  1. Check the prerequisite: Node.js 18 or newer must be installed
  2. Run the setup assistant: `npx ctx7 setup` โ€” generates an API key via OAuth and installs the integration; targeted at one client, e.g. `npx ctx7 setup --claude` (`--cursor` or `--opencode` also possible)
  3. Alternatively manual: register the MCP server `https://mcp.context7.com/mcp` in the client and pass the API key as a `CONTEXT7_API_KEY` header (free key via context7.com/dashboard)
  4. Test it: ask a coding question and append "use context7", e.g. "How do I set up Next.js 14 middleware? use context7"
  5. Remove again if needed: `npx ctx7 remove`

โœ… WHEN TO USE IT?

Working with fast-moving frameworks

When building with Next.js, React, or a freshly updated library, append "use context7" โ€” the agent reads the docs for the actual version instead of suggesting outdated APIs from its training knowledge.

Stopping hallucinated API calls

When the assistant keeps suggesting functions that don't (or no longer) exist in the library version in use, `query-docs` puts the actually valid signatures and code examples into the context.

โ›” WHEN NOT TO?

Questions about your own, private code

Context7 delivers documentation for public libraries โ€” it knows nothing about the internal structure of your own project.

Better: For understanding a codebase, use a code graph tool like Graphify or the agent's normal file tools.

Working completely offline

The recommended path is a hosted endpoint (mcp.context7.com) โ€” without an internet connection no docs arrive.

Better: Save the needed doc pages locally beforehand and hand them to the agent as files.

SOURCES