Skip to main content
Glama

get_component

Retrieve HTML code for Basecoat UI components to build accessible user interfaces. Specify a component name to get its HTML structure.

Instructions

Get HTML code for a specific Basecoat component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesComponent name (e.g., "button-primary", "card-basic", "input-with-label")

Implementation Reference

  • Handler for the 'get_component' tool: calls getComponent method with args.name and formats the response as markdown with HTML code.
    case 'get_component': {
      const component = await this.getComponent(args.name);
      return {
        content: [
          {
            type: 'text',
            text: `# ${component.name}\n\n**Category:** ${component.category}\n**File:** ${component.file}\n\n## HTML Code\n\`\`\`html\n${component.html}\n\`\`\``,
          },
        ],
      };
    }
  • Core implementation: scans components list, finds the matching component file, reads and returns its HTML content with metadata.
    async getComponent(componentName) {
      const components = await this.getComponentsList();
    
      // Search across all categories
      for (const [category, categoryComponents] of Object.entries(components)) {
        const component = categoryComponents.find(comp => comp.name === componentName);
        if (component) {
          const filePath = path.join(__dirname, 'components', category, component.file);
          try {
            const content = await fs.readFile(filePath, 'utf-8');
            return {
              name: componentName,
              category: category,
              html: content.trim(),
              file: component.file
            };
          } catch (error) {
            throw new Error(`Failed to read component file: ${error.message}`);
          }
        }
      }
    
      throw new Error(`Component '${componentName}' not found`);
  • server.js:169-182 (registration)
    Registers the 'get_component' tool in the ListTools response, including name, description, and input schema.
    {
      name: 'get_component',
      description: 'Get HTML code for a specific Basecoat component',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Component name (e.g., "button-primary", "card-basic", "input-with-label")',
          },
        },
        required: ['name'],
      },
    },
  • Input schema definition for the get_component tool, requiring a 'name' string parameter.
    inputSchema: {
      type: 'object',
      properties: {
        name: {
          type: 'string',
          description: 'Component name (e.g., "button-primary", "card-basic", "input-with-label")',
        },
      },
      required: ['name'],
    },
  • Supporting helper: dynamically lists all available components by reading directory structure.
    async getComponentsList() {
      const categories = ['forms', 'navigation', 'feedback', 'interactive', 'layout'];
      const components = {};
    
      for (const category of categories) {
        const categoryPath = path.join(__dirname, 'components', category);
        try {
          const files = await fs.readdir(categoryPath);
          const htmlFiles = files
            .filter(file => file.endsWith('.html'))
            .map(file => ({
              name: file.replace('.html', ''),
              category: category,
              file: file
            }));
    
          if (htmlFiles.length > 0) {
            components[category] = htmlFiles;
          }
        } catch (error) {
          console.error(`Error reading category ${category}:`, error.message);
        }
      }
    
      return components;
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool retrieves HTML code, implying a read-only operation, but doesn't clarify if authentication is needed, rate limits apply, what happens if the component doesn't exist, or the format of the returned HTML. This leaves significant gaps 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 a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded with the core action and resource, making it easy to parse quickly.

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

Completeness2/5

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

Given no annotations and no output schema, the description is incomplete. It doesn't explain what the returned HTML looks like (e.g., full component markup, partial code, error handling), behavioral aspects like permissions or rate limits, or how it differs from sibling tools. For a tool with minimal structured data, more context is needed.

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 'name' well-documented in the schema. The description adds no additional parameter semantics beyond implying the tool fetches HTML for a component identified by name, which is already clear from the schema. This meets the baseline for 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 action ('Get HTML code') and resource ('specific Basecoat component'), making the purpose immediately understandable. However, it doesn't differentiate from sibling tools like 'list_components' or 'search_components' beyond specifying it's for a 'specific' component rather than multiple components.

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 like 'list_components' or 'search_components'. It mentions 'specific' component, implying it's for retrieving a single known component, but doesn't explicitly state this or mention prerequisites or exclusions.

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/GustavoGomezPG/basecoat-mcp'

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