Skip to main content
Glama
Jpisnice

@jpisnice/shadcn-ui-mcp-server

by Jpisnice

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
NameRequiredDescriptionDefault
blockNameYesName of the block (e.g., "calendar-01", "dashboard-01", "login-02")
includeComponentsNoWhether to include component files for complex blocks (default: true)

Implementation Reference

  • 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)
          }`
        );
      }
    }
  • 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)",
      },
    };
  • 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
    };
  • 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
        }
      }
    }; 
  • 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"],
      },
    },
  • 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')
    }),
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