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();
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

B3.3/5.0
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 this is a read operation ('Get detailed information'), which is helpful, but it doesn't describe what 'detailed information' includes (e.g., properties, usage, dependencies), whether there are rate limits, authentication requirements, or error handling. For a tool with zero annotation coverage, this leaves significant gaps in understanding its behavior.

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's front-loaded with the core action and resource, making it easy to parse quickly. There's no wasted language, and it earns its place by providing essential context.

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?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on what 'detailed information' entails, which is critical since there's no output schema to clarify the return values. For a tool that presumably returns structured data about components, more context on the output would improve 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?

The input schema has 100% description coverage, with the parameter 'componentName' clearly documented in the schema as 'Name of the shadcn/ui component (e.g., "accordion", "button")'. The description doesn't add any additional meaning beyond what the schema provides, such as format constraints or examples not already covered. With high schema coverage, the baseline score of 3 is appropriate.

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 detailed information') and resource ('specific shadcn/ui component'), making the purpose immediately understandable. It distinguishes from 'list_shadcn_components' (which likely lists all components) and 'search_components' (which likely searches across components), though it doesn't explicitly differentiate from 'get_component_examples' which might overlap in retrieving component-related information.

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

Usage Guidelines3/5

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

The description implies usage when detailed information about a specific component is needed, but it doesn't provide explicit guidance on when to use this tool versus alternatives like 'get_component_examples' or 'search_components'. There's no mention of prerequisites, exclusions, or specific scenarios where this tool is preferred over siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.