folder_list
Retrieve and display folder contents within a Unity project using specified path and recursive options for subdirectory listing.
Instructions
List contents of a folder in Unity project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Path of the folder to list (default: Assets) | |
| recursive | No | List all subdirectories recursively (default: false) |
Implementation Reference
- src/tools/unity-mcp-tools.ts:525-539 (handler)Executes the 'folder_list' tool: validates args implicitly, calls adapter.listFolder, formats entries with icons and paths, returns formatted text contentcase '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)'}` }] }; }
- src/tools/unity-mcp-tools.ts:300-316 (registration)Registers the 'folder_list' tool in getTools() with name, description, and input schema{ 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)' } } } }
- TypeScript interface defining the structure of folder entries returned by the listFolder operationexport interface FolderEntry { path: string; name: string; type: 'file' | 'folder'; extension?: string; guid: string; }
- Helper method in UnityHttpAdapter that invokes the Unity HTTP endpoint 'folder/list' via generic call methodasync listFolder(path?: string, recursive: boolean = false): Promise<{ path: string; entries: FolderEntry[] }> { return this.call('folder/list', { path, recursive }); }
- src/simple-index.ts:40-42 (registration)Registers the generic MCP tool execution handler that dispatches to UnityMcpTools.executeTool based on tool name (covers folder_list)this.server.setRequestHandler(CallToolRequestSchema, async (request) => { return this.tools.executeTool(request.params.name, request.params.arguments || {}); });