Skip to main content
Glama
Jpisnice

@jpisnice/shadcn-ui-mcp-server

by Jpisnice

get_directory_structure

Retrieve the directory structure of shadcn-ui v4 repository to understand component organization, usage, and installation details for development projects.

Instructions

Get the directory structure of the shadcn-ui v4 repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
branchNoBranch name (default: "main")
ownerNoRepository owner (default: "shadcn-ui")
pathNoPath within the repository (default: v4 registry)
repoNoRepository name (default: "ui")

Implementation Reference

  • The main asynchronous handler function that implements the core logic of the 'get_directory_structure' tool. It uses axios to build and return the directory tree structure from the specified GitHub repository path, owner, repo, and branch, with sensible defaults.
    export async function handleGetDirectoryStructure({ 
      path, 
      owner, 
      repo, 
      branch 
    }: { 
      path?: string, 
      owner?: string, 
      repo?: string, 
      branch?: string 
    }) {
      try {
        const axios = await getAxiosImplementation();
        // Get the default path based on available properties
        const defaultPath = 'BLOCKS' in axios.paths ? axios.paths.BLOCKS : axios.paths.NEW_YORK_V4_PATH;
        
        const directoryTree = await axios.buildDirectoryTree(
          owner || axios.paths.REPO_OWNER,
          repo || axios.paths.REPO_NAME,
          path || defaultPath,
          branch || axios.paths.REPO_BRANCH
        );
        return {
          content: [{ 
            type: "text", 
            text: JSON.stringify(directoryTree, null, 2)
          }]
        };
      } catch (error) {
        logError('Failed to get directory structure', error);
        throw new Error(`Failed to get directory structure: ${error instanceof Error ? error.message : String(error)}`);
      }
    }
  • The input schema defining the optional parameters (path, owner, repo, branch) for the 'get_directory_structure' tool.
    export const schema = {
      path: {
        type: 'string',
        description: 'Path within the repository (default: v4 registry)'
      },
      owner: {
        type: 'string',
        description: 'Repository owner (default: "shadcn-ui")'
      },
      repo: {
        type: 'string',
        description: 'Repository name (default: "ui")'
      },
      branch: {
        type: 'string',
        description: 'Branch name (default: "main")'
      }
    }; 
  • Registers the 'get_directory_structure' tool by mapping its name to the handleGetDirectoryStructure handler function, imported from './repository/get-directory-structure.js'.
    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
    };
  • Registers the input schema for 'get_directory_structure' tool as getDirectoryStructureSchema, imported from './repository/get-directory-structure.js'.
    export const toolSchemas = {
      get_component: getComponentSchema,
      get_component_demo: getComponentDemoSchema,
      list_components: listComponentsSchema,
      get_component_metadata: getComponentMetadataSchema,
      get_directory_structure: getDirectoryStructureSchema,
      get_block: getBlockSchema,
      list_blocks: listBlocksSchema
    };
  • Defines the full tool specification object for 'get_directory_structure' including name, description, and inputSchema, used for tool listing and capabilities.
    'get_directory_structure': {
      name: 'get_directory_structure',
      description: 'Get the directory structure of the shadcn-ui v4 repository',
      inputSchema: {
        type: 'object',
        properties: getDirectoryStructureSchema
      }
    },
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/Jpisnice/shadcn-ui-mcp-server'

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