Step 1: Resolve Library ID
Find the Context7 library ID for the library you need:
bash
mcporter call 'context7.resolve-library-id(query: "how to use React hooks", libraryName: "react")' --output json
This returns matching libraries ranked by relevance. Pick the libraryId from the best match (format: /org/project).
Step 2: Query Documentation
Use the resolved library ID to fetch docs:
bash
mcporter call 'context7.query-docs(libraryId: "/vercel/next.js", query: "how to set up middleware for authentication")' --output json
Common Examples
bash
# React hooks docs mcporter call 'context7.resolve-library-id(query: "React hooks", libraryName: "react")' --output json mcporter call 'context7.query-docs(libraryId: "/facebook/react", query: "useEffect cleanup patterns")' --output json # Next.js routing mcporter call 'context7.resolve-library-id(query: "Next.js app router", libraryName: "next.js")' --output json mcporter call 'context7.query-docs(libraryId: "/vercel/next.js", query: "app router dynamic routes")' --output json # Python library mcporter call 'context7.resolve-library-id(query: "pandas dataframe", libraryName: "pandas")' --output json mcporter call 'context7.query-docs(libraryId: "/pandas-dev/pandas", query: "merge dataframes on multiple columns")' --output json