Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

read_file

Retrieve file contents from your computer's file system. This tool reads text files within permitted directories and handles various encodings while providing clear error feedback.

Instructions

Read the complete contents of a file from the file system. Handles various text encodings and provides detailed error messages if the file cannot be read. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Handler for the read_file tool in the main server request handler. Parses args using the schema, calls the readFile helper, and returns the file content.
    case "read_file": {
      const parsed = ReadFileArgsSchema.parse(args);
      const content = await readFile(parsed.path);
      return {
        content: [{ type: "text", text: content }],
      };
    }
  • Zod schema defining the input for read_file tool: requires a 'path' string.
    export const ReadFileArgsSchema = z.object({
      path: z.string(),
    });
  • src/server.ts:126-132 (registration)
    Registration of the read_file tool in the ListToolsRequestHandler, including name, description, and input schema reference.
      name: "read_file",
      description:
        "Read the complete contents of a file from the file system. " +
        "Handles various text encodings and provides detailed error messages " +
        "if the file cannot be read. Only works within allowed directories.",
      inputSchema: zodToJsonSchema(ReadFileArgsSchema),
    },
  • Core implementation of file reading: validates the path for security and reads the file content using fs.readFile.
    export async function readFile(filePath: string): Promise<string> {
        const validPath = await validatePath(filePath);
        return fs.readFile(validPath, "utf-8");
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context beyond basic functionality: it handles various text encodings, provides detailed error messages, and has directory restrictions. This covers key behavioral traits like error handling and operational limits, though it could mention performance aspects like file size limits.

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 front-loaded with the core purpose in the first sentence, followed by additional behavioral details. Each sentence adds value: the first defines the action, the second covers encoding and errors, and the third states directory restrictions. There is no wasted text, making it efficient and well-structured.

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

Completeness4/5

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

Given the tool's moderate complexity (single parameter, no output schema, no annotations), the description is mostly complete. It covers purpose, behavioral traits, and usage constraints. However, without an output schema, it does not describe return values (e.g., file content format), leaving a minor gap in completeness for the agent.

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

Parameters4/5

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

The input schema has 1 parameter with 0% description coverage, so the description must compensate. It implies the 'path' parameter is for specifying the file to read, but does not detail format or examples. The description adds meaning by contextualizing the parameter's role in file reading, though more specifics on path syntax would enhance clarity.

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

Purpose5/5

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

The description clearly states the verb ('Read') and resource ('complete contents of a file from the file system'), distinguishing it from siblings like 'get_file_info' (metadata) and 'read_multiple_files' (batch operation). It specifies the scope of reading the complete contents, making the purpose explicit and differentiated.

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

Usage Guidelines4/5

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

The description provides clear context with 'Only works within allowed directories,' indicating a usage constraint. However, it does not explicitly mention when to use this tool versus alternatives like 'read_multiple_files' for batch operations or 'get_file_info' for metadata, so it lacks explicit sibling differentiation.

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/StrawHatAI/claude-dev-tools'

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