Skip to main content
Glama

get_component_docs

Fetch comprehensive documentation for Reacticx React Native components, including props, code examples, usage instructions, and installation guides.

Instructions

Fetch the full documentation for a specific Reacticx component, including props, code examples, usage, and installation instructions. Use the component slug (e.g. 'accordion', 'elastic-slider', 'aurora').

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentYesComponent slug (e.g. 'accordion', 'elastic-slider', 'aurora')

Implementation Reference

  • Main handler for get_component_docs tool. Validates component slug using getComponentBySlug, fetches documentation via fetchComponentDocs, formats output with component metadata, and provides error handling with suggestions for similar components when not found.
    server.tool(
      "get_component_docs",
      "Fetch the full documentation for a specific Reacticx component, including props, code examples, usage, and installation instructions. Use the component slug (e.g. 'accordion', 'elastic-slider', 'aurora').",
      {
        component: z
          .string()
          .describe(
            "Component slug (e.g. 'accordion', 'elastic-slider', 'aurora')"
          ),
      },
      async ({ component }) => {
        const slug = component.toLowerCase().trim();
        const info = getComponentBySlug(slug);
    
        if (!info) {
          const suggestions = searchComponents(slug);
          const suggestText =
            suggestions.length > 0
              ? `\n\nDid you mean: ${suggestions
                  .slice(0, 5)
                  .map((s) => `"${s.slug}"`)
                  .join(", ")}?`
              : "";
          return {
            content: [
              {
                type: "text" as const,
                text: `Component "${slug}" not found in registry.${suggestText}`,
              },
            ],
          };
        }
    
        try {
          const docs = await fetchComponentDocs(slug);
    
          const header = [
            `**Component:** ${info.name}`,
            `**Category:** ${info.category}`,
            `**Install:** \`bunx --bun reacticx add ${info.slug}\``,
            info.dependencies.length > 0
              ? `**Dependencies:** ${info.dependencies.join(", ")}`
              : null,
            "",
            "---",
            "",
          ]
            .filter(Boolean)
            .join("\n");
    
          return {
            content: [
              { type: "text" as const, text: header + docs },
            ],
          };
        } catch (error) {
          const message =
            error instanceof Error ? error.message : String(error);
          return {
            content: [
              {
                type: "text" as const,
                text: `Error fetching docs for "${slug}": ${message}\n\nBasic info:\n- Name: ${info.name}\n- Category: ${info.category}\n- Dependencies: ${info.dependencies.join(", ") || "none"}\n- Install: \`bunx --bun reacticx add ${info.slug}\`\n- Docs: https://www.reacticx.com/docs/components/${info.slug}`,
              },
            ],
          };
        }
      }
    );
  • Zod schema defining the input parameter for get_component_docs: a required 'component' string that accepts the component slug (e.g., 'accordion', 'elastic-slider', 'aurora').
    {
      component: z
        .string()
        .describe(
          "Component slug (e.g. 'accordion', 'elastic-slider', 'aurora')"
        ),
    },
  • fetchComponentDocs helper function that fetches HTML documentation from https://www.reacticx.com/docs/components/{slug}, converts it to Markdown using htmlToMarkdown, caches results for 30 minutes, and returns formatted content with installation instructions.
    export async function fetchComponentDocs(
      slug: string
    ): Promise<string> {
      const cached = cache.get(slug);
      if (cached && Date.now() - cached.timestamp < CACHE_TTL) {
        return cached.content;
      }
    
      const url = `${DOCS_BASE_URL}/${slug}`;
    
      try {
        const response = await fetch(url, {
          headers: {
            "User-Agent": "ReacticxMCP/1.0",
            Accept: "text/html",
          },
        });
    
        if (!response.ok) {
          throw new Error(`HTTP ${response.status}: ${response.statusText}`);
        }
    
        const html = await response.text();
        const markdown = htmlToMarkdown(html);
    
        const content = [
          `# ${slug} - Reacticx Component Documentation`,
          `Source: ${url}`,
          "",
          markdown,
          "",
          "---",
          `Installation: \`bunx --bun reacticx add ${slug}\``,
        ].join("\n");
    
        cache.set(slug, { content, timestamp: Date.now() });
        return content;
      } catch (error) {
        const message =
          error instanceof Error ? error.message : String(error);
        throw new Error(
          `Failed to fetch docs for "${slug}" from ${url}: ${message}`
        );
      }
    }
  • getComponentBySlug helper function that looks up component information by slug in the COMPONENT_REGISTRY, returning ComponentInfo or undefined if not found.
    export function getComponentBySlug(
      slug: string
    ): ComponentInfo | undefined {
      return COMPONENT_REGISTRY.find(
        (c) => c.slug.toLowerCase() === slug.toLowerCase()
      );
    }
  • htmlToMarkdown helper function that converts HTML to Markdown by removing script/style tags, extracting main content, converting headings, code blocks, links, lists, tables, paragraphs, and handling HTML entities and whitespace cleanup.
    function htmlToMarkdown(html: string): string {
      let text = html;
    
      // Remove script and style tags with content
      text = text.replace(/<script[\s\S]*?<\/script>/gi, "");
      text = text.replace(/<style[\s\S]*?<\/style>/gi, "");
      text = text.replace(/<nav[\s\S]*?<\/nav>/gi, "");
      text = text.replace(/<footer[\s\S]*?<\/footer>/gi, "");
      text = text.replace(/<header[\s\S]*?<\/header>/gi, "");
    
      // Extract the main content area if possible
      const mainMatch = text.match(
        /<main[\s\S]*?>([\s\S]*?)<\/main>/i
      );
      const articleMatch = text.match(
        /<article[\s\S]*?>([\s\S]*?)<\/article>/i
      );
      if (articleMatch) {
        text = articleMatch[1];
      } else if (mainMatch) {
        text = mainMatch[1];
      }
    
      // Convert headings
      text = text.replace(/<h1[^>]*>([\s\S]*?)<\/h1>/gi, "\n# $1\n");
      text = text.replace(/<h2[^>]*>([\s\S]*?)<\/h2>/gi, "\n## $1\n");
      text = text.replace(/<h3[^>]*>([\s\S]*?)<\/h3>/gi, "\n### $1\n");
      text = text.replace(/<h4[^>]*>([\s\S]*?)<\/h4>/gi, "\n#### $1\n");
    
      // Convert code blocks - handle <pre><code> combinations
      text = text.replace(
        /<pre[^>]*>\s*<code[^>]*class="[^"]*language-(\w+)"[^>]*>([\s\S]*?)<\/code>\s*<\/pre>/gi,
        "\n```$1\n$2\n```\n"
      );
      text = text.replace(
        /<pre[^>]*>\s*<code[^>]*>([\s\S]*?)<\/code>\s*<\/pre>/gi,
        "\n```\n$1\n```\n"
      );
      text = text.replace(
        /<pre[^>]*>([\s\S]*?)<\/pre>/gi,
        "\n```\n$1\n```\n"
      );
    
      // Convert inline code
      text = text.replace(/<code[^>]*>([\s\S]*?)<\/code>/gi, "`$1`");
    
      // Convert bold and italic
      text = text.replace(/<(strong|b)[^>]*>([\s\S]*?)<\/\1>/gi, "**$2**");
      text = text.replace(/<(em|i)[^>]*>([\s\S]*?)<\/\1>/gi, "*$2*");
    
      // Convert links
      text = text.replace(
        /<a[^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,
        "[$2]($1)"
      );
    
      // Convert list items
      text = text.replace(/<li[^>]*>([\s\S]*?)<\/li>/gi, "- $1\n");
      text = text.replace(/<\/?[ou]l[^>]*>/gi, "\n");
    
      // Convert table elements
      text = text.replace(/<tr[^>]*>([\s\S]*?)<\/tr>/gi, "$1|\n");
      text = text.replace(/<th[^>]*>([\s\S]*?)<\/th>/gi, "| $1 ");
      text = text.replace(/<td[^>]*>([\s\S]*?)<\/td>/gi, "| $1 ");
      text = text.replace(/<\/?table[^>]*>/gi, "\n");
      text = text.replace(/<\/?thead[^>]*>/gi, "");
      text = text.replace(/<\/?tbody[^>]*>/gi, "");
    
      // Convert paragraphs and breaks
      text = text.replace(/<p[^>]*>([\s\S]*?)<\/p>/gi, "\n$1\n");
      text = text.replace(/<br\s*\/?>/gi, "\n");
      text = text.replace(/<hr\s*\/?>/gi, "\n---\n");
    
      // Convert divs to newlines
      text = text.replace(/<div[^>]*>/gi, "\n");
      text = text.replace(/<\/div>/gi, "\n");
    
      // Remove remaining HTML tags
      text = text.replace(/<[^>]+>/g, "");
    
      // Decode HTML entities
      text = text.replace(/&/g, "&");
      text = text.replace(/</g, "<");
      text = text.replace(/>/g, ">");
      text = text.replace(/"/g, '"');
      text = text.replace(/'/g, "'");
      text = text.replace(/ /g, " ");
      text = text.replace(/&#(\d+);/g, (_, code) =>
        String.fromCharCode(parseInt(code))
      );
    
      // Clean up whitespace
      text = text.replace(/\n{3,}/g, "\n\n");
      text = text.trim();
    
      return text;
    }
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 describes what the tool does (fetch documentation) but lacks details on behavioral traits such as error handling (e.g., what happens if the component slug is invalid), performance characteristics (e.g., response time), or output format (e.g., structured data vs. raw text). This is a significant gap for a tool with no annotation coverage.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded, with two sentences that efficiently convey the tool's purpose and usage. Every sentence earns its place: the first defines the action and scope, and the second provides parameter guidance with examples. There is no wasted verbiage.

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 output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameter usage but lacks behavioral context (e.g., error handling) and output details. Without annotations or an output schema, the description should do more to compensate, but it only meets minimum viability.

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 schema description coverage is 100%, with the single parameter 'component' fully documented in the schema. The description adds minimal value beyond the schema by providing examples ('accordion', 'elastic-slider', 'aurora'), but does not explain semantics like format constraints or validation rules. This meets the baseline of 3 when the schema does the heavy lifting.

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

Purpose5/5

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

The description clearly states the specific action ('Fetch'), resource ('full documentation for a specific Reacticx component'), and scope ('including props, code examples, usage, and installation instructions'). It distinguishes from sibling tools like 'list_components' (which likely lists components) and 'search_components' (which likely searches for components) by specifying retrieval of detailed documentation for a single component.

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

Usage Guidelines4/5

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

The description provides clear context for when to use this tool: to get comprehensive documentation for a specific component. It implicitly distinguishes from siblings by focusing on detailed docs rather than listing or searching. However, it does not explicitly state when NOT to use it or name alternatives (e.g., 'list_components' for overviews), which prevents a score of 5.

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/igorfelipeduca/reacticx-mcp'

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