Skip to main content

Context7

Live library documentation fetching service by Upstash. Pulls version-specific docs and code examples into AI agent context on demand, eliminating hallucinated or outdated API calls.

Two Delivery Modes

Both modes access the same upstream doc index; prefer MCP when the agent harness supports it natively, ctx7 CLI as fallback.

Per-Platform Usage

Cross-platform setup: Claude Code → Cross-Platform Migration Matrix (MCP layer section). MCP ecosystem overview: Our Stack vs omp.

MCP Tools Reference

Two tools, always invoked in sequence: In Claude Code these surface as mcp__context7__resolve-library-id and mcp__context7__query-docs. Usage pattern:

CLI Commands Reference

--json returns structured output suitable for piping into scripts.

REST API Reference

For scripting or non-MCP/CLI integrations. Auth: Authorization: Bearer <CONTEXT7_API_KEY> on both endpoints.

When to Use / When to Skip

Use before: implementing any library API, framework feature, CLI tool invocation, or external API call where flag/method names could have changed. Skip for: pure reasoning tasks, git operations, file manipulation with no external library dependency, standard Unix tools (ls, grep, cat). The CLAUDE.md rule (always-loaded): “Before using any library, framework, CLI tool, or API — resolve current docs via context7 MCP.” Applied in this repo on every ingest that touches a library. Similar tool (wiki search, not doc fetch): qmd. Wrapped as one of three surfaces (alongside web/code search) in ketch’s ketch docs command — same resolve → fetch flow, unified under a single agent-facing CLI.

Key Storage and Rotation

Single source of truth: ~/secrets/.env Synced to:
  • ~/.claude/.env (Claude Code)
  • ~/.config/opencode/.env (Opencode)
Variable name: CONTEXT7_API_KEY. Rotate at context7.com, then update all three locations.