get_block
Retrieve the source code for specific shadcn/ui v4 blocks, such as calendars or dashboards, with optional component files for complex blocks. Utilize this tool to streamline UI development.
Instructions
Get source code for a specific shadcn/ui v4 block (e.g., calendar-01, dashboard-01)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| blockName | Yes | Name of the block (e.g., "calendar-01", "dashboard-01", "login-02") | |
| includeComponents | No | Whether to include component files for complex blocks (default: true) |
Implementation Reference
- src/tools/blocks/get-block.ts:4-38 (handler)The handler function that implements the core logic of the 'get_block' tool. It checks the framework, fetches block code using axios.getBlockCode, and returns formatted content or throws an error.export async function handleGetBlock({ blockName, includeComponents = true, }: { blockName: string; includeComponents?: boolean; }) { const framework = getFramework(); if (framework === "react-native") { return { content: [ { type: "text", text: `Blocks are not available for React Native framework. The react-native-reusables repository does not provide block templates.`, }, ], }; } try { const axios = await getAxiosImplementation(); const blockData = await axios.getBlockCode(blockName, includeComponents); return { content: [{ type: "text", text: JSON.stringify(blockData, null, 2) }], }; } catch (error) { logError(`Failed to get block "${blockName}"`, error); throw new Error( `Failed to get block "${blockName}": ${ error instanceof Error ? error.message : String(error) }` ); } }
- src/tools/blocks/get-block.ts:40-52 (schema)TypeScript schema definition for the 'get_block' tool input parameters, used for documentation and validation.export const schema = { blockName: { type: "string", description: 'Name of the block (e.g., "calendar-01", "dashboard-01", "login-02")', }, includeComponents: { type: "boolean", description: "Whether to include component files for complex blocks (default: true)", }, };
- src/tools/index.ts:17-25 (registration)Registration of all tool handlers, mapping 'get_block' to the handleGetBlock function imported from blocks/get-block.ts.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:37-98 (registration)Tool metadata registration including schema reference for list_tools response and capabilities.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'] } }, 'get_component_demo': { name: 'get_component_demo', description: 'Get demo code illustrating how a shadcn/ui v4 component should be used', inputSchema: { type: 'object', properties: getComponentDemoSchema, required: ['componentName'] } }, 'list_components': { name: 'list_components', description: 'Get all available shadcn/ui v4 components', inputSchema: { type: 'object', properties: {} } }, 'get_component_metadata': { name: 'get_component_metadata', description: 'Get metadata for a specific shadcn/ui v4 component', inputSchema: { type: 'object', properties: getComponentMetadataSchema, required: ['componentName'] } }, 'get_directory_structure': { name: 'get_directory_structure', description: 'Get the directory structure of the shadcn-ui v4 repository', inputSchema: { type: 'object', properties: getDirectoryStructureSchema } }, 'get_block': { name: 'get_block', description: 'Get source code for a specific shadcn/ui v4 block (e.g., calendar-01, dashboard-01)', inputSchema: { type: 'object', properties: getBlockSchema, required: ['blockName'] } }, 'list_blocks': { name: 'list_blocks', description: 'Get all available shadcn/ui v4 blocks with categorization', inputSchema: { type: 'object', properties: listBlocksSchema } } };
- src/server/capabilities.ts:152-171 (schema)MCP server capabilities declaration for the 'get_block' tool, including input schema for protocol compliance.get_block: { description: "Get source code for a specific shadcn/ui v4 block (e.g., calendar-01, dashboard-01)", inputSchema: { type: "object", properties: { blockName: { type: "string", description: 'Name of the block (e.g., "calendar-01", "dashboard-01", "login-02")', }, includeComponents: { type: "boolean", description: "Whether to include component files for complex blocks (default: true)", }, }, required: ["blockName"], }, },
- src/utils/validation.ts:47-52 (schema)Joi validation schema for 'get_block' tool parameters, used in request validation pipeline.blockRequest: Joi.object({ blockName: Joi.string().required().min(1).max(200) .description('Name of the block'), includeComponents: Joi.boolean().optional() .description('Whether to include component files') }),