Skip to main content
Glama

folder_list

List files and subdirectories within Unity project folders to manage assets and navigate project structure. Specify a path and choose recursive listing for comprehensive directory exploration.

Instructions

List contents of a folder in Unity project

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathNoPath of the folder to list (default: Assets)
recursiveNoList all subdirectories recursively (default: false)

Implementation Reference

  • Handler for the 'folder_list' tool. Calls the adapter's listFolder method with provided path and recursive parameters, then formats the directory entries with icons (πŸ“ for folders, πŸ“„ for files) and path information, returning a formatted text response.
    case 'folder_list': {
      const result = await this.adapter.listFolder(args.path, args.recursive);
      const entries = result.entries.map(e => {
        const prefix = e.type === 'folder' ? 'πŸ“' : 'πŸ“„';
        const info = e.type === 'file' ? ` (${e.extension})` : '';
        return `${prefix} ${e.name}${info} - ${e.path}`;
      }).join('\n');
      
      return {
        content: [{
          type: 'text',
          text: `Contents of ${result.path}:\n\n${entries || '(empty)'}`
        }]
      };
    }
  • Registration of the 'folder_list' tool in the getTools() method, including name, description, and input schema definition.
    {
      name: 'folder_list',
      description: 'List contents of a folder in Unity project',
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path of the folder to list (default: Assets)'
          },
          recursive: {
            type: 'boolean',
            description: 'List all subdirectories recursively (default: false)'
          }
        }
      }
    }
  • Input schema for the folder_list tool defining parameters: path (string, optional, default Assets) and recursive (boolean, optional, default false).
      inputSchema: {
        type: 'object',
        properties: {
          path: {
            type: 'string',
            description: 'Path of the folder to list (default: Assets)'
          },
          recursive: {
            type: 'boolean',
            description: 'List all subdirectories recursively (default: false)'
          }
        }
      }
    }
  • Helper method in UnityHttpAdapter that implements listFolder by making an HTTP POST call to Unity server endpoint 'folder/list' with path and recursive parameters.
    async listFolder(path?: string, recursive: boolean = false): Promise<{ path: string; entries: FolderEntry[] }> {
      return this.call('folder/list', { path, recursive });
    }
  • Type definition for FolderEntry used in listFolder response, defining structure of directory listing entries.
    export interface FolderEntry {
      path: string;
      name: string;
      type: 'file' | 'folder';
      extension?: string;
      guid: string;
    }

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/zabaglione/mcp-server-unity'

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