Skip to main content
Glama

get_project_files

Read-only

Retrieve a recursive file tree of a Godot project, filtered by extensions and depth, to discover project structure when paths are unknown.

Instructions

Return a recursive file tree of a Godot project as nested { name, type, path, extension?, children? } objects. Use to discover project structure when paths are unknown. Pass extensions to filter (e.g. ["gd","tscn"]); maxDepth caps recursion (-1 unlimited). Skips hidden (dot-prefixed) entries and the .mcp directory.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectPathYesPath to the Godot project directory
maxDepthNoMaximum recursion depth. -1 means unlimited (default: -1)
extensionsNoFilter to only these file extensions (e.g. ["gd", "tscn"]). Omit to include all.

Implementation Reference

  • The main handler function for the get_project_files tool. Normalizes args, validates project args, builds a recursive file tree (with optional maxDepth and extensions filter), and returns the tree as JSON.
    export async function handleGetProjectFiles(args: OperationParams) {
      args = normalizeParameters(args);
      const v = validateProjectArgs(args);
      if ('isError' in v) return v;
    
      try {
        const maxDepth = typeof args.maxDepth === 'number' ? args.maxDepth : -1;
        const extensions = Array.isArray(args.extensions)
          ? (args.extensions as string[]).map((e) => e.toLowerCase().replace(/^\./, ''))
          : null;
        const tree = buildFilesystemTree(v.projectPath, '', maxDepth, 0, extensions);
        return { content: [{ type: 'text', text: JSON.stringify(tree) }] };
      } catch (error: unknown) {
        const errorMessage = error instanceof Error ? error.message : 'Unknown error';
        return createErrorResponse(`Failed to get project files: ${errorMessage}`, [
          'Check if the project directory is accessible',
        ]);
      }
    }
  • Recursive helper function that builds a nested FileTreeNode structure for the project directory. Skips hidden (dot-prefixed) entries, respects maxDepth, and filters by extensions if provided.
    function buildFilesystemTree(
      currentPath: string,
      relativePath: string,
      maxDepth: number,
      currentDepth: number,
      extensions: string[] | null,
    ): FileTreeNode {
      const name = basename(currentPath);
      const node: FileTreeNode = { name, type: 'dir', path: relativePath || '.' };
      if (maxDepth !== -1 && currentDepth >= maxDepth) {
        node.children = [];
        return node;
      }
      const children: FileTreeNode[] = [];
      try {
        const entries = readdirSync(currentPath, { withFileTypes: true });
        for (const entry of entries) {
          if (entry.name.startsWith('.')) continue;
          const childRelPath = relativePath ? `${relativePath}/${entry.name}` : entry.name;
          if (entry.isDirectory()) {
            children.push(
              buildFilesystemTree(
                join(currentPath, entry.name),
                childRelPath,
                maxDepth,
                currentDepth + 1,
                extensions,
              ),
            );
          } else if (entry.isFile()) {
            const ext = entry.name.includes('.') ? entry.name.split('.').pop()!.toLowerCase() : '';
            if (extensions && !extensions.includes(ext)) continue;
            children.push({ name: entry.name, type: 'file', path: childRelPath, extension: ext });
          }
        }
      } catch (err) {
        logDebug(`buildFilesystemTree error at ${currentPath}: ${err}`);
      }
      node.children = children;
      return node;
    }
  • TypeScript interface for the file tree node used by buildFilesystemTree and returned by handleGetProjectFiles.
    interface FileTreeNode {
      name: string;
      type: 'file' | 'dir';
      path: string;
      extension?: string;
      children?: FileTreeNode[];
    }
  • Tool definition (schema) for get_project_files, registered in projectToolDefinitions. Declares inputSchema with projectPath (required), maxDepth, and extensions.
      name: 'get_project_files',
      description:
        'Return a recursive file tree of a Godot project as nested { name, type, path, extension?, children? } objects. Use to discover project structure when paths are unknown. Pass extensions to filter (e.g. ["gd","tscn"]); maxDepth caps recursion (-1 unlimited). Skips hidden (dot-prefixed) entries and the .mcp directory.',
      annotations: { readOnlyHint: true },
      inputSchema: {
        type: 'object',
        properties: {
          projectPath: { type: 'string', description: 'Path to the Godot project directory' },
          maxDepth: {
            type: 'number',
            description: 'Maximum recursion depth. -1 means unlimited (default: -1)',
          },
          extensions: {
            type: 'array',
            items: { type: 'string' },
            description:
              'Filter to only these file extensions (e.g. ["gd", "tscn"]). Omit to include all.',
          },
        },
        required: ['projectPath'],
      },
    },
  • src/dispatch.ts:95-95 (registration)
    Registration of the get_project_files tool in the dispatch table, mapping the tool name to the handleGetProjectFiles handler.
    get_project_files: (_runner, args) => handleGetProjectFiles(args),
Behavior5/5

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

Annotations (readOnlyHint=true) already signal read-only; description adds valuable behavioral details: skips hidden entries and .mcp directory, and recursion behavior. No contradiction.

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?

Two sentences, front-loaded with core purpose, no redundant words. Every sentence contributes functional clarity.

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

Completeness5/5

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

Despite no output schema, description fully explains return shape and optionality, parameter behavior, and filtering/skipping rules. Sufficient for agent invocation.

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 coverage is 100% with descriptions for all parameters; description reiterates filtering examples and default, but adds minimal new meaning beyond schema.

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

Purpose5/5

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

Description clearly states it returns a recursive file tree with specific fields, and positions it for discovering project structure when paths are unknown, distinguishing it from siblings like search_project.

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

Usage Guidelines4/5

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

Explicitly states when to use (discover structure when paths unknown) and hints at filtering via extensions and maxDepth, but lacks explicit when-not-to-use or alternative tool mentions.

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/Erodenn/godot-mcp-runtime'

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