Skip to main content
Glama
Preston-Harrison

Filesystem MCP Server

read_multiple_files

Read multiple UTF-8 text files simultaneously and return their contents as a path-to-content mapping. This tool enables batch file reading operations within allowed directory boundaries.

Instructions

Read multiple UTF-8 text files at once and return a mapping of paths to contents.

Args: paths (List[str]): List of file paths to read (absolute or relative to allowed directories)

Returns: Dict[str, str] | str: Dictionary mapping absolute file paths to their contents, or error message if any file fails

Note: - All paths must be within allowed directory roots - All files must be UTF-8 text files - If any file fails to read, entire operation returns error string - Returns dictionary for successful reads, string for errors

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathsYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • main.py:433-459 (handler)
    The handler function for the 'read_multiple_files' MCP tool. It reads the contents of multiple specified UTF-8 text files within allowed directories, returning a dictionary mapping absolute paths to file contents or an error string if any issue occurs. Registered via @mcp.tool decorator.
    @mcp.tool
    def read_multiple_files(paths: List[str]) -> Dict[str, str] | str:
        """Read multiple UTF-8 text files at once and return a mapping of paths to contents.
    
        Args:
            paths (List[str]): List of file paths to read (absolute or relative to allowed directories)
    
        Returns:
            Dict[str, str] | str: Dictionary mapping absolute file paths to their contents, or error message if any file fails
    
        Note:
            - All paths must be within allowed directory roots
            - All files must be UTF-8 text files
            - If any file fails to read, entire operation returns error string
            - Returns dictionary for successful reads, string for errors
        """
        result: Dict[str, str] = {}
        try:
            for p in paths:
                rp = _resolve(p)
                if not _is_text(rp):
                    return f"Error reading multiple files: '{rp}' is not a UTF-8 text file or is binary"
                result[str(rp)] = rp.read_text(encoding="utf-8")
            return result
        except Exception as e:
            return _human_error(e, "reading multiple files")
Behavior5/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 effectively describes key traits: the operation reads files (implying read-only, non-destructive), specifies constraints (UTF-8 text, allowed directories), and details error handling ('If any file fails to read, entire operation returns error string'). This covers safety, limitations, and failure modes adequately for a tool with no annotations.

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 well-structured and front-loaded with the core purpose in the first sentence. Each subsequent section (Args, Returns, Note) adds value without redundancy. The bullet points in the Note section are efficient and clear, making the text easy to parse with zero wasted sentences.

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

Completeness5/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 (batch file reading with constraints), no annotations, and an output schema present (which handles return values), the description is complete. It covers purpose, parameters, returns, and behavioral notes like constraints and error handling, leaving no significant gaps for an AI agent to understand and invoke the tool correctly.

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

Parameters5/5

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

The schema description coverage is 0%, so the description must fully compensate. It adds significant meaning beyond the basic schema: it explains that 'paths' is a list of file paths, clarifies they can be 'absolute or relative to allowed directories', and ties this to the tool's constraints. This provides essential context not present in the schema, fully compensating for the lack of schema descriptions.

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 specific action ('Read multiple UTF-8 text files at once') and the resource ('text files'), distinguishing it from sibling tools like 'read_text_file' (singular) and 'search_files' (searching rather than reading). It explicitly describes the output format ('mapping of paths to contents'), making the purpose unambiguous and distinct from alternatives.

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 for when to use this tool (reading multiple text files simultaneously) and includes constraints like 'All paths must be within allowed directory roots' and 'All files must be UTF-8 text files'. However, it does not explicitly state when to use this versus alternatives like 'read_text_file' for single files or 'grep' for searching content, missing 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/Preston-Harrison/fs-mcp-py'

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