Skip to main content
Glama
Ronnietag
by Ronnietag

file_write

Write content to files on Linux systems by specifying absolute paths and file content for file management operations.

Instructions

Write content to a file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesAbsolute path
contentYesFile content

Implementation Reference

  • Actual logic implementation for file writing.
    def execute_file_write(path: str, content: str) -> str:
        """Write content to a file."""
        try:
            resolved = Path(path).resolve()
            resolved.parent.mkdir(parents=True, exist_ok=True)
            resolved.write_text(content)
            return f"Written: {path}"
        except Exception as e:
            return f"Error writing to {path}: {e}"
  • MCP handler function that bridges the protocol request to the implementation logic.
    async def handle_file_write(arguments: dict[str, Any]) -> list[TextContent]:
        """Handle file_write tool calls (ELEVATED)."""
        if not arguments or "path" not in arguments or "content" not in arguments:
            return [TextContent(type="text", text="Error: missing parameters")]
    
        result = execute_file_write(arguments["path"], arguments["content"])
        return [TextContent(type="text", text=result)]
  • Tool registration including schema definition for parameters.
    register_tool(
        name="file_write",
        scope=PermissionLevel.ELEVATED,
        description="Write content to a file",
        params_schema={
            "type": "object",
            "properties": {
                "path": {"type": "string", "description": "Absolute path"},
                "content": {"type": "string", "description": "File content"},
            },
            "required": ["path", "content"],
        },
  • Registration mapping of tool name to its handler function.
    TOOL_HANDLERS = {
        "file_read": handle_file_read,
        "file_list": handle_file_list,
        "app_launch": handle_app_launch,
        "file_write": handle_file_write,

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/Ronnietag/linux-mcp'

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