# Fumadocs (Framework Mode, Astro): AI & LLMs
URL: /docs/astro/integrations/llms
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/(framework)/[framework]/integrations/llms.mdx

Make your docs readable for AI agents, and add an AI chat.

## Markdown for LLMs [#markdown-for-llms]

Serve your docs as Markdown for AI agents:

```package-install
npx @fumadocs/cli feature llms
```

Your site then serves:

- `/llms.txt`: an index of your docs, linking the Markdown of each page.
- `/llms-full.txt`: every page in one file.
- `/docs/ui.md`: the Markdown of a page, `/index.md` for the page at `/`.

The CLI adds `docsLlms` to `lib/source.ts`, which renders these files:

```ts title="lib/source.ts"
import { llms } from 'fumadocs-core/source';

export const docsLlms = llms(source, {
  // the Markdown of a page
  renderPage: async (page) => `# ${page.data.title} (${page.url})

${await page.data.getText('processed')}`,
  // leave drafts out, `llms.txt` links them to their HTML page instead
  filter: (page) => page.slugs[0] !== 'drafts',
});
```

MDX components stay as JSX in the Markdown, unless they define a [Markdown form](/docs/headless/utils/markdown#asmarkdown).

### Sections [#sections]

Each root folder is a section with its own `llms-full.txt`, like `/docs/ui/llms-full.txt`, so agents can read large docs one part at a time. Choose other sections with `section`:

```ts title="lib/source.ts"
export const docsLlms = llms(source, {
  section(folder) {
    // collapsed: listed in `llms.txt` as one link to its own `llms.txt`
    if (folder.root) return { collapse: true };

    return folder.index !== undefined;
  },
  // ...
});
```

### Page Actions [#page-actions]

Page actions let readers copy the Markdown of a page, or open it in AI apps.

![AI Page Actions](/docs/ai-page-actions.png)

Add them to the React island of your docs page:

```astro tab="src/pages/docs/[...slug].astro"
<Docs
  client:load
  markdownUrl={`${page.url}.md`}
  githubUrl={`https://github.com/${owner}/${repo}/blob/main/content/docs/${encodeURI(page.path)}`}
>
  <Content />
</Docs>
```

```tsx tab="src/components/docs.tsx"
import { MarkdownCopyButton, ViewOptionsPopover } from 'fumadocs-ui/layouts/docs/page';

<div className="flex flex-row gap-2 items-center border-b pt-2 pb-6">
  <MarkdownCopyButton markdownUrl={markdownUrl} />
  <ViewOptionsPopover markdownUrl={markdownUrl} githubUrl={githubUrl} />
</div>;
```

### Accept Header [#accept]

Docs pages are prerendered, so they can't serve Markdown for `Accept: text/markdown`.

## MCP Server [#mcp-server]

Let AI agents list, search and read your docs through an [MCP](https://modelcontextprotocol.io) server:

```package-install
npx @fumadocs/cli feature mcp
```

The server renders on request, so your project needs an [adapter](https://docs.astro.build/en/guides/on-demand-rendering/).

Then connect an agent to it:

```json
{
  "mcpServers": {
    "docs": { "url": "https://your-site.com/api/mcp" }
  }
}
```

To customize the tools, see [`fumadocs-core/mcp`](/docs/headless/utils/mcp).

## WebMCP [#webmcp]

<Callout type="warn" title="Experimental">
[WebMCP](https://webmachinelearning.github.io/webmcp/) is an early web standard, available in
Chrome 149+ behind the `#enable-webmcp-testing` flag and an origin trial.
</Callout>

WebMCP gives the AI agent in the reader's browser tools to search and read your docs:

```package-install
npx @fumadocs/cli feature webmcp
```

Render the generated `WebMCP` component inside `<RootProvider />`.

## Ask AI [#ask-ai]

![AI Search](/docs/ai-search.png)

Add an AI chat to your docs layout:

```package-install
npx @fumadocs/cli feature ai
```

Choose a provider, and set its API key in `.env.local`, like `OPENROUTER_API_KEY` for OpenRouter. To use another model, edit the generated `/api/chat` route.

The CLI adds the chat to your docs layout. If it can't find your layout, add the chat by hand:

```tsx tab="components/ai/layout.tsx"
'use client';
import { DocsLayout as Layout, type DocsLayoutProps } from 'fumadocs-ui/layouts/docs';
import { AIChat, AIChatPanel, useAIChat } from './search';

export function DocsLayout(props: DocsLayoutProps) {
  return (
    <AIChat>
      <ChatLayout {...props} />
    </AIChat>
  );
}

function ChatLayout(props: DocsLayoutProps) {
  const { open, setOpen } = useAIChat();

  return (
    <Layout
      {...props}
      aiChat={{ open, onOpenChange: setOpen, panel: <AIChatPanel />, trigger: true }}
    />
  );
}
```

```tsx tab="src/components/docs.tsx"
import { DocsLayout } from 'fumadocs-ui/layouts/docs'; // [!code --]
import { DocsLayout } from '@/components/ai/layout'; // [!code ++]
```