rnr-mcp-server
Version:
A Model Context Protocol (MCP) server for React Native Reusables components, providing AI assistants with access to component source code, demos, and metadata for React Native development.
39 lines (38 loc) • 1.42 kB
JavaScript
import { getAxiosImplementation } from '../../utils/framework.js';
import { logError } from '../../utils/logger.js';
export async function handleGetDirectoryStructure({ path, owner, repo, branch }) {
try {
const axios = await getAxiosImplementation();
// Get the default path based on available properties
const defaultPath = axios.paths.BASE_PATH;
const directoryTree = await axios.buildDirectoryTree(owner || axios.paths.REPO_OWNER, repo || axios.paths.REPO_NAME, path || defaultPath, 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: packages/ui/src)'
},
owner: {
type: 'string',
description: 'Repository owner (default: "mrzachnugent")'
},
repo: {
type: 'string',
description: 'Repository name (default: "react-native-reusables")'
},
branch: {
type: 'string',
description: 'Branch name (default: "main")'
}
};