@jpisnice/shadcn-ui-mcp-server
Version:
A Model Context Protocol (MCP) server for shadcn/ui components, providing AI assistants with access to component source code, demos, blocks, and metadata.
25 lines (24 loc) • 912 B
JavaScript
import { axios } from '../../utils/axios.js';
import { logError } from '../../utils/logger.js';
export async function handleGetBlock({ blockName, includeComponents = true }) {
try {
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)}`);
}
}
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)'
}
};