Context7 Skill
Use this skill when the task needs current library or framework documentation, version-specific API usage, setup guidance, code examples, or troubleshooting for a programming package.
Core Rule
Use the mcporter skill to discover a configured Context7-capable MCP server, then call it by the selected server name. Do not require a particular gateway, server name, URL, credential, or native Context7 wrapper syntax.
Tool Choice
- Use
Context7-resolve-library-idfirst when the user names a package, framework, product, or library without an exact Context7 ID. - Use
Context7-query-docswhen you have a Context7-compatiblelibraryId. - Skip resolution only when the user already provides a valid ID like
/vercel/next.js,/vercel/next.js/v15.1.8, or/vercel/next.js@v15.1.8. - Keep each docs query scoped to one concept. Split broad requests into separate calls.
Preflight and Library Selection
- On the first Context7 lookup in a task, first verify that
mcporteris installed, then run the bounded capability discovery inreferences/mcporter-workflow.md. Select a healthy configured server only when it exposes both library-resolution and docs-query tools. - Select an exact library-name match before comparing documentation coverage, source reputation, benchmark score, and version fit.
- When two candidates are materially ambiguous, name the top candidates and the selection reason in the answer. Do not silently choose a different package with a similar name.
- When the user supplies a version-pinned ID, preserve that pin. If it is not indexed, say so before using an unpinned candidate.
Quick Commands
mcporter list --schema --json --timeout 7000
mcporter call <context7-server>.resolve-library-id \
--args '{"libraryName":"Next.js","query":"How to implement middleware authentication"}' \
--output json
mcporter call <context7-server>.query-docs \
--args '{"libraryId":"/vercel/next.js","query":"How to implement middleware authentication with redirects"}' \
--output json
Workflow
- Identify the library and the exact task.
- Resolve the library ID unless an ID was already supplied.
- Pick the best ID using name match, documentation coverage, source reputation, benchmark score, and version fit.
- Query docs with a focused natural-language question.
- Answer from returned snippets and include their source URLs. Call out version-sensitive behavior explicitly.
Failure and Fallback
- Preserve the discovery lookup trace for the task. If discovery finds no healthy Context7-capable server, report its machine-readable reason and state that the MCP lookup is unavailable. If the selected server call fails, try each remaining
candidateServersentry once, then report every attempted server and failure before using the next fallback. Do not imply that Context7 returned documentation. - If a supplied
libraryIdis rejected, rerunContext7-resolve-library-idwith the library name. Do not silently replace a user-supplied version pin; state when the exact version is not indexed. - Use the direct REST fallback only when
CONTEXT7_API_KEYis available. Otherwise, retrieve the relevant upstream official documentation with the runtime's web-fetch capability and cite the fetched URL. - On
429,500,503, or504from the REST API, follow the backoff guidance inreferences/api-fallback.md. On401,403, or404, explain the failed condition and do not retry blindly.
Response Contract
For every successful lookup, state the selected libraryId, selected MCP server, whether it was version-pinned, and the returned source URL or URLs. When resolution was ambiguous, include the deciding factor. When a fallback was used, state MCP unavailable, REST fallback, or upstream official docs and why.
Safety and Decision Checkpoint
- Do not send private code, credentials, or proprietary snippets in a Context7 query.
- Do not use native Context7 wrapper syntax or present a memory-only answer as retrieved documentation.
- Do not combine unrelated concepts in one query.
- 🔴 CHECKPOINT: Before querying private or teamspace documentation, or sending any user-provided code excerpt, obtain the user's confirmation.
- 🔴 CHECKPOINT: Before producing an execution plan for a production authentication/security change, migration, or potentially destructive operation, verify the exact version against an official source URL and obtain the user's confirmation. If no official source is available, label the conclusion
unverifiedrather than presenting it as settled.
Coverage and Limits
- Context7 retrieves current documentation and code examples for libraries, websites, package docs, llms.txt sources, uploaded docs, and other indexed sources.
- Library IDs usually use
/owner/repo,/<source>/<id>,/packages/<name>,/npm/<name>,/websites/<domain>,/llmstxt/<source>, or/docs/<name>. - Version pinning supports
/owner/repo/<version>and/owner/repo@<version>. - Context7 data is community-contributed; verify important behavior against returned source URLs or upstream docs when risk is high.
- API keys unlock higher rate limits and private/teamspace features, but a configured Context7-capable MCP server should remain the default path.
Detailed References
Use references/mcporter-workflow.md for command patterns, field shapes, query design, and source-backed answer patterns.
Use references/api-fallback.md only when the MCP path through mcporter is unavailable, when validating a direct Context7 API integration, or when the task specifically asks for REST API calls.
Official Documents
These are the official documents this skill was built from:
https://context7.com/docs/overviewhttps://context7.com/docs/api-guidehttps://github.com/upstash/context7
