Skip to main content
Glama

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
NameRequiredDescriptionDefault
pathNoDirectory path
detailsNoShow detailed info

Implementation Reference

  • 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, }; } },
  • 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, }; } }, );

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/spences10/mcp-wsl-exec'

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