Skip to main content
Glama
Ronnietag
by Ronnietag

file_read

Read file contents to access text, code, or data stored in Linux systems. Specify the absolute file path to retrieve information for analysis or processing.

Instructions

Read contents of a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path to file

Implementation Reference

  • The core implementation of the file_read tool logic, including security checks for path traversal.
    def execute_file_read(path: str) -> str:
        """Read a file and return its contents."""
        tool = get_tool_by_name("file_read")
        tool_id = next(tid for tid, t in {}.items() if t.name == "file_read")  # placeholder
    
        # Security: path traversal check
        resolved = Path(path).resolve()
        if not str(resolved).startswith(os.path.expanduser("~")):
            log_action(tool_id or "unknown", {"path": path}, "BLOCKED: outside home", False)
            return "Error: Can only read files within home directory"
    
        try:
            content = resolved.read_text()
            log_action(tool_id or "unknown", {"path": path}, "OK", True)
            return content
  • The MCP handler function that processes tool calls and invokes the execute_file_read helper.
    async def handle_file_read(arguments: dict[str, Any]) -> list[TextContent]:
        """Handle file_read tool calls."""
        if not arguments or "path" not in arguments:
            return [TextContent(type="text", text="Error: missing 'path' parameter")]
    
        result = execute_file_read(arguments["path"])
        return [TextContent(type="text", text=result)]
  • Tool registration including schema definitions for file_read.
    register_tool(
        name="file_read",
        scope=PermissionLevel.SAFE,
        description="Read contents of a file",
        params_schema={
            "type": "object",
            "properties": {
                "path": {"type": "string", "description": "Absolute path to file"},
            },
            "required": ["path"],
        },
    )
Behavior2/5

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

No annotations provided, so description carries full burden. 'Read contents' implies a safe read operation but discloses nothing about encoding handling, binary vs. text modes, size limits, file locking, or error behaviors (404, permission denied).

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?

Extremely concise at 4 words. Front-loaded with action first. No filler or redundant text. Every word earns its place despite minimal information content.

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

Completeness3/5

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

Given single parameter with 100% schema coverage, description is minimally adequate for invocation. However, lacks critical context due to missing output schema: does not indicate return format (string, bytes, object) or content size limitations, which are essential for a read operation tool.

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?

Schema has 100% description coverage ('Absolute path to file'), so baseline is 3. The description adds no additional parameter semantics beyond what the schema already provides.

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

Purpose4/5

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

States specific verb 'Read' and resource 'contents of a file', making the basic purpose clear. However, it does not differentiate from sibling clipboard_read (both read) or file_list (both file operations), though the distinction is inferable from the tool names.

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

Usage Guidelines2/5

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

Provides no guidance on when to use this vs. file_list (directory listing vs. content reading), vs. clipboard_read, or error conditions (permissions, missing files). No prerequisites or alternatives mentioned.

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/Ronnietag/linux-mcp'

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