Skip to main content
Glama
Preston-Harrison

Filesystem MCP Server

read_multiple_files

Read and retrieve contents of multiple UTF-8 text files simultaneously, mapping paths to their contents. Ensures all files are within allowed directories and returns an error if any file fails.

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

Implementation Reference

  • main.py:433-459 (handler)
    Handler function for the 'read_multiple_files' MCP tool. Decorated with @mcp.tool, it reads contents from multiple specified text files within allowed directories, returning a dictionary of absolute paths to contents or an error string if any issue occurs.
    @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")

Other Tools

Related 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