# Context7 MCP

> Fetch version-sensitive library/API docs via Context7 MCP (setup, examples, method usage). Not for general CS concepts or SOTA surveys.

- Skill: `dmoreq/context7-mcp` (Agent Skill)
- Install (CLI): `npx skillmds@latest add dmoreq/context7-mcp`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dmoreq/context7-mcp/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: dmoreq (https://skillmd.com/u/dmoreq)
- Updated: 2026-09-22
- Page: https://skillmd.com/skills/dmoreq/context7-mcp

---


# Context7 Documentation Skill

Use Context7 to fetch up-to-date library documentation instead of relying on training data.

## When to Activate
Activate when the user asks about:
- Setup / configuration of a library or framework
- Code examples involving specific libraries
- API references or method usage
- Version-specific behavior (e.g., "FastAPI 0.115", "Pydantic v2", "React 19")

Do **not** activate for:
- General programming concepts
- Business logic or pure algorithm questions
- Refactoring existing project code that does not require external docs

## How to Use

### Step 1: Resolve Library ID
Skip resolve when the user already passed a Context7 ID (`/org/project` or `/org/project/version`). Otherwise call `resolve-library-id` with:
- `libraryName`: name of the library (e.g., "fastapi", "pandas", "next.js")
- `query`: short description of what the user needs (helps ranking)

Cap resolve retries at 3 (try alternate names, then stop).

### Step 2: Select Best Match
Prefer:
- Exact or closest name match
- Official / primary package over forks
- Higher benchmark / reputation score
- Version-specific ID if the user mentioned a version

### Step 3: Query Documentation
Call `query-docs` with:
- `libraryId`: the selected Context7 ID (e.g., `/tiangolo/fastapi`)
- `query`: focused on **one single concept**

If the question covers multiple distinct topics, make separate `query-docs` calls for each concept.

### Step 4: Answer
- Base the response on the fetched documentation
- Include relevant code examples from the docs
- Mention the library version when relevant

## Guidelines
- Keep each `query-docs` call scoped to one concept.
- Prefer official sources when multiple matches exist.
- If resolve returns poor results, try alternate names (e.g., "next.js" instead of "nextjs").
- Only fetch docs when current information is actually needed.

## Notes for Python
- Works well with common Python libraries: FastAPI, Pydantic, SQLAlchemy, pandas, Polars, httpx, uv, ruff, etc.
- Prefer the official/primary package when multiple matches appear.

## Related Skills
- Use from any implementation skill when library/API docs are version-sensitive.
- Do not replace **tech-research** for approach comparison or SOTA survey.

## Final Checklist
- [ ] User query actually requires up-to-date documentation (not just general knowledge)
- [ ] Correct library ID resolved (official/primary package prioritized)
- [ ] Each `query-docs` call is focused on a single concept
- [ ] Response is grounded in information fetched from Context7
- [ ] Library version cited when relevant
- [ ] No redundant or unnecessary tool calls made

