How to use Context7 for documentation
This guide shows how to use the Context7 MCP server to search and query technical documentation.
Prerequisites
- MCP enabled in mini-me
- A valid Context7 API key:
CONTEXT7_API_KEY - Context7 server configured in your configuration file
Steps
1. Get a Library ID
Before you can query documentation, you must obtain a Context7 Library ID.
Use the context7_resolve_library_id tool with two required parameters:
query: What you're looking for (e.g., "React hooks")libraryName: The library name (e.g., "react")
Example query:
"I want to understand how useEffect works in React"
The model should call:
context7_resolve_library_id(query="useEffect React", libraryName="react")
Expected result: A library ID in the format /org/project (e.g., /facebook/react)
2. Query the documentation
Once you have the library ID, use context7_query_docs with:
libraryId: The ID obtained in step 1 (e.g.,/facebook/react)query: Your specific question (e.g., "useEffect cleanup function")
Example query:
"How to clean up a useEffect in React?"
The model should call:
context7_query_docs(libraryId="/facebook/react", query="useEffect cleanup")
Common Use Cases
| Need | Example Query | Tools Used |
|---|---|---|
| Understand a library | "Explain how Redux works" | resolve-library-id, query-docs |
| Find examples | "Show me useState examples" | resolve-library-id, query-docs |
| Solve a problem | "Why does my useEffect run multiple times?" | resolve-library-id, query-docs |
| Explore an API | "What methods are available in axios?" | resolve-library-id, query-docs |
Variants
- If you already know the library ID: You can directly call
context7_query_docswithout usingresolve-library-id - For multiple libraries: Call
resolve-library-idfor each library, thenquery-docsfor each one
Limitations
- Maximum 3 calls to
resolve-library-idper question - Maximum 3 calls to
query-docsper question - Results depend on the library coverage in Context7's database
See Also
- Tools reference: Available Tools
- Why Context7: Design Decisions
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|