read
Retrieve file contents from virtual filesystem workspaces using a specified path to access stored data.
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 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()) )
- src/chuk_mcp_vfs/server.py:87-91 (registration)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)
- src/chuk_mcp_vfs/models.py:130-136 (schema)Pydantic model defining the output schema for the 'read' tool response.class ReadResponse(BaseModel): """Response from read operation""" path: str content: str size: int