Tools Reference
Context7 MCP Server provides two tools that LLMs can use to access up-to-date documentation and code examples.Overview
The workflow for using Context7 tools:resolve-library-id
Resolves a package or product name to a Context7-compatible library ID.When to Use
Call this tool when:- User mentions a library by name (e.g., “Next.js”, “MongoDB”, “React”)
- You need to find the Context7-compatible library ID
- User does not provide an explicit library ID in format
/org/project
Parameters
The question or task you need help with. This is used to rank library results by relevance.Example:
"How do I set up authentication in Next.js?"Library name to search for and retrieve a Context7-compatible library ID.Example:
"nextjs", "mongodb", "react"Response Format
The tool returns a list of matching libraries with detailed metadata:Response Fields
Context7-compatible identifier in format
/org/projectExample: /vercel/next.jsHuman-readable library or package nameExample:
Next.jsShort summary of the library’s purposeExample:
The React Framework for ProductionNumber of available code examples in the documentationHigher values indicate more comprehensive documentation
Authority indicator for the library’s sourceValues:
High, Medium, Low, UnknownQuality indicator (0-100, where 100 is highest quality)Based on documentation completeness, code examples, and community engagement
List of available versions for this libraryExample:
15.1.0, 15.0.0, 14.2.0Use format /org/project/version to query specific versionsSelection Process
When multiple libraries match, the LLM should select based on:- Name similarity - Exact matches prioritized
- Description relevance - Match to query intent
- Documentation coverage - Higher Code Snippet counts preferred
- Source reputation - High/Medium reputation more authoritative
- Benchmark score - Higher scores indicate better quality
Usage Example
Best Practices
- Provide specific, descriptive queries for better relevance ranking
- Use exact library names when possible
- Check all returned options before selecting
- If ambiguous, ask user for clarification
- Clearly state your selection and reasoning
Error Handling
If no libraries are found:- Try alternative library names or spellings
- Check for typos in
libraryName - Suggest related libraries to user
- Ask user for more specific library information
query-docs
Retrieves and queries up-to-date documentation and code examples from Context7.When to Use
Call this tool when:- You have a Context7-compatible library ID from
resolve-library-id - User provides explicit library ID (e.g.,
/mongodb/docs,/vercel/next.js) - You need specific documentation for a programming task
Prerequisites
Parameters
Exact Context7-compatible library ID retrieved from
resolve-library-id or provided by user.Format: /org/project or /org/project/versionExamples:/mongodb/docs/vercel/next.js/supabase/supabase/vercel/next.js/v14.3.0-canary.87
The question or task you need help with. Be specific and include relevant details.Good examples:
"How to set up authentication with JWT in Express.js""React useEffect cleanup function examples""Configure MongoDB connection pooling"
"auth"(too vague)"hooks"(too generic)"help"(no context)
Response Format
The tool returns intelligently ranked documentation and code examples:- Relevant code examples
- API references
- Configuration instructions
- Best practices
- Links to source documentation
Usage Example
Version-Specific Queries
To query a specific version, include it in the library ID:Best Practices
- Be specific in your queries for better results
- Include context about what you’re trying to accomplish
- Mention versions when relevant
- Ask focused questions rather than broad topics
- Use technical terms that appear in documentation
Error Handling
Invalid Library ID:- Verify library ID format is
/org/project - Call
resolve-library-idto get the correct ID - Check if the library exists in Context7
- Try searching with
resolve-library-id - Verify library name spelling
- Check if library is available in Context7 catalog
Tool Workflow
Complete Example
Here’s how the tools work together:With Explicit Library ID
When user provides the library ID:Rate Limiting
Both tools are subject to rate limits based on authentication:- Anonymous: Limited requests per hour
- Free API Key: Higher limits suitable for development
- Paid Plans: Professional and enterprise limits
Privacy & Security
All queries are sent to the Context7 API for:- Intelligent reranking of documentation
- Context generation
- Relevance scoring
Annotations
Both tools include thereadOnlyHint: true annotation, indicating they:
- Do not modify any data
- Only retrieve information
- Are safe to call multiple times
- Have no side effects
Next Steps
Cursor Setup
Install Context7 in Cursor
Configuration
Configure API keys and options
All Clients
See all supported clients
Troubleshooting
Common issues and solutions