resolveLibraryId tool searches Context7’s library database and returns matching results with their Context7-compatible library IDs. This is typically the first step in a documentation lookup workflow.
Usage
Configuration
Parameters
Context7ToolsConfig
Configuration options for the tool.
Returns
Returns an AI SDKtool that can be used with generateText, streamText, or agents.
Tool Behavior
When the AI model calls this tool, it:- Takes a
queryandlibraryNameparameter from the model - Searches Context7’s database for matching libraries
- Returns formatted results including:
- Library ID (e.g.,
/reactjs/react.dev) - Title and description
- Number of code snippets available
- Source reputation score
- Available versions
- Library ID (e.g.,
Input Schema
The tool accepts the following input from the AI model:string
required
The user’s original question or task. This is used to rank library results by relevance to what the user is trying to accomplish.
string
required
Library name to search for (e.g., “react”, “next.js”, “vue”)
Output Format
On success, the tool returns the search results as plain text, formatted for easy consumption by the AI model:Examples
Basic Usage
With Custom API Key
Inspecting Tool Calls
Selection Guidance
The tool’s description instructs the AI model to select libraries based on:- Name similarity - Exact matches are prioritized
- Description relevance - How well the description matches the query intent
- Documentation coverage - Libraries with more code snippets are preferred
- Source reputation - High/Medium reputation sources are more authoritative
- Benchmark score - Quality indicator (100 is the highest)
Related
- queryDocs - Fetch documentation using the resolved library ID
- Context7Agent - Pre-built agent that handles the full workflow