Skip to main content
Glama
koopatroopa787

MCP PC Control Server

read_file

Read complete file contents from the file system to examine text before editing. Handles various text encodings and returns full file content.

Instructions

Read the complete contents of a file from the file system. Handles various text encodings and returns the full file content. Use this to examine file contents before editing.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe path to the file to read (absolute or relative)

Implementation Reference

  • The handler function for the 'read_file' tool. It extracts the file path from arguments, reads the file content asynchronously using Node.js fs.promises.readFile, and returns the content wrapped in the MCP ToolResult format with type 'text'.
    case "read_file": {
      const filePath = args.path as string;
      const content = await fs.readFile(filePath, "utf-8");
      return {
        content: [
          {
            type: "text",
            text: content,
          },
        ],
      };
    }
  • The input schema for the 'read_file' tool, defining an object with a required 'path' string property.
    inputSchema: {
      type: "object",
      properties: {
        path: {
          type: "string",
          description: "The path to the file to read (absolute or relative)",
        },
      },
      required: ["path"],
    },
  • src/index.ts:20-33 (registration)
    The Tool object registration for 'read_file' in the TOOLS array, which is returned by the listTools handler. Includes name, description, and inputSchema.
    {
      name: "read_file",
      description: "Read the complete contents of a file from the file system. Handles various text encodings and returns the full file content. Use this to examine file contents before editing.",
      inputSchema: {
        type: "object",
        properties: {
          path: {
            type: "string",
            description: "The path to the file to read (absolute or relative)",
          },
        },
        required: ["path"],
      },
    },
  • src/index.ts:261-263 (registration)
    The server request handler for ListToolsRequestSchema that returns the TOOLS array, effectively registering all tools including 'read_file'.
    server.setRequestHandler(ListToolsRequestSchema, async () => {
      return { tools: TOOLS };
    });
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. It discloses key behavioral traits: it reads complete contents (not partial), handles various text encodings, and returns full file content. However, it doesn't mention error handling (e.g., for missing files or permissions) or 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 context in a second sentence. Both sentences earn their place by providing essential information without redundancy, 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 low complexity (one parameter, no output schema) and no annotations, the description is mostly complete. It covers purpose, usage, and key behaviors. However, it lacks details on error cases or return format specifics, which would be helpful for a read operation.

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?

The input schema has 100% description coverage, with the 'path' parameter well-documented in the schema. The description doesn't add any meaningful parameter semantics beyond what the schema provides (e.g., it doesn't clarify path resolution or encoding specifics), so it meets the baseline for high schema coverage.

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 tool's purpose with a specific verb ('Read') and resource ('complete contents of a file from the file system'). It distinguishes from siblings like get_file_info (metadata) and edit_file/write_file (modification) by focusing on content retrieval.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('to examine file contents before editing'), which differentiates it from edit_file (for modifications) and get_file_info (for metadata). It also implies when not to use it (e.g., for file operations like moving or deleting).

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/koopatroopa787/first_mcp'

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