---
title: "Context7 MCP: Real-Time Documentation"
source: https://docs.autohand.ai/guides/mcp/context7-docs
---

# Context7 MCP: Real-Time Documentation

Stop coding against stale training data. Context7 fetches current documentation for any library and delivers it straight into your Autohand session so the agent always works with the latest APIs.

## What Context7 does

[Context7](https://github.com/upstash/context7) is a documentation-as-context MCP server. Instead of relying on the language model's training data (which may be months old), Context7 fetches live documentation from package registries and official sources. When you ask Autohand to use a library, Context7 pulls the current API reference, examples, and guides so the agent generates code that actually matches the latest release.

This is especially useful when working with fast-moving frameworks like Next.js, React, or any library that ships breaking changes between major versions.

## Setup

Context7 uses the HTTP transport. Add it from the command line:

``` bash
# Add Context7 with your API key
autohand mcp add --transport http context7 https://mcp.context7.com/mcp \
  --header "CONTEXT7_API_KEY: your-api-key-here"

# Verify it connected
autohand mcp list
```

Or add it directly to your `~/.autohand/config.json`:

``` json
{
  "mcp": {
    "servers": [
      {
        "name": "context7",
        "transport": "http",
        "url": "https://mcp.context7.com/mcp",
        "headers": {
          "CONTEXT7_API_KEY": "your-api-key-here"
        },
        "autoConnect": true
      }
    ]
  }
}
```

Get your API key from the [Context7 website](https://context7.com). A free tier is available for individual developers.

## Usage examples

Once connected, Context7 tools become available as `mcp__context7__*`. The agent can call them automatically when it needs documentation.

### Get docs for a specific library

``` bash
# Ask Autohand to build something with a specific library
autohand --prompt "Create a Next.js 15 API route that handles file uploads using the App Router"

# The agent will call Context7 to fetch Next.js 15 docs before generating code
```

### Debug version-specific issues

``` bash
# When you hit a breaking change between versions
autohand --prompt "My React Query v5 mutations stopped working after upgrading from v4. Help me migrate."

# Context7 fetches the v5 migration guide and current API docs
```

### Explore unfamiliar libraries

``` bash
# Learn a new library with current examples
autohand --prompt "Show me how to set up Drizzle ORM with PostgreSQL and write a typed query"

# Gets the latest Drizzle docs instead of outdated patterns
```

## When to use Context7

-   **Fast-moving frameworks** like Next.js, React, Vue, or Svelte where APIs change between releases.
-   **New library adoption** when you want the agent to learn from official docs rather than guessing.
-   **Version migrations** where you need the agent to understand both the old and new API.
-   **Niche packages** that the language model may not have seen during training.

## Tips

-   Mention the specific version in your prompt (e.g., "Next.js 15" not just "Next.js") so Context7 fetches the right docs.
-   Context7 works best with npm packages and popular frameworks. For internal or private libraries, consider building a custom MCP server.
-   The HTTP transport keeps a persistent session, so repeated lookups within the same conversation are fast.
-   Combine Context7 with [Brave Search MCP](/docs/guides/mcp/brave-search.html) for cases where official docs are not enough and you need community solutions.