get_directory_info
Retrieve directory contents and file details from Windows Subsystem for Linux environments. Use this tool to list files and obtain information about directory structures securely.
Instructions
Get directory contents and info
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | No | Directory path | |
| details | No | Show detailed info |
Implementation Reference
- src/index.ts:297-321 (handler)Handler function for the get_directory_info tool. Executes 'ls' command on the specified directory (default current) with optional detailed listing (-lah), formats the output using format_output, and handles errors.async ({ path, details }) => { try { const dir = path || '.'; const cmd = details ? `ls -lah "${dir}"` : `ls -A "${dir}"`; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } },
- src/index.ts:279-292 (schema)Valibot schema defining optional 'path' (string, directory path) and 'details' (boolean, show detailed info) parameters for the get_directory_info tool.schema: v.object({ path: v.optional( v.pipe( v.string(), v.description('Directory path'), ), ), details: v.optional( v.pipe( v.boolean(), v.description('Show detailed info'), ), ), }),
- src/index.ts:275-322 (registration)Registration of the get_directory_info tool on the MCP server, including name, description, input schema, read-only annotation, and handler function reference.this.server.tool( { name: 'get_directory_info', description: 'Get directory contents and info', schema: v.object({ path: v.optional( v.pipe( v.string(), v.description('Directory path'), ), ), details: v.optional( v.pipe( v.boolean(), v.description('Show detailed info'), ), ), }), annotations: { readOnlyHint: true, }, }, async ({ path, details }) => { try { const dir = path || '.'; const cmd = details ? `ls -lah "${dir}"` : `ls -A "${dir}"`; const result = await this.command_executor.execute_command(cmd); return { content: [ { type: 'text' as const, text: this.format_output(result), }, ], }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}`, }, ], isError: true, }; } }, );