AI & LLMs
Make your docs readable for AI agents, and add an AI chat.
Markdown for LLMs
Serve your docs as Markdown for AI agents:
npx @fumadocs/cli feature llmsYour 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.mdfor the page at/.
The CLI adds docsLlms to lib/source.ts, which renders these files:
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.
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:
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 let readers copy the Markdown of a page, or open it in AI apps.

Add them to the React island of your docs page:
<Docs
client:load
markdownUrl={`${page.url}.md`}
githubUrl={`https://github.com/${owner}/${repo}/blob/main/content/docs/${encodeURI(page.path)}`}
>
<Content />
</Docs>Accept Header
Docs pages are prerendered, so they can't serve Markdown for Accept: text/markdown.
MCP Server
Let AI agents list, search and read your docs through an MCP server:
npx @fumadocs/cli feature mcpThe server renders on request, so your project needs an adapter.
Then connect an agent to it:
{
"mcpServers": {
"docs": { "url": "https://your-site.com/api/mcp" }
}
}To customize the tools, see fumadocs-core/mcp.
WebMCP
Experimental
WebMCP is an early web standard, available in
Chrome 149+ behind the #enable-webmcp-testing flag and an origin trial.
WebMCP gives the AI agent in the reader's browser tools to search and read your docs:
npx @fumadocs/cli feature webmcpRender the generated WebMCP component inside <RootProvider />.
Ask AI

Add an AI chat to your docs layout:
npx @fumadocs/cli feature aiChoose 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:
'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 }}
/>
);
}How is this guide?
Last updated on
