Library docs: use Context7, not training data
One of the global rules my agents load on every session, published as they load it. Links to reference files point at documents I do not publish.
- Source
- rob/agents/policy/claude/context7.md
- Revision
- ca34e4e
Read ~/.claude/reference/context7.md before using Context7 or diagnosing its configuration and quota.
Whenever you research how to use a library, framework, SDK, API, cloud service or CLI tool — even
well-known ones (React, Next.js, Prisma, Express, Tailwind, Django, Spring Boot) — call the
context7 MCP server rather than answering from memory. Covers API syntax, config options, version
migration, library-specific debugging, setup and CLI usage. Prefer it over web search for developer
documentation.
Not for: refactoring, writing scripts from scratch, debugging business logic, code review, or general programming concepts.
Two tools, in order: resolve-library-id (libraryName + query) → query-docs (libraryId +
query). Their own descriptions carry the search technique — one concept per call, specific
full-sentence queries, official punctuation, version-pinned /org/project/version IDs, max 3 calls
per question. Read them; this rule deliberately does not restate them.
Three things the tool descriptions do not tell you:
-
Skip
resolve-library-idwhen you already know the ID. Passing/org/projectstraight toquery-docsis supported and halves the quota cost. -
Check which ID and version actually came back. A pinned version not in the index falls back to latest silently. If the answer hinges on the version, say which one you got.
-
Never put API keys, passwords or credentials in a query — queries go to Context7’s API.
Pick between matches on exact name match, then source reputation (High/Medium over Low/Unknown), then benchmark score, then snippet count.
On quota exhaustion or any tool error: say so out loud, then web-search. Never silently fall back to training data.
Wiring, and what was rejected
Hosted MCP at https://mcp.context7.com/mcp, paid key inlined as Authorization: Bearer ctx7sk-… in
both mcp-servers.json and both Codex config.toml [mcp_servers.context7.http_headers]. This is
deliberate: an env-var CONTEXT7_API_KEY would be unset on camden/jules and in headless runs,
silently dropping every request to the anonymous tier. All requests must carry the paid key.
No npx ctx7, no plugin, no skill. The CLI + Skills route is the more expensive option here, not
the cheaper one: this harness defers MCP tool schemas, so context7 contributes two names to the
deferred list and its schemas load only via ToolSearch at point of use, while the CLI skill’s
description: line would load in every session’s skill listing. The CLI also needs Node ≥18 on
camden/jules, and its per-machine OAuth state silently drops to the anonymous tier in headless runs.
Do not re-open this without a new fact — “there’s a CLI now” is not one.
mintlify-index is retired: absent from this profile’s declarative MCP inventory. Any note saying
context7 was retired in its favour is stale — context7 is the current server, so ignore it.