list_directory
Browse and view files and directories within your local development projects to navigate your codebase structure and locate specific files.
Instructions
List files and directories in a given path
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to directory (relative to projects directory or absolute) |
Implementation Reference
- index.js:264-281 (handler)The main handler function for the 'list_directory' tool. It resolves the directory path, reads the contents using fs.readdir with file types, maps entries to formatted strings with icons, and returns a text content block listing the items.async listDirectory(dirPath) { const resolvedPath = this.resolvePath(dirPath); const entries = await fs.readdir(resolvedPath, { withFileTypes: true }); const items = entries.map((entry) => { const icon = entry.isDirectory() ? '📁' : '📄'; return `${icon} ${entry.name}`; }); return { content: [ { type: 'text', text: `Contents of ${resolvedPath}:\n\n${items.join('\n')}`, }, ], }; }
- index.js:104-113 (schema)Input schema for the 'list_directory' tool, defining the required 'path' parameter as a string.inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to directory (relative to projects directory or absolute)', }, }, required: ['path'], },
- index.js:101-114 (registration)Registration of the 'list_directory' tool in the ListToolsRequestSchema response, including name, description, and input schema.{ name: 'list_directory', description: 'List files and directories in a given path', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to directory (relative to projects directory or absolute)', }, }, required: ['path'], }, },
- index.js:172-173 (registration)Dispatch/registration of the 'list_directory' handler in the CallToolRequestSchema switch statement.case 'list_directory': return await this.listDirectory(args.path);