Documentation Lookup with Context7
Use Context7 MCP when a user asks about a library, framework, or API. Check the current docs instead of using memory alone.
Tools
resolve-library-id: Finds the Context7 ID for a library.query-docs: Gets docs and code for a valid library ID.
Always get a valid library ID before you call query-docs.
When to Use This Skill
Use this skill when the user:
- Asks how to install or set up a tool.
- Asks about config.
- Needs code that uses a library.
- Asks how an API works.
- Asks for current code or docs.
- Names a library, framework, SDK, or API.
Examples include React, Vue, Svelte, Next.js, Express, Tailwind CSS, Prisma, and Supabase.
Do not use this skill for code that does not depend on a named tool or API.
Steps
1. Find the Library ID
Call resolve-library-id with:
libraryName: The library or product name.query: The user's full question.
Example:
libraryName: "Next.js"
query: "How do I add middleware in Next.js 15?"Do not guess the library ID.
2. Pick the Best Match
Pick one result. Use these rules in order:
- Pick the exact library name.
- Pick the official project when you can.
- Match the version named by the user.
- Pick a high trust source.
- Pick the result with the best score.
Do not pick a fork, plugin, or old version unless the user asks for it.
If two results still look the same, use one more resolve-library-id call with a clearer query.
If there is no good match, say that Context7 did not return a clear match. Do not make up an ID.
3. Get the Docs
Call query-docs with:
libraryId: The ID chosen in step 2.query: A short and clear form of the user's task.
Example:
libraryId: "/vercel/next.js"
query: "Next.js 15 middleware file name, setup, and a small example"Ask for only the facts needed for the answer. This helps Context7 return useful text and code.
4. Answer from the Docs
Use the returned docs to answer the user.
- Give the direct answer first.
- Use a small code sample when it helps.
- Name the version when version rules matter.
- Keep required imports and setup steps.
- Do not claim that the docs say something they do not say.
- If the docs are not clear, say what is unclear.
- If the docs conflict, favor the official and version-matched result. Tell the user about the conflict.
- If the user did not give a version, do not guess one. State which docs you used when it matters.
Call Limit
For one user question:
- Call
resolve-library-idno more than three times. - Call
query-docsno more than three times.
Use a second call only when the first result is missing key facts or covers the wrong version.
After three calls, stop. Give the best supported answer and state any gap. Do not guess.
Edge Cases
More Than One Library
Resolve each named library on its own. Query only the docs needed for the task.
A Named Version
Use a version ID when Context7 offers one. If it does not, use the closest official docs and warn that the exact version was not found.
An Unknown Name
The user may misspell a name or use a short name. Use the full question to find the likely match. If the match is still not clear, ask the user which tool they mean.
A Changed or Removed API
Check the version and current docs. Explain the new API. Mention the old API only if it helps with the user's code.
Context7 Is Not Ready
If the tools are missing or fail, say so. Use only facts you can support. Mark any older knowledge as possibly out of date.
Full Usage Example
User request:
Write a Prisma query that gets a user and their posts.First call:
resolve-library-id:
libraryName: "Prisma"
query: "Write a Prisma Client query that gets one user and their posts."Choose the official Prisma result, such as:
/prisma/prismaSecond call:
query-docs:
libraryId: "/prisma/prisma"
query: "Prisma Client findUnique query that includes a user's posts"Then answer with a short example based on the returned docs:
const user = await prisma.user.findUnique({
where: { id: userId },
include: { posts: true },
});Also note any needed model link, version rule, or return type shown in the docs.