LLMs
Serve your docs as Markdown for LLMs and AI agents.
Routes
Your site serves your docs as Markdown by default, from llmsPlugin():
| Route | Content |
|---|---|
/llms.txt | An index of all pages. |
/llms-full.txt | The content of all pages, in one file. |
/docs/<page>.md | One page as Markdown, like /docs.md. |
Docs pages link to their Markdown in the page actions, as page.markdownUrl.
Accept
A request for a page that prefers Markdown (Accept: text/markdown) gets its Markdown with Vary: Accept. It requires docs pages rendered on request, with output: 'server':
export default defineConfig({
output: 'server',
adapter: node({ mode: 'standalone' }),
// ...
});Prerendered pages are static files, hosts serve them without running Astro.
Processed Markdown
The routes serve your raw MDX source by default. To serve processed Markdown, enable includeProcessedMarkdown. It takes the same options as Remark LLMs:
fumadocs({
includeProcessedMarkdown: true,
});Fumadocs CLI enables it for you:
npx @fumadocs/cli feature llmsMDX Components
MDX components are kept as JSX by default. With output: 'function', your MDX components render them:
fumadocs({
includeProcessedMarkdown: { output: 'function' },
});A component defines its Markdown with asMarkdown(), the others are kept as JSX. In the browser, asMarkdown() is false and the component renders as usual.
getText()
Source pages have getText():
// the source file
await page.data.getText('raw');
// the processed Markdown, requires `includeProcessedMarkdown`
await page.data.getText('processed');
// with `output: 'function'`, render with other components
await page.data.getText('processed', { components });MCP Server
mcpPlugin() serves a MCP server at /api/mcp, with tools to list, read and search your pages. It requires an Astro adapter to render on request.
npm i @modelcontextprotocol/server zodimport { defineConfig } from '@fumadocs/astro/config';
import { mcpPlugin } from '@fumadocs/astro/plugins/mcp';
import { source } from './lib/source';
export default defineConfig({
source,
plugins: [mcpPlugin()],
});Or with Fumadocs CLI:
npx @fumadocs/cli feature mcpPages are read from every content source, like the Markdown routes above.
Prop
Type
For example, register a tool with tools:
import { z } from 'zod';
mcpPlugin({
tools(server) {
server.registerTool(
'get_site_name',
{ description: 'The name of the site', inputSchema: z.object({}) },
async () => ({ content: [{ type: 'text', text: this.config.title ?? '' }] }),
);
},
});WebMCP
WebMCP exposes tools to the browser's AI agent on the page the reader is viewing. See WebMCP.
npx @fumadocs/cli feature webmcpThe CLI adds it to Provider in your layout module. search_docs uses the built-in search index.
Ask AI
The chat dialog runs as an endpoint at src/pages/api/chat.ts and requires an Astro adapter. Use the client layout in your docs page module, or let the CLI set it up. See Ask AI.
npx @fumadocs/cli feature aiHow is this guide?
Last updated on
