Skip to main content
Glama

get_component

Returns the canonical HTML snippet for an Elegant 1.0 component. Use this instead of reading a full wiki .md file to get component HTML directly.

Instructions

Returns the canonical HTML snippet for an Elegant 1.0 component. Much cheaper than reading a full wiki .md file. Use this instead of Read on any component wiki file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesComponent name. Use list_components to see all options.

Implementation Reference

  • The get_component tool handler: looks up the component in COMPONENT_MAP by name, fetches the wiki file, extracts the HTML block for the requested section, rewrites asset paths to CDN URLs, and returns the canonical HTML snippet.
    server.tool("get_component", "Returns the canonical HTML for an Elegant 1.0 UI component. All asset paths are pre-filled with CDN URLs. Copy this HTML directly into your index.html. Do NOT search for component files locally — this tool is the only source.", { name: z.enum(Object.keys(COMPONENT_MAP) as [string, ...string[]]) }, async ({ name: n }) => {
      const entry = COMPONENT_MAP[n];
      if (!entry) return { content: [{ type: "text" as const, text: `Unknown component: ${n}.\n\nAvailable components (use list_components for full list):\n${Object.keys(COMPONENT_MAP).join(", ")}` }] };
      const content = await readWikiFile(entry.file);
      if (!entry.section) return { content: [{ type: "text" as const, text: content }] };
      const html = rewriteAssetPaths(extractHtmlBlock(content, entry.section));
      return { content: [{ type: "text" as const, text: `## ${n}\nCDN: ${CDN_BASE}\nAll <img src> and <link href> paths below use the CDN. Copy as-is.\n\n\`\`\`html\n${html}\n\`\`\`` }] };
    });
  • The input schema for get_component: takes a 'name' parameter which is an enum of all keys from COMPONENT_MAP (the list of valid component names).
    server.tool("get_component", "Returns the canonical HTML for an Elegant 1.0 UI component. All asset paths are pre-filled with CDN URLs. Copy this HTML directly into your index.html. Do NOT search for component files locally — this tool is the only source.", { name: z.enum(Object.keys(COMPONENT_MAP) as [string, ...string[]]) }, async ({ name: n }) => {
  • api/mcp.ts:571-572 (registration)
    The tool is registered as tool number 2 on the MCP server using server.tool('get_component', ...). The comment /* 2. get_component */ marks it.
    /* 2. get_component */
    server.tool("get_component", "Returns the canonical HTML for an Elegant 1.0 UI component. All asset paths are pre-filled with CDN URLs. Copy this HTML directly into your index.html. Do NOT search for component files locally — this tool is the only source.", { name: z.enum(Object.keys(COMPONENT_MAP) as [string, ...string[]]) }, async ({ name: n }) => {
  • COMPONENT_MAP is the lookup table mapping component names (e.g. 'topnavbar', 'header-v1', 'widget') to their wiki file and section. This data drives get_component's lookups.
    const COMPONENT_MAP: Record<string, { file: string; section?: string }> = {
      topnavbar:              { file: "topnavbar.md",                       section: "Complete HTML" },
      "sidemenu-settings":    { file: "sidemenu_variant1_settings.md",      section: "Complete HTML" },
      "sidemenu-reports":     { file: "sidemenu_variant2_reports.md",       section: "Complete HTML" },
      "header-v1":            { file: "header.md",                          section: "Variant 1: Default" },
      "header-v2":            { file: "header.md",                          section: "Variant 2: With Back Button" },
      "header-v3":            { file: "header.md",                          section: "Variant 3: Report Header" },
      "classic-tab":          { file: "classic_tab.md",                     section: "Variant 1: Classic Tab (Single Variant)" },
      "line-tab":             { file: "line_tab.md",                        section: "Variant 1: Default (Plain Text, h=40)" },
      "line-tab-quicklink":   { file: "line_tab.md",                        section: "Variant 3: QuickLink (pill tabs, h=32)" },
      "actionbar-type1":      { file: "actionbar.md",                       section: "Type 1 — Search + Pagination (Minimal)" },
      "actionbar-type2":      { file: "actionbar.md",                       section: "Type 2 — Search + Bulk Actions (Enable/Disable/Delete/More) + Pagination" },
      "actionbar-type8":      { file: "actionbar.md",                       section: "Type 8 — Report ActionBar: Search + Incident Button + Pagination + Column View" },
      "data-table":           { file: "data_table_type1.md",                section: "Complete HTML" },
      "data-table-type2":     { file: "data_table_type2.md",                section: "Complete HTML" },
      "rpt-chart-floater":    { file: "rpt-chart-floater.md",               section: "Complete HTML" },
      "drawer-sm":            { file: "drawer.md",                          section: "Variant 1" },
      "drawer-md":            { file: "drawer.md",                          section: "Variant 2" },
      "drawer-lg":            { file: "drawer.md",                          section: "Variant 3" },
      "form-text":            { file: "form_input.md",                      section: "Type 1" },
      "form-textarea":        { file: "form_input.md",                      section: "Type 3" },
      "form-checkbox":        { file: "form_input.md",                      section: "Type 23: Checkbox Group" },
      "form-radio":           { file: "form_input.md",                      section: "Type 5" },
      "form-dropdown":        { file: "form_dropdown.md",                   section: "Type 1: Basic Dropdown (plain text items)" },
      "widget":               { file: "widget.md",                          section: "Dashboard Container" },
      "stat-card":            { file: "stat_card.md",                       section: "Grid Wrapper + All 10 Types" },
      "button-row":           { file: "button-row.md",                      section: "Complete HTML" },
      "note-container":       { file: "note-container.md",                  section: "Complete HTML" },
      "design-tokens":        { file: "design_tokens.md",                   section: "" },
    };
  • Helper functions used by get_component: rewriteAssetPaths (rewrites asset URLs to CDN), extractSection (finds a section by heading), and extractHtmlBlock (extracts ```html code blocks).
    function rewriteAssetPaths(html: string): string {
      // Match all relative forms: ./assets/, assets/, ../assets/, ../../assets/ ...
      // Covers: src="...", href="...", and any data-* attribute pointing at assets/
      // (e.g. data-icon, data-src, data-hover-icon — used by JS for dynamic swaps).
      return html
        .replace(/src=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `src=${q}${CDN_BASE}/assets/`)
        .replace(/href=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, q) => `href=${q}${CDN_BASE}/assets/`)
        .replace(/(data-[a-z-]+)=(["'])(?:\.\/|(?:\.\.\/)+)?assets\//g, (_m, attr, q) => `${attr}=${q}${CDN_BASE}/assets/`);
    }
    
    function extractSection(content: string, heading: string): string {
      const lines = content.split("\n");
      const headingLower = heading.toLowerCase();
      let inSection = false;
      const out: string[] = [];
      for (const line of lines) {
        if (/^#{2,3} /.test(line)) {
          if (line.toLowerCase().includes(headingLower)) {
            inSection = true;
            out.push(line);
            continue;
          }
          if (inSection) break;
        }
        if (inSection) out.push(line);
      }
      return out.length ? out.join("\n").trim() : `[Section "${heading}" not found]`;
    }
    
    function extractHtmlBlock(content: string, heading?: string): string {
      const src = heading ? extractSection(content, heading) : content;
      const match = src.match(/```html\n([\s\S]*?)```/);
      return match ? match[1].trim() : "[No HTML block found]";
    }
Behavior4/5

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

No annotations are provided, so the description carries full burden. It states the output is an HTML snippet and implies efficiency (cheaper). Although it doesn't explicitly mention read-only or side effects, the purpose is clear and no contradictions exist.

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 two sentences that are front-loaded and contain no unnecessary words. Every sentence adds value.

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

Completeness5/5

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

Given the tool's simplicity (one parameter, no output schema) and the rich annotations, the description provides sufficient context: purpose, usage guidance, and comparison to alternatives.

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?

Input schema has 100% description coverage, including one parameter with an enum and description. The tool description adds no extra parameter semantics beyond the schema, so baseline 3 is appropriate.

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 tool returns 'the canonical HTML snippet for an Elegant 1.0 component,' which is a specific verb and resource. It also contrasts with reading full wiki files, distinguishing it from siblings like get_full_wiki_file.

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

Usage Guidelines5/5

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

The description explicitly advises when to use this tool: 'Much cheaper than reading a full wiki .md file. Use this instead of Read on any component wiki file.' This provides clear context and excludes alternatives.

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/Anguraj-zoho/elegant-mcp'

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