Skip to main content
Glama

get_component

Retrieve documentation for Fumadocs UI components including props, usage examples, and configuration options to integrate them into projects.

Instructions

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentYesComponent name (e.g., 'accordion', 'tabs', 'codeblock', 'steps')

Implementation Reference

  • Main handler function getComponent that executes the tool logic: validates input, looks up component path from COMPONENT_PATHS or searches the docs index, fetches documentation content, and returns formatted output with usage tips
    export async function getComponent(params: GetComponentParams): Promise<string> {
      const { component } = params;
    
      if (!component || component.trim().length === 0) {
        return "Error: Please provide a component name.";
      }
    
      const normalizedComponent = component.toLowerCase().trim();
    
      // Try exact match first
      let componentPath = COMPONENT_PATHS[normalizedComponent];
    
      // If no exact match, try to find it
      if (!componentPath) {
        // Search for it in the docs index
        const searchResults = searchDocsIndex(normalizedComponent, "ui");
        const componentResult = searchResults.find(
          (r) => r.path.includes("/components/") && r.title.toLowerCase().includes(normalizedComponent)
        );
    
        if (componentResult) {
          componentPath = componentResult.path;
        }
      }
    
      if (!componentPath) {
        // List available components
        const availableComponents = Object.keys(COMPONENT_PATHS).sort();
        return [
          `Component not found: ${component}`,
          "",
          "Available components:",
          ...availableComponents.map((c) => `- ${c}`),
          "",
          "Tips:",
          "- Use the exact component name",
          "- Try `search_docs` with your query to find related documentation",
        ].join("\n");
      }
    
      try {
        const content = await fetchPage(componentPath);
    
        const output: string[] = [
          `# Component: ${component}`,
          `Path: ${componentPath}`,
          "",
          "---",
          "",
          content,
          "",
          "---",
          "",
          "## Usage Tips",
          "",
          "1. Import the component from `fumadocs-ui/components`",
          "2. Check the props table above for configuration options",
          "3. See the examples for common usage patterns",
          "",
          `Source: https://fumadocs.vercel.app${componentPath}`,
        ];
    
        return output.join("\n");
      } catch (error) {
        if (error instanceof FumadocsError) {
          if (error.code === "PAGE_NOT_FOUND") {
            return `Component documentation not found at: ${componentPath}`;
          }
          return `Error fetching component docs: ${error.message} (${error.code})`;
        }
        return `Unexpected error: ${error instanceof Error ? error.message : "Unknown error"}`;
      }
    }
  • Schema definition for the get_component tool: getComponentSchema defines the Zod validation schema for the component parameter, and GetComponentParams type defines the TypeScript interface
    export const getComponentSchema = {
      component: z
        .string()
        .describe("Component name (e.g., 'accordion', 'tabs', 'codeblock', 'steps')"),
    };
    
    export type GetComponentParams = {
      component: string;
    };
  • src/index.ts:78-89 (registration)
    Tool registration in src/index.ts where get_component is registered with the MCP server using server.tool(), including the tool description, schema binding, and async handler wrapper
    // 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 }],
        };
      }
    );
  • COMPONENT_PATHS helper data structure that maps component names (e.g., 'accordion', 'tabs', 'codeblock') to their documentation paths, used by getComponent for exact matching
    export const COMPONENT_PATHS: Record<string, string> = {
      accordion: "/docs/ui/components/accordion",
      "auto-type-table": "/docs/ui/components/auto-type-table",
      banner: "/docs/ui/components/banner",
      codeblock: "/docs/ui/components/codeblock",
      "code-block": "/docs/ui/components/codeblock",
      "dynamic-codeblock": "/docs/ui/components/dynamic-codeblock",
      files: "/docs/ui/components/files",
      "github-info": "/docs/ui/components/github-info",
      "graph-view": "/docs/ui/components/graph-view",
      "image-zoom": "/docs/ui/components/image-zoom",
      "inline-toc": "/docs/ui/components/inline-toc",
      steps: "/docs/ui/components/steps",
      tabs: "/docs/ui/components/tabs",
      "type-table": "/docs/ui/components/type-table",
    };
  • searchDocsIndex helper function that performs fuzzy search across the documentation index when an exact component match isn't found, scoring matches by title, description, keywords, and path
    export function searchDocsIndex(
      query: string,
      section?: SectionId
    ): DocEntry[] {
      const normalizedQuery = query.toLowerCase();
      const queryWords = normalizedQuery.split(/\s+/);
    
      let results = DOCS_INDEX;
    
      // Filter by section if specified
      if (section) {
        results = results.filter((entry) => entry.section === section);
      }
    
      // Score and filter results
      const scored = results
        .map((entry) => {
          let score = 0;
          const titleLower = entry.title.toLowerCase();
          const descLower = entry.description.toLowerCase();
    
          for (const word of queryWords) {
            // Title matches (highest weight)
            if (titleLower.includes(word)) {
              score += 10;
              if (titleLower === word || titleLower.startsWith(word)) {
                score += 5;
              }
            }
    
            // Description matches
            if (descLower.includes(word)) {
              score += 5;
            }
    
            // Keyword matches
            for (const keyword of entry.keywords) {
              if (keyword.includes(word)) {
                score += 3;
                if (keyword === word) {
                  score += 2;
                }
              }
            }
    
            // Path matches
            if (entry.path.toLowerCase().includes(word)) {
              score += 2;
            }
          }
    
          return { entry, score };
        })
        .filter((item) => item.score > 0)
        .sort((a, b) => b.score - a.score);
    
      return scored.map((item) => item.entry);
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool returns (documentation including props, usage examples, and configuration options), which is helpful. However, it doesn't mention whether this is a read-only operation, if there are rate limits, authentication requirements, or error conditions. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences. The first sentence clearly states the purpose and scope, while the second provides examples and hints at additional components. There's minimal waste, though the phrase 'and more' could be slightly more specific.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (single parameter, no annotations, no output schema), the description is moderately complete. It covers the purpose and output content but lacks behavioral details like error handling or authentication. Without an output schema, it should ideally describe return values more explicitly, though it does mention 'props, usage examples, and configuration options'.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'component' parameter clearly documented as 'Component name (e.g., 'accordion', 'tabs', 'codeblock', 'steps')'. The description adds value by listing additional component examples ('files, banner, and more') and specifying what documentation includes, but doesn't provide syntax or format details beyond what the schema already covers. Baseline 3 is appropriate given high schema coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get documentation for a specific Fumadocs UI component.' It specifies the verb ('Get') and resource ('documentation for a specific Fumadocs UI component'), and lists examples of available components. However, it doesn't explicitly differentiate from sibling tools like 'get_page' or 'search_docs', which likely retrieve different types of documentation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It mentions available components but doesn't explain when to choose 'get_component' over sibling tools like 'get_page' (for page documentation), 'list_topics' (for topic listing), or 'search_docs' (for broader searches). No context or exclusions are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/k4cper-g/fumadocs-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server