Configuration & CLI MCP & Search

OpenClaw Context7: Live Documentation Search via MCP

LLM training data goes stale. Library APIs change. Context7 solves this for developer-facing agents — connecting your OpenClaw agent to live, version-accurate documentation for thousands of libraries via MCP, in under 10 minutes.

JD
J. Donovan
Technical Writer
Feb 27, 2025 12 min read 5.3k views
Updated Feb 27, 2025
Key Takeaways
  • Context7 is an MCP server providing live, version-accurate documentation for thousands of open-source libraries
  • Add it to OpenClaw's MCP config with type: npx and package @context7/mcp-server — no separate install required
  • Context7 fetches live docs rather than serving a static snapshot, so your agent gets current API references
  • Works alongside Tavily or SearXNG — documentation queries route to Context7, general web queries to your search provider
  • Specify library versions explicitly in queries to get docs for specific releases

Ask a stock LLM about a React hook that was added six months ago and you'll get either silence or a confident wrong answer. Context7 fixes this for developer agents — when your agent needs documentation, it queries Context7 and gets the actual current docs, not training-data approximations.

What Context7 Actually Does

Context7 is an MCP server that maintains an index of live documentation for open-source libraries. When your OpenClaw agent queries it — "how do I use the useFormStatus hook in React 19?" — Context7 fetches the current React 19 documentation for that hook and returns it as structured content the agent can reason from.

The difference from web search: Context7 returns documentation, not web pages about documentation. No blog posts, no Stack Overflow threads, no outdated tutorials — just the actual library docs, at the version you specify.

This matters most for:

  • Libraries that release frequently (React, Next.js, LangChain, Anthropic SDK)
  • APIs that changed significantly after the LLM's training cutoff
  • Version-specific queries where the answer genuinely differs between releases
  • Agents helping developers who are using a specific version of a framework
ℹ️
Context7 complements, doesn't replace, web search
Context7 is excellent for library documentation. It doesn't cover blog posts, tutorials, news, or general web content. For a developer-facing OpenClaw agent, you typically want both: Context7 for "how does X API work" and Tavily or SearXNG for "what changed in X in the latest release" and general knowledge queries.

MCP in 60 Seconds

MCP (Model Context Protocol) is a standard that lets AI agents connect to external tool servers. Instead of baking every capability into the agent itself, MCP lets you attach external servers that expose specific tools — and the agent calls those tools when it needs them.

