> ## Documentation Index
> Fetch the complete documentation index at: https://context7.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Agentic Tools

> Build AI agents with up-to-date library documentation

Context7 provides tools and integrations that give your AI agents access to accurate, up-to-date library documentation. Instead of relying on potentially outdated training data, your agents can fetch real-time documentation to answer questions and generate code.

## Why Agentic Tools?

AI agents often struggle with:

* **Outdated knowledge** - Training data becomes stale, leading to deprecated API usage
* **Hallucinated APIs** - Models confidently suggest methods that don't exist
* **Version mismatches** - Code examples from old versions that no longer work

Context7's agentic tools solve these problems by giving your agents direct access to current documentation during inference.

## Available Integrations

> [card] [Vercel AI SDK](https://context7.com/docs/agentic-tools/ai-sdk/getting-started.md)
>
> Add Context7 tools to your AI SDK workflows with `generateText`, `streamText`, or use the
> pre-built `Context7Agent` for automatic documentation lookup.

> [card] [TypeScript SDK](https://context7.com/docs/sdks/ts/getting-started.md)
>
> Call Context7 directly from any TypeScript or Node.js app.

> [card] [MCP Server](https://context7.com/docs/resources/all-clients.md)
>
> Connect Context7's MCP server to any agent or editor.

## How It Works

```mermaid theme={null}
sequenceDiagram
    participant User
    participant Agent
    participant Context7
    participant Docs

    User->>Agent: "How do I use React Server Components?"
    Agent->>Context7: resolveLibraryId(query: "React Server Components", libraryName: "react")
    Context7-->>Agent: Library ID: /reactjs/react.dev
    Agent->>Context7: queryDocs(libraryId: "/reactjs/react.dev", query: "server components")
    Context7->>Docs: Fetch latest documentation
    Docs-->>Context7: Current docs with examples
    Context7-->>Agent: Documentation content
    Agent->>User: Answer with accurate, up-to-date code examples
```

## Use Cases

> [accordion] Documentation-Aware Chatbots
>
> Build chatbots that answer framework questions with accurate, version-specific information:
>
> ```typescript theme={null}
> import { generateText, stepCountIs } from "ai";
> import { openai } from "@ai-sdk/openai";
> import { resolveLibraryId, queryDocs } from "@upstash/context7-tools-ai-sdk";
>
> const { text } = await generateText({
>   model: openai("gpt-6-astra"),
>   prompt: "How do I set up authentication in Next.js 16?",
>   tools: {
>     resolveLibraryId: resolveLibraryId(),
>     queryDocs: queryDocs(),
>   },
>   stopWhen: stepCountIs(5),
> });
> ```

> [accordion] Code Generation Pipelines
>
> Ensure generated code uses current APIs and best practices:
>
> ```typescript theme={null}
> import { Context7Agent } from "@upstash/context7-tools-ai-sdk";
> import { anthropic } from "@ai-sdk/anthropic";
>
> const agent = new Context7Agent({
>   model: anthropic("claude-sonnet-5-5"),
> });
>
> const { text } = await agent.generate({
>   prompt: "Generate a Supabase Edge Function that handles webhooks",
> });
> ```

> [accordion] Code Review Agents
>
> Build code review agents that verify implementations against current API documentation:
>
> ```typescript theme={null}
> import { generateText, stepCountIs } from "ai";
> import { anthropic } from "@ai-sdk/anthropic";
> import { resolveLibraryId, queryDocs } from "@upstash/context7-tools-ai-sdk";
>
> const codeToReview = `
>   const { data } = await supabase
>     .from('users')
>     .select('*')
>     .eq('id', userId)
>     .single();
> `;
>
> const { text } = await generateText({
>   model: anthropic("claude-sonnet-5-5"),
>   prompt: `Review this Supabase code for correctness and best practices:
>
> ${codeToReview}
>
> Check against the latest Supabase documentation.`,
>   tools: {
>     resolveLibraryId: resolveLibraryId(),
>     queryDocs: queryDocs(),
>   },
>   stopWhen: stepCountIs(5),
> });
>
> // Agent fetches current Supabase docs to verify:
> // - Correct method signatures
> // - Deprecated patterns
> // - Security best practices
> // - Error handling recommendations
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.