list_directory
Browse files and directories in a specified path to view local project contents for development tasks.
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 handler function that implements the list_directory tool logic: resolves path, reads directory entries, formats with icons, and returns formatted text content.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 'path' parameter.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 metadata (name, description, schema) in the ListToolsRequestSchema response.{ 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);