Skip to main content
Glama

get_project_structure

Retrieve the complete directory structure for a specified project to understand its organization and file layout.

Instructions

Get the complete directory structure of a specific project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_nameYesName of the project

Implementation Reference

  • The core handler function that recursively generates the project directory structure as a nested tree object.
    async function getProjectStructure( projectName: string, subPath: string = "" ): Promise<ProjectStructure> { const fullPath = path.join(CONTEXT_DIR, projectName, subPath); const stats = await fs.stat(fullPath); const name = subPath ? path.basename(subPath) : projectName; if (stats.isFile()) { return { name, type: "file", path: subPath || projectName, }; } const entries = await fs.readdir(fullPath, { withFileTypes: true }); const children = await Promise.all( entries.map((entry) => getProjectStructure( projectName, subPath ? path.join(subPath, entry.name) : entry.name ) ) ); return { name, type: "directory", path: subPath || projectName, children, }; }
  • src/index.ts:251-266 (registration)
    Tool dispatch case in the CallToolRequestSchema handler that extracts arguments, calls the getProjectStructure function, and formats the response.
    case "get_project_structure": { const projectName = args.project_name as string; if (!projectName) { throw new Error("project_name is required"); } const structure = await getProjectStructure(projectName); return { content: [ { type: "text", text: JSON.stringify(structure, null, 2), }, ], }; }
  • Input schema definition for the get_project_structure tool, specifying the required project_name parameter.
    inputSchema: { type: "object", properties: { project_name: { type: "string", description: "Name of the project", }, }, required: ["project_name"], },
  • TypeScript interface defining the structure of the project tree returned by the tool.
    interface ProjectStructure { name: string; type: "file" | "directory"; path: string; children?: ProjectStructure[]; }
  • src/index.ts:168-182 (registration)
    Tool registration in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: "get_project_structure", description: "Get the complete directory structure of a specific project", inputSchema: { type: "object", properties: { project_name: { type: "string", description: "Name of the project", }, }, required: ["project_name"], }, },

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/doko89/mcp-mycontext'

If you have feedback or need assistance with the MCP directory API, please join our Discord server