Files
upstash__context7/docs/agentic-tools.mdx
Enes Akar 9ab85544ed docs: restructure sidebar navigation into collapsible groups (#3163)
Reorganize the Context7 tab navigation and make every section
collapsible. Mintlify only honors `expanded` on nested groups, so each
tab's sections now live one level down under a wrapper group.

Navigation:
- Split the flat Overview and How To groups into Get Started, Libraries
  and Account
- Group library pages by Ownership and Configuration
- Merge the SDK and agentic tool trees into API and SDKs; Vercel AI SDK
  is now a sibling of TypeScript
- Collapse all sections by default except Get Started
- Remove group icons

Content:
- Rename agentic-tools/overview.mdx to agentic-tools.mdx, retitle it
  "Agentic Tools" and add a redirect from the old URL
- Drop the work-in-progress warning from the TypeScript SDK guide

No pages were added or removed.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-09 08:50:00 +03:00

138 lines
4.4 KiB
Plaintext

---
title: "Agentic Tools"
sidebarTitle: "Agentic Tools"
description: "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
<CardGroup cols={1}>
<Card
title="Vercel AI SDK"
icon="wand-magic-sparkles"
href="/agentic-tools/ai-sdk/getting-started"
>
Add Context7 tools to your AI SDK workflows with `generateText`, `streamText`, or use the
pre-built `Context7Agent` for automatic documentation lookup.
</Card>
<Card title="TypeScript SDK" icon="js" href="/sdks/ts/getting-started">
Call Context7 directly from any TypeScript or Node.js app.
</Card>
<Card title="MCP Server" icon="plug" href="/resources/all-clients">
Connect Context7's MCP server to any agent or editor.
</Card>
</CardGroup>
## How It Works
```mermaid
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
<AccordionGroup>
<Accordion title="Documentation-Aware Chatbots" icon="comments">
Build chatbots that answer framework questions with accurate, version-specific information:
```typescript
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-5.2"),
prompt: "How do I set up authentication in Next.js 15?",
tools: {
resolveLibraryId: resolveLibraryId(),
queryDocs: queryDocs(),
},
stopWhen: stepCountIs(5),
});
```
</Accordion>
<Accordion title="Code Generation Pipelines" icon="code">
Ensure generated code uses current APIs and best practices:
```typescript
import { Context7Agent } from "@upstash/context7-tools-ai-sdk";
import { anthropic } from "@ai-sdk/anthropic";
const agent = new Context7Agent({
model: anthropic("claude-sonnet-4-20250514"),
});
const { text } = await agent.generate({
prompt: "Generate a Supabase Edge Function that handles webhooks",
});
```
</Accordion>
<Accordion title="Code Review Agents" icon="magnifying-glass-chart">
Build code review agents that verify implementations against current API documentation:
```typescript
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-4-20250514"),
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
```
</Accordion>
</AccordionGroup>