Skip to main content
Glama

read

Retrieve file contents from virtual filesystem workspaces using a specified path to access stored data.

Instructions

Read file contents.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • Core implementation of the 'read' tool handler in VFSTools class. Resolves path, reads file from VFS, decodes content, and returns ReadResponse.
    async def read(self, path: str) -> ReadResponse:
        """
        Read file contents.
    
        Args:
            path: File path (absolute or relative to cwd)
    
        Returns:
            ReadResponse with file contents
        """
        vfs = self.workspace_manager.get_current_vfs()
        resolved_path = self.workspace_manager.resolve_path(path)
    
        content = await vfs.read_file(resolved_path)
        if content is None:
            raise ValueError(f"Could not read file: {resolved_path}")
    
        content_str = content.decode("utf-8") if isinstance(content, bytes) else content
    
        return ReadResponse(
            path=resolved_path, content=content_str, size=len(content_str.encode())
        )
  • MCP server tool registration for 'read', delegating to VFSTools.read method.
    @server.tool
    async def read(path: str):
        """Read file contents."""
        return await vfs_tools.read(path)
  • Pydantic model defining the output schema for the 'read' tool response.
    class ReadResponse(BaseModel):
        """Response from read operation"""
    
        path: str
        content: str
        size: int

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/chrishayuk/chuk-mcp-vfs'

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