#!/usr/bin/env node
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import {
listTopics,
listTopicsSchema,
searchDocs,
searchDocsSchema,
getPage,
getPageSchema,
getSetupGuide,
getSetupGuideSchema,
getComponent,
getComponentSchema,
} from "./tools/index.js";
// Create server instance
const server = new McpServer({
name: "fumadocs",
version: "1.0.0",
});
// Register list_topics tool
server.tool(
"list_topics",
"Browse available Fumadocs documentation sections and topics. Use without parameters to see all sections, or specify a section to see all topics in that section.",
listTopicsSchema,
async (params) => {
const result = await listTopics(params);
return {
content: [{ type: "text", text: result }],
};
}
);
// Register search_docs tool
server.tool(
"search_docs",
"Search Fumadocs documentation by keyword. Returns matching documentation pages with titles, descriptions, and paths. Use this to find specific topics or features.",
searchDocsSchema,
async (params) => {
const result = await searchDocs(params);
return {
content: [{ type: "text", text: result }],
};
}
);
// Register get_page tool
server.tool(
"get_page",
"Fetch the full content of a specific Fumadocs documentation page. Provide the path (e.g., '/docs/manual-installation/next') to get detailed documentation.",
getPageSchema,
async (params) => {
const result = await getPage(params);
return {
content: [{ type: "text", text: result }],
};
}
);
// Register get_setup_guide tool
server.tool(
"get_setup_guide",
"Get a complete setup guide for adding Fumadocs to an existing project. Specify the framework (next, react-router, tanstack-start, or waku) to get framework-specific instructions.",
getSetupGuideSchema,
async (params) => {
const result = await getSetupGuide(params);
return {
content: [{ type: "text", text: result }],
};
}
);
// Register get_component tool
server.tool(
"get_component",
"Get documentation for a specific Fumadocs UI component. Includes props, usage examples, and configuration options. Available components: accordion, tabs, codeblock, steps, files, banner, and more.",
getComponentSchema,
async (params) => {
const result = await getComponent(params);
return {
content: [{ type: "text", text: result }],
};
}
);
// Start server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error("Fumadocs MCP Server running on stdio");
}
main().catch((error) => {
console.error("Fatal error:", error);
process.exit(1);
});