Skip to main content
Glama

get_component_code

Retrieve complete HTML code and information for specific KRDS design system components to implement Korean government digital service interfaces.

Instructions

특정 KRDS 컴포넌트의 전체 HTML 코드와 정보를 가져옵니다.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYes컴포넌트 이름 (예: button, text_input, modal)

Implementation Reference

  • Core handler function that loads all components and finds the matching one by name, normalizing underscores to dashes.
    export async function getComponentCode(
      loader: KRDSLoader,
      componentName: string
    ): Promise<KRDSComponent | null> {
      const allComponents = await loader.loadComponents();
      
      return allComponents.find(c => 
        c.name === componentName || c.name === componentName.replace(/_/g, '-')
      ) || null;
    }
  • src/index.ts:121-134 (registration)
    Tool registration in getTools() including name, description, and input schema definition.
    {
      name: 'get_component_code',
      description: '특정 KRDS 컴포넌트의 전체 HTML 코드와 정보를 가져옵니다.',
      inputSchema: {
        type: 'object',
        properties: {
          componentName: {
            type: 'string',
            description: '컴포넌트 이름 (예: button, text_input, modal)',
          },
        },
        required: ['componentName'],
      },
    },
  • MCP server wrapper handler that validates input, calls the core getComponentCode, formats the response with component details, HTML code, and usage instructions.
    private async handleGetComponentCode(args: any) {
      if (!args?.componentName) {
        throw new Error('componentName이 필요합니다.');
      }
    
      const component = await getComponentCode(this.loader, args.componentName);
      
      if (!component) {
        return {
          content: [{
            type: 'text',
            text: `컴포넌트 "${args.componentName}"을 찾을 수 없습니다.`,
          }],
        };
      }
    
      const text = 
        `# ${component.name}\n\n` +
        `**카테고리:** ${component.category}\n` +
        `**설명:** ${component.description || '설명 없음'}\n\n` +
        `## HTML 코드\n\n` +
        `\`\`\`html\n${component.htmlCode}\n\`\`\`\n\n` +
        `## 사용법\n\n` +
        `1. KRDS CSS 파일을 프로젝트에 포함시킵니다:\n` +
        `   \`<link rel="stylesheet" href="node_modules/krds-uiux/resources/css/krds.css">\`\n\n` +
        `2. 위 HTML 코드를 복사하여 사용하세요.\n\n` +
        `3. 필요에 따라 클래스와 내용을 수정하세요.`;
    
      return {
        content: [{ type: 'text', 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 states the tool fetches HTML code and information, implying a read-only operation, but doesn't disclose any behavioral traits such as authentication needs, rate limits, error handling, or what '정보' (information) entails beyond HTML. For a tool with zero annotation coverage, this is a significant gap in transparency.

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 any wasted words. It is appropriately sized and front-loaded, making it easy for an agent to quickly understand the core function. Every part of the sentence contributes to clarifying the tool's intent.

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 the complexity of fetching component code and information, with no annotations and no output schema, the description is incomplete. It doesn't explain what '정보' (information) includes, the format of the HTML code, potential errors, or any behavioral aspects. For a tool that retrieves detailed data, more context is needed to guide the agent effectively, especially without structured output information.

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 'componentName' documented as '컴포넌트 이름 (예: button, text_input, modal)' (component name, e.g., button, text_input, modal). The description adds no additional parameter semantics beyond what the schema provides, such as format constraints or examples. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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: '가져옵니다' (fetches/retrieves) specific KRDS component's '전체 HTML 코드와 정보' (full HTML code and information). It specifies the resource (KRDS component) and what is retrieved (HTML code + information). However, it doesn't explicitly differentiate from siblings like 'list_all_components' or 'search_krds_components', which might list or search components rather than fetch detailed code.

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 doesn't mention prerequisites, context for usage, or compare to sibling tools such as 'list_all_components' (for listing) or 'search_krds_components' (for searching). This lack of explicit when/when-not or alternative references leaves the agent without clear usage direction.

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/re-rank/UIUX-MCP'

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