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,
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations provided, so description carries full disclosure burden. 'Write' implies mutation but fails to specify destructive traits: overwrite behavior, directory auto-creation, encoding, or atomicity. Critical gaps for a file mutation tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Single sentence of four words is front-loaded and efficient, but borders on under-specification given the tool's destructive potential and lack of annotations. Appropriately concise structure, yet insufficiently sized for the complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Mutation tool with no annotations, no output schema, and undocumented behavioral edge cases (existing files, permissions). Description inadequate for safe agent operation; missing safety-critical context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% with clear descriptions ('Absolute path', 'File content'). Description adds no semantic detail beyond schema baseline, but schema adequately covers both required parameters.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

States the verb (write) and resource (file) but provides minimal elaboration beyond the tool name 'file_write'. Does not differentiate from sibling 'file_read' or clarify write semantics (create vs overwrite).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Contains no guidance on when to use this tool versus siblings like 'file_read', or prerequisites like directory existence. No mention of overwrite behavior or error conditions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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