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
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Absolute path | |
| content | Yes | File content |
Implementation Reference
- src/linux_mcp/tools/__init__.py:218-226 (handler)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}" - src/linux_mcp/mcp/__init__.py:78-84 (handler)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"], }, - src/linux_mcp/mcp/__init__.py:106-110 (registration)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,