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
| Name | Required | Description | Default |
|---|---|---|---|
| branch | No | Branch name (default: "main") | |
| owner | No | Repository owner (default: "shadcn-ui") | |
| path | No | Path within the repository (default: v4 registry) | |
| repo | No | Repository 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")' } };
- src/tools/index.ts:17-25 (registration)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 };
- src/tools/index.ts:27-35 (registration)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 };
- src/tools/index.ts:73-80 (registration)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 } },