Skip to main content
Glama
JojoSlice

README Generator MCP Server

by JojoSlice

read_project_structure

Analyzes project directory structure to generate tree-like file and folder layouts for README documentation creation.

Instructions

Read the directory structure of a project. Returns a tree-like structure of files and folders.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe absolute path to the project directory
maxDepthNoMaximum depth to traverse (default: 3)

Implementation Reference

  • Handler for the 'read_project_structure' tool. Destructures input arguments, calls the getDirectoryStructure helper function, stringifies the result as JSON, and returns it as text content in the MCP response format.
    case "read_project_structure": {
      const { path, maxDepth = 3 } = args as {
        path: string;
        maxDepth?: number;
      };
      const structure = await getDirectoryStructure(path, maxDepth);
      return {
        content: [
          {
            type: "text",
            text: JSON.stringify(structure, null, 2),
          },
        ],
      };
    }
  • Input schema definition for the 'read_project_structure' tool, specifying the required 'path' parameter and optional 'maxDepth'.
      type: "object",
      properties: {
        path: {
          type: "string",
          description: "The absolute path to the project directory",
        },
        maxDepth: {
          type: "number",
          description: "Maximum depth to traverse (default: 3)",
          default: 3,
        },
      },
      required: ["path"],
    },
  • src/index.ts:391-409 (registration)
    Registration of the 'read_project_structure' tool in the ListTools response, including name, description, and input schema.
      name: "read_project_structure",
      description:
        "Read the directory structure of a project. Returns a tree-like structure of files and folders.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The absolute path to the project directory",
          },
          maxDepth: {
            type: "number",
            description: "Maximum depth to traverse (default: 3)",
            default: 3,
          },
        },
        required: ["path"],
      },
    },
  • Core helper function that recursively reads the directory structure up to a maximum depth, ignoring common patterns like node_modules, and builds a tree-like object representation.
    async function getDirectoryStructure(
      dirPath: string,
      maxDepth: number = 3,
      currentDepth: number = 0,
      ignorePatterns: string[] = [
        "node_modules",
        ".git",
        "dist",
        "build",
        ".next",
        "coverage",
      ],
    ): Promise<any> {
      if (currentDepth >= maxDepth) {
        return null;
      }
    
      try {
        const entries = await readdir(dirPath, { withFileTypes: true });
        const structure: any = {
          type: "directory",
          name: parse(dirPath).base || dirPath,
          children: [],
        };
    
        for (const entry of entries) {
          if (ignorePatterns.some((pattern) => entry.name.includes(pattern))) {
            continue;
          }
    
          const fullPath = join(dirPath, entry.name);
    
          if (entry.isDirectory()) {
            const subStructure = await getDirectoryStructure(
              fullPath,
              maxDepth,
              currentDepth + 1,
              ignorePatterns,
            );
            if (subStructure) {
              structure.children.push(subStructure);
            }
          } else {
            structure.children.push({
              type: "file",
              name: entry.name,
              path: fullPath,
            });
          }
        }
    
        return structure;
      } catch (error) {
        throw new Error(`Failed to read directory: ${error}`);
      }
    }
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool reads and returns a tree-like structure, which implies it's a read-only operation, but doesn't cover aspects like error handling (e.g., if the path doesn't exist), performance considerations, or any side effects. It adds basic context but lacks depth for a tool with no annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise and front-loaded: two sentences that directly state the action and output without unnecessary words. Every sentence earns its place by conveying essential information efficiently.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is minimally complete. It covers the basic purpose and output but lacks details on usage guidelines, behavioral traits, and error handling. With no output schema, it should ideally explain return values more thoroughly, but it only mentions 'tree-like structure' vaguely.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters ('path' and 'maxDepth') with descriptions. The description doesn't add any parameter-specific details beyond what the schema provides, such as format examples or constraints. Baseline 3 is appropriate when the schema handles parameter documentation adequately.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Read the directory structure of a project' specifies the verb (read) and resource (directory structure), and 'Returns a tree-like structure of files and folders' clarifies the output. However, it doesn't explicitly differentiate from sibling tools like 'analyze_project' or 'read_file', which might have overlapping functionality.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention when to choose 'read_project_structure' over 'analyze_project' or 'read_file', nor does it specify prerequisites or exclusions. Usage is implied only by the purpose statement.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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/JojoSlice/README-Gen-MCP-Server'

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