@aaronmaturen/pi-context7
v1.0.1
Published
Context7 extension for pi - fetches up-to-date library documentation via context7.com
Downloads
170
Maintainers
Readme
pi-context7
A pi extension that brings Context7 library documentation into your coding sessions.
Instead of relying on potentially stale training data, the LLM can pull real, up-to-date documentation snippets directly from a library's official docs at query time.
How it works
The extension registers two tools that the LLM can call:
| Tool | Purpose |
| -------------------- | ---------------------------------------------------------------------------------------------------------- |
| resolve_library_id | Search context7.com for a library by name; returns ranked matches with IDs, trust scores, and token counts |
| get_library_docs | Fetch documentation snippets for a resolved library ID, optionally focused on a topic |
Typical flow:
- You ask about a library (e.g. "how do I use Drizzle ORM with Postgres?")
- LLM calls
resolve_library_id("drizzle-orm")→ picks the best match - LLM calls
get_library_docs("/drizzle-team/drizzle-orm", { topic: "postgres" })→ gets real docs - LLM answers using current, accurate documentation
Installation
Via npm (recommended)
# Global — available in all projects
pi install npm:@aaronmaturen/pi-context7
# Project-local — saved to .pi/settings.json, shared with your team
pi install -l npm:@aaronmaturen/pi-context7Then restart pi or run /reload.
From source
# Clone and symlink globally
git clone https://github.com/aaronmaturen/pi-context7
ln -s $(pwd)/pi-context7 ~/.pi/agent/extensions/pi-context7
# Or for a quick one-off test without installing
pi -e ./src/index.tsUsage
Just ask pi about any library — the LLM will use the tools automatically when it needs current docs:
you: how do I do server-side rendering with Next.js 15 App Router?
you: show me the zustand persist middleware API
you: what's the correct way to use Drizzle transactions?Or be explicit:
you: use context7 to look up the latest Hono docs on routingConfiguration
No API key required — Context7 has a generous free tier (200 requests/day for anonymous use). The extension sets a X-User-Agent: pi-context7/1.0 header so usage is identifiable.
If you have a Context7 account and want to use a higher quota, the API currently uses session cookies (browser-based auth). Anonymous access is sufficient for typical development use.
Tuning token budgets
The default tokens value is 10,000. For complex topics or large APIs you can ask for more:
you: fetch 25000 tokens of the React Server Components docs from context7The LLM will pass the appropriate tokens value to get_library_docs.
No npm dependencies
The extension uses only Node.js built-ins (fetch) and pi's own utilities. No npm install required.
Files
pi-context7/
├── README.md
├── package.json # pi extension entry point declaration
└── src/
└── index.ts # Extension — two tools + session status indicatorContext7 API
GET https://context7.com/api/v1/search?query=<name>— search librariesGET https://context7.com/api/v1/<library-id>?tokens=<n>&topic=<t>— fetch docs
See context7.com and the Context7 MCP server for more details.
