shadcn-svelte-mcp-server
Version:
A Model Context Protocol (MCP) server for shadcn-svelte components, providing AI assistants with access to component source code, demos, blocks, and metadata.
36 lines (35 loc) • 1.23 kB
JavaScript
import { axios } from '../../utils/axios.js';
import { logError } from '../../utils/logger.js';
export async function handleGetDirectoryStructure({ path, owner, repo, branch }) {
try {
const directoryTree = await axios.buildDirectoryTree(owner || axios.paths.REPO_OWNER, repo || axios.paths.REPO_NAME, path || axios.paths.REGISTRY_UI_PATH, 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)}`);
}
}
export const schema = {
path: {
type: 'string',
description: 'Path within the repository (default: v4 registry)'
},
owner: {
type: 'string',
description: 'Repository owner (default: "huntabyte")'
},
repo: {
type: 'string',
description: 'Repository name (default: "shadcn-svelte")'
},
branch: {
type: 'string',
description: 'Branch name (default: "main")'
}
};