read
Retrieve file contents from virtual filesystem workspaces. Specify a file path to access stored data across multiple storage providers.
Instructions
Read file contents.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Implementation Reference
- src/chuk_mcp_vfs/vfs_tools.py:46-67 (handler)Core handler function that executes the read tool logic: 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()) )
- src/chuk_mcp_vfs/models.py:130-136 (schema)Pydantic model defining the output schema for the read tool.class ReadResponse(BaseModel): """Response from read operation""" path: str content: str size: int
- src/chuk_mcp_vfs/server.py:87-90 (registration)MCP server registration of the 'read' tool using @server.tool decorator, delegating to VFSTools.read method.@server.tool async def read(path: str): """Read file contents.""" return await vfs_tools.read(path)