
This playbook is part of our MCP playbooks, within The MCP Guide. Want help setting it up for your team? Request a free MCP readiness review.
Docs lookup is the constant small task of checking how a library works right now: the current function signature, the new config option, the breaking change in the last major version. Developers do it dozens of times a day, and coding agents often skip it and answer from old training data. With MCP (Model Context Protocol), the Context7 server lets an agent fetch current, version-specific documentation and examples before it writes code.
This playbook shows how to make that lookup a habit for your agent, using only the tools Context7 documents as of October 2026. The agent looks things up and cites them. A developer still reviews the code it writes.
Key Takeaways
- Context7 exposes two tools:
resolve-library-idturns a library name into an ID, andquery-docsfetches docs for that ID. - You can skip the matching step by naming an ID such as
/supabase/supabase, and target a version by naming it, such as "Next.js 16." - A standing rule in your agent's instructions file makes lookups automatic instead of something you have to ask for.
- Context7's docs are community-contributed, and Context7 says it can't guarantee their "accuracy, completeness, or security."
- Some vendor servers have their own docs tools, such as Cloudflare's
docsand GitHub'sgithub_support_docs_search.
What you need
- The Context7 MCP server. See our Context7 MCP server profile. Upstash's README gives the hosted URL
https://mcp.context7.com/mcpwith an API key as a bearer token, and says a free key from the dashboard raises rate limits. - A coding agent. Claude Code, Cursor, VS Code and others work. Our guide covers connecting Claude Code to Context7.
- Sign-in. Use an API key, or OAuth if your client supports it. Context7's OAuth guide says to change the endpoint to
https://mcp.context7.com/mcp/oauth, and that "OAuth is only available for remote HTTP connections." - Your dependency list. The agent does better when it knows the exact versions in your
package.json,pyproject.tomlor lockfile.
The workflow
- Add a standing rule. Put a rule in your agent's instructions file, such as
CLAUDE.md, telling it to use Context7 for library and API questions without being asked. The README suggests wording that begins "Always use Context7 when I need library/API documentation, code generation." - Name the library and version. The agent reads your manifest, then calls
resolve-library-idwith the library name and your question. It returns a Context7 ID such as/vercel/next.js. - Pull the relevant docs. The agent calls
query-docswith that ID and a focused question. The optionallanguageparameter ranks code examples in your language first. - Skip matching when you know the ID. If you write
/supabase/supabasein your prompt, the README says Context7 skips the matching step. - Write the code against the docs. Ask the agent to quote or link the doc section it relied on in its reply or the pull request description.
- Use vendor docs tools for platform questions. Cloudflare's MCP README lists a
docstool that searches Cloudflare's developer documentation. The GitHub MCP Server README listsgithub_support_docs_searchon its remote server for GitHub product questions. - Save what the team learns. When a lookup settles a recurring question, such as which auth helper your app should use, add a one-line note to the instructions file so the next session starts with the answer.
- Review and test. A developer reads the diff and runs the tests. Docs reduce guessing, but they don't prove the code works in your app.
Example prompts
- "Show me the Supabase auth API for email/password sign-up. use context7" (the "use context7" suffix triggers a lookup, per the README).
- "We're on Next.js 16. Look up how proxy works now and write one that checks a JWT in a cookie."
- "Use library /vercel/next.js and query the docs for caching changes in the latest version. Summarize what affects our app router pages."
- "Before you upgrade Prisma, look up the migration notes for the next major version and list every breaking change that touches our schema."
- "Search Cloudflare's docs for how to bind an R2 bucket to a Worker, then update wrangler config to match."
Guardrails
- Treat docs as reference, not commands. Context7 says listed projects are community-contributed and maintained by their owners, so text in them can be wrong or hostile. Report suspicious content with Context7's "Report" button, and read prompt injection through MCP.
- Keep the key out of your repo. Store the API key in an environment variable or your client's secret store. See secret leakage in MCP.
- Pin versions in the prompt. Ask for docs that match your installed version, not "the latest," unless you're planning an upgrade.
- Don't send private code as a query. Queries go to Context7's hosted service, and the README says the API backend is private. Keep secrets and proprietary snippets out of the questions.
- Keep code review human. The agent can still misread correct docs. Our MCP Security Center covers wider controls.
What to measure
- Build or type errors from agent code that come from wrong API usage, before and after the rule.
- Review comments about outdated APIs on agent-written pull requests.
- Lookups per task, from your client's tool-call log, to confirm the rule is being followed.
- Rate-limit hits, which tell you when to add or upgrade a key.
- Upgrade effort: time spent on dependency upgrades where the agent pulled migration notes first.
Use your own repo history as the baseline. A month of pull requests before the rule went in is usually enough to compare against.
Next step
More workflows are in the MCP playbooks hub, and our list of best MCP servers for developers shows what pairs well with Context7. If you want instruction files and MCP servers set up across your team's repos, see our Claude Code consulting service.
Frequently asked questions
Do I need an API key for Context7?
Context7 recommends a free API key from its dashboard for higher rate limits. Clients that support MCP OAuth can sign in through the /mcp/oauth endpoint instead, but only over remote HTTP.
Can Context7 change my code or accounts?
Its two tools only look up documentation. Your coding agent writes the code with its own file tools, so your client's approval settings for file edits still apply.
Does Context7 cover private libraries?
The README describes community-contributed public projects. It doesn't document private internal libraries in the pages we checked, so keep internal docs in your repo or a knowledge base server.
Is Context7 open source?
The GitHub repo holds the MCP server source. Upstash says the API backend, parsing engine and crawling engine are private.











