I Built a CLI That Gives Your LLM Accurate Library Docs — No MCP Server Needed

Published: (March 2, 2026 at 05:23 AM EST)
3 min read
Source: Dev.to

Source: Dev.to

The Problem

You’re building with Next.js 15 and ask your AI assistant to write an API route. It gives you the Pages Router pattern from Next.js 12. You paste React docs into the prompt, but they’re already outdated by the time you copy them.

Context7 solved this by indexing documentation directly from source repos and serving it through an MCP server. Cursor, Claude Code, and other AI editors use it to get real, version‑specific docs instead of hallucinated APIs.

But MCP has a constraint: you need an MCP‑compatible client. If you’re working in the terminal, running a script, or using a local LLM — you’re out of luck.

The Solution

I built c7 — a CLI that pulls from the same Context7 database and outputs docs as plain text to stdout.

c7 react hooks
c7 express middleware
c7 nextjs "app router"

No server, no configuration, no IDE integration. Just text you can pipe anywhere.

How It Works

The CLI does two things:

  1. Resolves a library name to a Context7 ID (e.g., react/websites/react_dev)
  2. Fetches documentation for that library, filtered by topic

Under the hood it makes two API calls using Node.js built‑in fetch against Context7’s v2 API. The entire project is ~220 lines across two files with zero dependencies.

bin/c7.js   — 136 lines (CLI parsing + output formatting)
lib/api.js  —  87 lines (Context7 v2 API client)

No axios. No commander. No chalk. Just process.argv and fetch.

The Real Power: Pipes

Because c7 outputs plain text to stdout, it composes with everything.

Pipe into LLMs

# Claude
c7 react hooks | claude "summarize the key patterns and show examples"

# Ollama (local models)
c7 express middleware | ollama run codellama "explain this middleware pattern"

# Any LLM CLI
c7 nextjs "api routes" | llm "write an API route based on these docs"

Pipe into Unix tools

# Search docs
c7 nextjs "api routes" | grep "export"

# Page through docs
c7 prisma "schema" | less

# Copy to clipboard (macOS)
c7 react "useEffect" | pbcopy

# Build context files
c7 nextjs "app router" >> context.txt
c7 react "server components" >> context.txt

Use in scripts

# Pre‑load context for a coding agent
DOCS=$(c7 nextjs "app router middleware")
claude "Build a Next.js middleware that handles auth. Use these docs:\n$DOCS"

c7 vs MCP Server

FeatureMCP Serverc7 CLI
SetupInstall server, configure MCP client, restart editor (npx @vedanth/context7)Zero‑config, runs anywhere
Works inMCP‑compatible editorsTerminal, scripts, CI, anywhere
ComposableLimited to MCP protocolPipes, redirects, subshells
DependenciesSeveral npm packagesNone
Lines of code~1000+~220

They’re complementary: use the MCP server in your editor, use c7 everywhere else.

Getting Started

# Run without installing
npx @vedanth/context7 react hooks

# Or install globally
npm install -g @vedanth/context7
c7 react hooks
c7 express middleware
c7 nextjs "app router" | claude "summarize"

No API key required for basic usage. For higher rate limits, get a free key at the Context7 dashboard.

  • GitHub:
  • npm:
  • Landing page:
  • Context7:
0 views
Back to Blog

Related posts

Read more »