Fumadocs

MCP

Expose your docs to AI agents as MCP tools.

fumadocs-core/mcp registers tools on a MCP server, for AI agents to read and search your docs.

The MCP Server guide sets up a route with these tools for you.

Usage

npm install fumadocs-core @modelcontextprotocol/server zod

Register the tools with your source, its docsLlms renderer, and a search server:

lib/mcp.ts
import { McpServer } from '@modelcontextprotocol/server';
import { registerSearchTool, registerSourceTools } from 'fumadocs-core/mcp';
import { createFromSource } from 'fumadocs-core/search/server';
import { source, docsLlms } from '@/lib/source';

export const mcp = new McpServer({ name: 'docs', version: '1.0.0' });

// `list_pages` & `get_page`
registerSourceTools(mcp, source, docsLlms);
// `search`
registerSearchTool(mcp, createFromSource(source));

For runtime content sources, pass the getter of your source:

registerSourceTools(mcp, getSource, docsLlms);

Then connect the server to a transport, like the streamable HTTP transport.

Tools

ToolInputOutput
list_pagesNonellms.index(), the index of pages
get_pageurl of a pagellms.page(page), or an error when no page matches
searchquery, locale?the search results, as JSON

How is this guide?

Last updated on