get_page
Fetch full content from Fumadocs documentation pages by providing a specific path to access detailed technical information.
Instructions
Fetch the full content of a specific Fumadocs documentation page. Provide the path (e.g., '/docs/manual-installation/next') to get detailed documentation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Documentation path (e.g., '/docs/manual-installation/next' or '/docs/ui/components/tabs') |
Implementation Reference
- src/tools/get-page.ts:14-66 (handler)Main handler function getPage that fetches and returns documentation page content. It validates input, normalizes paths, handles errors, and formats the output with metadata including the source URL.export async function getPage(params: GetPageParams): Promise<string> { const { path } = params; if (!path || path.trim().length === 0) { return "Error: Please provide a documentation path."; } // Normalize path let normalizedPath = path.trim(); if (!normalizedPath.startsWith("/")) { normalizedPath = "/" + normalizedPath; } if (!normalizedPath.startsWith("/docs")) { normalizedPath = "/docs" + normalizedPath; } try { const content = await fetchPage(normalizedPath); if (!content || content.trim().length === 0) { return `No content found at path: ${normalizedPath}\n\nTry using \`search_docs\` to find the correct path.`; } const output: string[] = [ `# Documentation: ${normalizedPath}\n`, "---\n", content, "\n---", `\nSource: https://fumadocs.vercel.app${normalizedPath}`, ]; return output.join("\n"); } catch (error) { if (error instanceof FumadocsError) { if (error.code === "PAGE_NOT_FOUND") { return [ `Page not found: ${normalizedPath}`, "", "The requested documentation page does not exist.", "", "Suggestions:", "- Check if the path is correct", "- Use `search_docs` to find the right page", "- Use `list_topics` to browse available pages", ].join("\n"); } return `Error fetching page: ${error.message} (${error.code})`; } return `Unexpected error fetching page: ${error instanceof Error ? error.message : "Unknown error"}`; } }
- src/tools/get-page.ts:4-12 (schema)Schema definition for get_page tool using Zod validation and TypeScript type definition for input parameters. The schema expects a 'path' string parameter for documentation paths.export const getPageSchema = { path: z .string() .describe("Documentation path (e.g., '/docs/manual-installation/next' or '/docs/ui/components/tabs')"), }; export type GetPageParams = { path: string; };
- src/index.ts:52-63 (registration)MCP tool registration for get_page in the main server file. The tool is registered with its name, description, schema, and async handler that wraps the getPage function and formats the response.// 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 }], }; } );
- src/services/docs-fetcher.ts:134-162 (helper)Helper function fetchPage that implements the actual fetching logic. It first checks cache, then tries to fetch from llms-full.txt, and falls back to direct HTML fetching with content extraction.export async function fetchPage(path: string): Promise<string> { // Normalize path const normalizedPath = path.startsWith("/") ? path : `/${path}`; const cacheKey = `page:${normalizedPath}`; const cached = cache.get<string>(cacheKey); if (cached) { return cached; } // Try fetching from llms-full.txt first (contains all docs in markdown) try { const fullDocs = await fetchLlmsFullTxt(); const pageContent = extractPageFromFullDocs(fullDocs, normalizedPath); if (pageContent) { cache.set(cacheKey, pageContent, "PAGE_CONTENT"); return pageContent; } } catch { // Fall through to direct fetch } // Fallback: fetch the HTML page directly const url = `${FUMADOCS_BASE_URL}${normalizedPath}`; const html = await fetchWithRetry(url); const content = extractContentFromHtml(html); cache.set(cacheKey, content, "PAGE_CONTENT"); return content; }