Skip to main content
Glama
Jpisnice

@jpisnice/shadcn-ui-mcp-server

by Jpisnice

get_component

Read-only

Retrieve the source code for any shadcn/ui v4 component by providing its name. Use this to get the exact implementation for your project.

Instructions

Get the source code for a specific shadcn/ui v4 component

Input Schema

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

Implementation Reference

  • The main handler function for the 'get_component' tool. Accepts { componentName } and calls axios.getComponentSource() to fetch the component source code from the shadcn/ui v4 GitHub registry, returning it as text content.
    export async function handleGetComponent({ componentName }: { componentName: string }) {
      try {
        const axios = await getAxiosImplementation();
        const sourceCode = await axios.getComponentSource(componentName);
        return {
          content: [{ type: "text", text: sourceCode }]
        };
      } catch (error) {
        logError(`Failed to get component "${componentName}"`, error);
        throw new Error(`Failed to get component "${componentName}": ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • Input schema for the 'get_component' tool, defining the 'componentName' parameter as a required string with a description.
    export const schema = {
      componentName: {
        type: 'string',
        description: 'Name of the shadcn/ui component (e.g., "accordion", "button")'
      }
    }; 
  • Registration of the 'get_component' tool in the tools object, mapping it to the imported getComponentSchema and providing description and input schema.
    export const tools = {
      'get_component': {
        name: 'get_component',
        description: 'Get the source code for a specific shadcn/ui v4 component',
        inputSchema: {
          type: 'object',
          properties: getComponentSchema,
          required: ['componentName']
        }
      },
  • Registration of the 'get_component' handler in the toolHandlers map, mapping the name 'get_component' to handleGetComponent function.
    export const toolHandlers = {
      get_component: handleGetComponent,
      get_component_demo: handleGetComponentDemo,
      list_components: handleListComponents,
      get_component_metadata: handleGetComponentMetadata,
      get_directory_structure: handleGetDirectoryStructure,
      get_block: handleGetBlock,
      list_blocks: handleListBlocks,
      apply_theme: handleApplyTheme,
      list_themes: handleListThemes,
      get_theme: handleGetTheme
    };
  • The getComponentSource() helper function that actually fetches the component source code from the GitHub raw URL for the shadcn/ui v4 registry.
    async function getComponentSource(componentName: string): Promise<string> {
        const basePath = getRegistryBasePath();
        const componentPath = `${basePath}/ui/${componentName.toLowerCase()}.tsx`;
        
        try {
            const response = await githubRaw.get(`/${componentPath}`);
            return response.data;
        } catch (error) {
            throw new Error(`Component "${componentName}" not found in v4 registry`);
        }
    }
Behavior3/5

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

Annotations already declare readOnlyHint=true, signaling a safe read operation. The description confirms 'get the source code' but adds no additional behavioral context beyond what is already indicated.

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, clear sentence with no filler. Every word contributes meaning, achieving maximum conciseness.

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?

Although the tool is simple, the description does not specify the output format (e.g., raw string, JSON) or mention any limitations. Given the absence of an output schema, this omission leaves some ambiguity for the agent.

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% for the single parameter 'componentName', including an example. The tool description does not add new meaning beyond the schema, so baseline score of 3 is appropriate.

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

Purpose5/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 the resource 'source code for a specific shadcn/ui v4 component', effectively distinguishing it from siblings like get_block or get_component_demo.

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 vs alternatives such as get_component_demo or get_component_metadata. An agent lacks context for tool selection.

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

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