Skip to main content
Glama
Jpisnice
by Jpisnice

list_blocks

Retrieve categorized shadcn/ui v4 blocks by specifying a category such as calendar, dashboard, or login for easy integration.

Instructions

Get all available shadcn/ui v4 blocks with categorization

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
categoryNoFilter by category (calendar, dashboard, login, sidebar, products)

Implementation Reference

  • The handleListBlocks function is the core implementation of the list_blocks tool. It checks the framework, handles React Native specially, and fetches available blocks via axios.getAvailableBlocks(category) for other frameworks, returning formatted JSON content.
    export async function handleListBlocks({ category }: { category?: string }) { const framework = getFramework(); if (framework === "react-native") { return { content: [ { type: "text", text: JSON.stringify( { categories: {}, totalBlocks: 0, availableCategories: [], message: "Blocks are not available for React Native framework. The react-native-reusables repository does not provide block templates.", }, null, 2 ), }, ], }; } try { const axios = await getAxiosImplementation(); const blocks = await axios.getAvailableBlocks(category); return { content: [ { type: "text", text: JSON.stringify(blocks, null, 2), }, ], }; } catch (error) { logError("Failed to list blocks", error); throw new Error( `Failed to list blocks: ${ error instanceof Error ? error.message : String(error) }` ); } }
  • The schema export defines the input parameters for the list_blocks tool, specifically the optional 'category' string filter.
    export const schema = { category: { type: "string", description: "Filter by category (calendar, dashboard, login, sidebar, products)", }, };
  • Registration of the handleListBlocks function in the toolHandlers map, which is used by the MCP server to dispatch tool calls.
    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 };
  • Registration of the listBlocksSchema in the toolSchemas map for input validation.
    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 };
  • Definition of the list_blocks tool in the tools export, including name, description, and input schema reference, used for MCP tool listing and capabilities.
    'list_blocks': { name: 'list_blocks', description: 'Get all available shadcn/ui v4 blocks with categorization', inputSchema: { type: 'object', properties: listBlocksSchema } }

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