Context7 is one such server. It exposes two tools: resolve-library-id (which maps a library name to Context7's internal ID) and get-library-docs (which returns documentation for a specific library and optional topic). OpenClaw's MCP integration makes these tools available to your agent automatically once Context7 is configured.

You don't write any code to use MCP tools. You configure them in gateway.yaml and the agent can call them in any conversation where it needs documentation.

Adding Context7 to OpenClaw

Context7 runs as an npx-launched subprocess. OpenClaw starts it automatically based on your config — you don't need to install or run anything separately.

Add this to your gateway.yaml:

mcp:
  servers:
    - name: context7
      type: npx
      package: "@context7/mcp-server"
      args: []
      env: {}
      autoStart: true

That's the entire configuration. On next agent startup, OpenClaw will launch the Context7 MCP server, register its tools, and make them available in every conversation. Verify it loaded by checking startup logs for MCP server context7: ready.

If you're running multiple MCP servers, list them all under the same servers array:

mcp:
  servers:
    - name: context7
      type: npx
      package: "@context7/mcp-server"
      autoStart: true
    - name: another-mcp-server
      type: npx
      package: "@some/other-server"
      autoStart: true
⚠️
npx requires Node.js on your server
The npx launch type requires Node.js installed on the same machine as your OpenClaw gateway. Run node --version to verify. If Node isn't installed, npx-type MCP servers won't start. Install Node.js 18+ via your package manager or nvm before adding Context7 to your config.

What Context7 Covers

As of early 2025, Context7 supports thousands of libraries across multiple ecosystems. The coverage is strongest in JavaScript/TypeScript and Python, with solid coverage of major Go, Rust, and Java libraries.

Particularly well-covered categories:

  • Frontend frameworks: React, Next.js, Vue, Nuxt, SvelteKit, Astro
  • Backend frameworks: FastAPI, Django, Flask, Express, NestJS, Hono
  • AI/ML libraries: LangChain, LlamaIndex, Anthropic SDK, OpenAI SDK, Hugging Face
  • Databases and ORMs: Prisma, Drizzle, Supabase, MongoDB, PostgreSQL drivers
  • Infrastructure: Terraform providers, Kubernetes client libraries, Docker SDK

If a library isn't in Context7's index, the tool returns an appropriate not-found response and the agent falls back to its training data or web search. The agent doesn't break — it just uses whatever knowledge it has.

Using Context7 Alongside Web Search

The best setup for a developer-facing OpenClaw agent combines Context7 for documentation with a web search provider for everything else. Here's how this works in practice:

Your agent receives: "What's the best way to handle optimistic updates in React Query v5?"

With both Context7 and Tavily configured:

  1. The agent recognizes this is a library-specific documentation question
  2. It calls Context7's resolve-library-id with "react-query" or "tanstack-query"
  3. It calls get-library-docs with the resolved ID and topic "optimistic updates"
  4. Context7 returns the current TanStack Query v5 documentation on optimistic updates
  5. The agent synthesizes an answer grounded in actual current docs

If the question were instead "what changed in React Query between v4 and v5?", the agent would likely use Tavily for web search to find migration guides and changelog content — broader than what documentation search covers.

You don't need to configure routing rules. A well-prompted agent naturally learns to use the right tool for the right query type. Document this in your soul.md or identity.md: "When answering questions about specific library APIs, use Context7. When answering general questions or looking for recent news, use web search."

Common Mistakes

Not having Node.js installed and wondering why Context7 doesn't start. The npx launch type is a Node.js subprocess. Check node --version first.

Expecting Context7 to cover every library. It doesn't. If your agent heavily relies on a niche or proprietary library, Context7 won't help — fall back to web search or provide documentation directly in the system prompt.

Not specifying library versions in queries when version matters. Context7 supports version-specific queries. If your agent is helping with a project on Next.js 13 (Pages Router) and the default Context7 returns Next.js 14 App Router docs, the answers will be wrong. Teach your agent to ask users about their library version before querying Context7.

Restarting OpenClaw and forgetting that the first Context7 invocation after a cold start has higher latency while the subprocess initializes. The second and subsequent calls are faster. Don't tune timeouts based on the cold-start response time.

Frequently Asked Questions

What is Context7 and how does it work with OpenClaw?

Context7 is an MCP server that provides live, version-accurate documentation for thousands of open-source libraries. Connected to OpenClaw via MCP, your agent can query Context7 for up-to-date API references and code examples — instead of relying on potentially outdated training data. It's the documentation layer for developer-facing agents.

What is MCP and why does Context7 use it?

MCP (Model Context Protocol) is a standard for connecting AI agents to external tool servers. Context7 implements MCP to expose documentation search as a callable tool. OpenClaw's MCP support means you add Context7 via config — no custom code needed. The agent calls it automatically when it needs documentation.

How do I add Context7 to my OpenClaw MCP config?

Add Context7 to the mcp.servers block in gateway.yaml with type npx and package @context7/mcp-server. Set autoStart: true and OpenClaw launches it as a subprocess at startup. No separate installation — npx handles it. Node.js must be installed on the same machine.

Which libraries does Context7 support?

Thousands of libraries across JavaScript/TypeScript and Python primarily, with solid Go, Rust, and Java coverage. Strongest support for React, Next.js, Vue, FastAPI, Django, LangChain, Anthropic SDK, Supabase, Prisma, and similar widely-used open-source projects. Check the Context7 website for the current catalog.

Does Context7 return the latest version of documentation?

Yes — Context7 fetches live documentation, not static snapshots. Query for React hooks and you get current documentation. Specify a version explicitly for older release docs. This version-awareness is the core advantage over training data, which has a cutoff and may not reflect recent API changes.

Can I use Context7 alongside Tavily or SearXNG in OpenClaw?

Yes. OpenClaw supports multiple MCP servers and search providers simultaneously. Context7 handles library documentation; Tavily or SearXNG handles general web search. Your agent uses the appropriate tool per query type — documentation questions route to Context7, general and news queries route to your search provider.

JD
J. Donovan
Technical Writer
J. Donovan documents AI agent integrations and tooling for developer audiences. Has configured MCP servers including Context7, Playwright, and custom internal servers for production OpenClaw deployments in developer tooling companies.
Build Smarter Developer Agents
MCP integrations and tooling guides — free every week.