# Fumadocs Core (the core library of Fumadocs): MCP
URL: /docs/headless/utils/mcp
Source: https://raw.githubusercontent.com/fuma-nama/fumadocs/refs/heads/main/apps/docs/content/docs/headless/utils/mcp.mdx

Expose your docs to AI agents as MCP tools.

`fumadocs-core/mcp` registers tools on a [MCP](https://modelcontextprotocol.io) server, for AI agents to read and search your docs.

<Callout>
The [MCP Server](/docs/next/integrations/llms#mcp-server) guide sets up a route with these tools for
you.
</Callout>

## Usage [#usage]

```package-install
fumadocs-core @modelcontextprotocol/server zod
```

Register the tools with your source, its [`docsLlms`](/docs/next/integrations/llms#markdown-for-llms) renderer, and a search server:

```ts title="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:

```ts
registerSourceTools(mcp, getSource, docsLlms);
```

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

## Tools [#tools]

| Tool         | Input              | Output                                              |
| ------------ | ------------------ | --------------------------------------------------- |
| `list_pages` | None               | `llms.index()`, the index of pages                  |
| `get_page`   | `url` of a page    | `llms.page(page)`, or an error when no page matches |
| `search`     | `query`, `locale?` | the search results, as JSON                         |