Skip to main content
Glama
heilgar

Shadcn UI MCP Server

by heilgar

list-components

Discover and manage Shadcn UI components by listing available options for integration. Use this tool to explore and select components within compatible AI tools for streamlined UI development.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler function for the 'list-components' tool. It fetches the components page from shadcn/ui, parses the HTML to extract component names using parseComponentsFromHtml, and returns the list as JSON.
    export const listComponents = async () => {
        try {
            const response = await fetchWithRetry(`${BASE_URL}/components`);
            const html = await response.text();
            const components = parseComponentsFromHtml(html);
            return createResponse(JSON.stringify(components, null, 2));
        } catch (error) {
            return handleError(error, "Error fetching components list");
        }
    }
  • src/index.ts:10-15 (registration)
    Registration of the 'list-components' tool in the toolDefinitions object, specifying description, empty input parameters/schema, and linking to the listComponents handler. The tool is later registered via server.tool() in a loop.
    "list-components": {
        description: "Get the list of available shadcn/ui components",
        parameters: {},
        toolSchema: {},
        handler: listComponents
    },
  • Input schema for the 'list-components' tool, which takes no parameters (empty objects).
    parameters: {},
    toolSchema: {},
  • Key helper function used by the handler to parse the fetched HTML and extract the list of available shadcn/ui component names using Cheerio.
    export function parseComponentsFromHtml(html: string): string[] {
        if (!html || typeof html !== 'string') {
            throw new Error('Invalid HTML content');
        }
        
        try {
            const $ = loadCheerio(html);
            
            const components = $('a[href^="/docs/components/"]')
                .map((_, el) => {
                    const href = $(el).attr('href');
                    return href?.split('/').pop();
                })
                .get()
                .filter((name): name is string => Boolean(name))
                .sort();
            
            if (components.length === 0) {
                console.error('Warning: No components found in HTML');
            }
            
            return components;
        } catch (error) {
            throw new Error(`Failed to parse components: ${error instanceof Error ? error.message : String(error)}`);
        }
    }
  • Helper function for robustly fetching the components page with retries and exponential backoff, used in the handler.
    export async function fetchWithRetry(url: string, retries = RETRY_ATTEMPTS, delay = RETRY_DELAY_MS): Promise<Response> {
        try {
            const response = await fetch(url);
            if (!response.ok) {
                throw new Error(`HTTP error ${response.status}: ${response.statusText}`);
            }
            return response;
        } catch (error) {
            if (retries <= 1) throw error;
            
            await new Promise(resolve => setTimeout(resolve, delay));
            return fetchWithRetry(url, retries - 1, delay * 2); // Exponential backoff
        }
    }
Behavior1/5

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

Tool has no description.

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

Conciseness1/5

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

Tool has no description.

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

Completeness1/5

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

Tool has no description.

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

Parameters1/5

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

Tool has no description.

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

Purpose1/5

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

Tool has no description.

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

Usage Guidelines1/5

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

Tool has no description.

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

Related 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/heilgar/shadcn-ui-mcp-server'

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