Skip to main content

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:
1

Identify Library Need

User asks a question that requires library documentation.
2

Resolve Library ID

If the library ID is unknown, use resolve-library-id to find it.
3

Query Documentation

Use query-docs with the library ID to retrieve relevant documentation.
4

Generate Response

LLM uses the documentation to generate an accurate, up-to-date response.

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

string
required
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?"
Do not include sensitive information such as API keys, passwords, credentials, personal data, or proprietary code.
string
required
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

string
Context7-compatible identifier in format /org/projectExample: /vercel/next.js
string
Human-readable library or package nameExample: Next.js
string
Short summary of the library’s purposeExample: The React Framework for Production
number
Number of available code examples in the documentationHigher values indicate more comprehensive documentation
string
Authority indicator for the library’s sourceValues: High, Medium, Low, Unknown
number
Quality indicator (0-100, where 100 is highest quality)Based on documentation completeness, code examples, and community engagement
array
List of available versions for this libraryExample: 15.1.0, 15.0.0, 14.2.0Use format /org/project/version to query specific versions

Selection Process

When multiple libraries match, the LLM should select based on:
  1. Name similarity - Exact matches prioritized
  2. Description relevance - Match to query intent
  3. Documentation coverage - Higher Code Snippet counts preferred
  4. Source reputation - High/Medium reputation more authoritative
  5. Benchmark score - Higher scores indicate better quality

Usage Example

Best Practices

Do not call this tool more than 3 times per question. If you cannot find what you need after 3 calls, use the best result you have.
  • 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:
Actions:
  1. Try alternative library names or spellings
  2. Check for typos in libraryName
  3. Suggest related libraries to user
  4. 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

You must call resolve-library-id first to obtain the library ID, unless the user explicitly provides a library ID in the format /org/project or /org/project/version.

Parameters

string
required
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
string
required
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"
Bad examples:
  • "auth" (too vague)
  • "hooks" (too generic)
  • "help" (no context)
Do not include sensitive information such as API keys, passwords, credentials, personal data, or proprietary code.

Response Format

The tool returns intelligently ranked documentation and code examples:
The response includes:
  • 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:
Or mention the version in your query:
Context7 will automatically match the appropriate version from the versions list.

Best Practices

Do not call this tool more than 3 times per question. If you cannot find what you need after 3 calls, use the best information you have.
  • 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:
Actions:
  1. Verify library ID format is /org/project
  2. Call resolve-library-id to get the correct ID
  3. Check if the library exists in Context7
Library Not Found (404):
Actions:
  1. Try searching with resolve-library-id
  2. Verify library name spelling
  3. Check if library is available in Context7 catalog

Tool Workflow

Complete Example

Here’s how the tools work together:
1

User Request

2

Resolve Library

Returns: /mongodb/docs
3

Query Documentation

Returns: Code examples and documentation for MongoDB connection pooling
4

Generate Response

LLM uses the retrieved documentation to generate accurate, up-to-date code.

With Explicit Library ID

When user provides the library ID:
1

User Request

2

Query Documentation (Skip Resolve)

3

Generate Response

LLM uses the documentation to generate the authentication code.

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
See Configuration → Rate Limits for details.

Privacy & Security

Never include sensitive data in queries:
  • API keys, passwords, or credentials
  • Personal identifiable information (PII)
  • Proprietary or confidential code
  • Customer data
  • Security tokens
All queries are sent to the Context7 API for:
  • Intelligent reranking of documentation
  • Context generation
  • Relevance scoring
See Privacy Policy for details on data handling.

Annotations

Both tools include the readOnlyHint: 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