Skip to main content
Glama

Get directory contents and info

get_directory_info
Read-only

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,
    			};
    		}
    	},
    );
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description adds no behavioral information beyond what the readOnlyHint annotation already provides. While the annotation correctly indicates this is a read-only operation, the description doesn't disclose any additional behavioral traits such as what happens with invalid paths, whether it follows symlinks, what format the output takes, or any rate limits. With annotations covering the safety profile, this meets the baseline but adds minimal value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at just four words with no wasted language. While this conciseness comes at the expense of completeness, every word directly relates to the tool's function. The structure is front-loaded with the core purpose, though there's no additional information to structure beyond this basic statement.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has readOnlyHint annotation but no output schema, the description should provide more context about what information is returned. The description doesn't explain what 'contents and info' includes, whether it returns file lists, metadata, permissions, or other directory attributes. For a tool with two parameters and no output schema, this leaves significant gaps in understanding what the tool actually produces.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the input schema already fully documents both parameters (path and details). The description adds no additional meaning about what 'directory contents and info' specifically entails, how the boolean 'details' parameter affects the output, or what constitutes a valid path format. The baseline score of 3 reflects adequate schema coverage without description enhancement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Tautological: description restates name/title.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_disk_usage' and 'get_system_info' that might overlap in system information retrieval, there's no indication of when directory-specific information is needed, what prerequisites exist, or when other tools might be more appropriate. This leaves the agent without context for tool selection.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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