Skip to main content
Glama

write

Write content to files in virtual filesystem workspaces. Use this tool to save text data to files across multiple storage providers with session, user, or shared scope access.

Instructions

Write content to file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
requestYes

Implementation Reference

  • VFSTools.write: the core handler implementing file write logic, resolving path, creating parents, encoding content, and writing to VFS.
    async def write(self, request: WriteRequest) -> WriteResponse: """ Write content to file. Args: request: WriteRequest with path and content Returns: WriteResponse with success status """ from pathlib import PurePosixPath vfs = self.workspace_manager.get_current_vfs() resolved_path = self.workspace_manager.resolve_path(request.path) # Ensure all parent directories exist # Use PurePosixPath to ensure forward slashes on all platforms parent = str(PurePosixPath(resolved_path).parent) if parent != "/": # Create all parent directories if they don't exist parts = [p for p in parent.split("/") if p] current_path = "" for part in parts: current_path += f"/{part}" if not await vfs.exists(current_path): await vfs.mkdir(current_path) content_bytes = request.content.encode("utf-8") await vfs.write_file(resolved_path, content_bytes) return WriteResponse(success=True, path=resolved_path, size=len(content_bytes))
  • Pydantic models: WriteRequest (path, content) and WriteResponse (success, path, size).
    class WriteRequest(BaseModel): """Request to write a file""" path: str content: str class WriteResponse(BaseModel): """Response from write operation""" success: bool path: str size: int
  • MCP server tool registration for 'write', delegating to VFSTools instance.
    @server.tool async def write(request: WriteRequest): """Write content to file.""" return await vfs_tools.write(request)
  • Instantiation of VFSTools instance used by all VFS tools including write.
    vfs_tools = VFSTools(workspace_manager) checkpoint_tools_instance = CheckpointTools(checkpoint_manager)

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