Skip to main content
Glama
totodev999

shadcn-ui MCP Server

by totodev999

get_component_details

Retrieve documentation and usage details for shadcn/ui components to understand implementation and examples.

Instructions

Get detailed information about a specific shadcn/ui component

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYesName of the shadcn/ui component (e.g., "accordion", "button")

Implementation Reference

  • The primary handler function for the 'get_component_details' tool. It validates the input component name, checks the component cache, fetches details using fetchComponentDetails if not cached, caches the result, and returns a standardized JSON response.
    private async handleGetComponentDetails(args: any) {
      const componentName = this.validateComponentName(args);
    
      try {
        // Check cache first
        if (this.componentCache.has(componentName)) {
          return this.createSuccessResponse(
            this.componentCache.get(componentName)
          );
        }
    
        // Fetch component details
        const componentInfo = await this.fetchComponentDetails(componentName);
    
        // Save to cache
        this.componentCache.set(componentName, componentInfo);
    
        return this.createSuccessResponse(componentInfo);
      } catch (error) {
        this.handleAxiosError(error, `Component "${componentName}"`);
      }
    }
  • src/index.ts:117-132 (registration)
    Registration of the 'get_component_details' tool in the ListToolsRequestSchema handler, including name, description, and input schema specifying the required 'componentName' parameter.
    {
      name: 'get_component_details',
      description:
        'Get detailed information about a specific shadcn/ui component',
      inputSchema: {
        type: 'object',
        properties: {
          componentName: {
            type: 'string',
            description:
              'Name of the shadcn/ui component (e.g., "accordion", "button")',
          },
        },
        required: ['componentName'],
      },
    },
  • Switch case in CallToolRequestSchema handler that routes calls to the 'get_component_details' tool to the handleGetComponentDetails method.
    case 'get_component_details':
      return await this.handleGetComponentDetails(request.params.arguments);
  • Key helper function called by the handler to fetch and parse detailed component information from the shadcn/ui documentation website using axios and cheerio, extracting description, installation, usage, and props.
    private async fetchComponentDetails(
      componentName: string
    ): Promise<ComponentInfo> {
      const response = await this.axiosInstance.get(
        `${this.SHADCN_DOCS_URL}/docs/components/${componentName}`
      );
      const $ = cheerio.load(response.data);
    
      // Extract component information
      const title = $('h1').first().text().trim();
    
      // Extract description properly
      const description = this.extractDescription($);
    
      // Extract GitHub source code link
      const sourceUrl = `${this.SHADCN_GITHUB_URL}/tree/main/apps/www/registry/default/ui/${componentName}`;
    
      // Extract installation instructions
      const installation = this.extractInstallation($);
    
      // Extract usage examples
      const usage = this.extractUsage($);
    
      // Extract variant information
      const props = this.extractVariants($, componentName);
    
      return {
        name: componentName,
        description,
        url: `${this.SHADCN_DOCS_URL}/docs/components/${componentName}`,
        sourceUrl,
        installation: installation.trim(),
        usage: usage.trim(),
        props: Object.keys(props).length > 0 ? props : undefined,
      };
    }
  • Helper function used by the handler to validate and normalize the 'componentName' input parameter.
    private validateComponentName(args: any): string {
      if (!args?.componentName || typeof args.componentName !== 'string') {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Component name is required and must be a string'
        );
      }
      return args.componentName.toLowerCase();
    }
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. While 'Get' implies a read operation, it doesn't specify what 'detailed information' includes, whether there are authentication requirements, rate limits, error conditions, or response format. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is a single, efficient sentence that gets straight to the point with no wasted words. It's appropriately sized for a simple retrieval tool, though it could potentially be more structured with additional context about what 'detailed information' entails.

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?

For a single-parameter read tool with good schema coverage but no output schema, the description is minimally adequate. It identifies the core purpose but lacks important context about what constitutes 'detailed information', how results are structured, and differentiation from sibling tools. The absence of annotations and output schema increases the need for more descriptive completeness.

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?

Schema description coverage is 100%, with the single parameter 'componentName' clearly documented in the schema. The description adds no additional parameter semantics beyond what the schema already provides (e.g., no examples beyond those in schema, no format requirements). The baseline score of 3 reflects adequate coverage through the schema alone.

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 verb 'Get' and resource 'detailed information about a specific shadcn/ui component', making the purpose unambiguous. However, it doesn't explicitly differentiate from sibling tools like 'get_component_examples' or 'list_shadcn_components', which likely provide different types of component information.

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 its siblings. It doesn't mention alternatives like 'get_component_examples' for usage examples or 'list_shadcn_components' for component listings, leaving the agent to guess about the appropriate context for this specific detail-retrieval tool.

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/totodev999/shadcn-ui-mcp-server_clone'

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