Skip to main content
Glama
StrawHatAI

Claude Desktop Commander MCP

by StrawHatAI

write_file

Replace entire file contents for major edits or when incremental changes fail, overwriting existing files within permitted directories.

Instructions

Completely replace file contents. Best for large changes (>20% of file) or when edit_block fails. Use with caution as it will overwrite existing files. Only works within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
contentYes

Implementation Reference

  • Core handler function that validates the file path and writes the provided content to the file using Node.js fs.promises.writeFile.
    export async function writeFile(filePath: string, content: string): Promise<void> {
        const validPath = await validatePath(filePath);
        await fs.writeFile(validPath, content, "utf-8");
    }
  • Zod schema defining the input arguments for the write_file tool: path (string) and content (string).
    export const WriteFileArgsSchema = z.object({
      path: z.string(),
      content: z.string(),
    });
  • src/server.ts:142-148 (registration)
    Tool registration in the MCP server's ListTools response, including name, description, and input schema.
    {
      name: "write_file",
      description:
        "Completely replace file contents. Best for large changes (>20% of file) or when edit_block fails. " +
        "Use with caution as it will overwrite existing files. Only works within allowed directories.",
      inputSchema: zodToJsonSchema(WriteFileArgsSchema),
    },
  • Dispatch handler in the MCP server's CallToolRequest handler that parses arguments, calls the writeFile function, and returns success response.
    case "write_file": {
      const parsed = WriteFileArgsSchema.parse(args);
      await writeFile(parsed.path, parsed.content);
      return {
        content: [{ type: "text", text: `Successfully wrote to ${parsed.path}` }],
      };
    }
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively communicates key behavioral traits: the destructive nature ('will overwrite existing files'), caution needed, and directory restrictions. However, it doesn't mention error conditions, response format, or performance characteristics that would be helpful for an agent.

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

Conciseness5/5

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

The description is efficiently structured with three sentences that each serve a distinct purpose: stating the core operation, providing usage guidelines, and specifying constraints. There's no wasted language, and the most critical information (the destructive nature) is front-loaded appropriately.

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

Completeness4/5

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

For a destructive file operation tool with no annotations and no output schema, the description does a good job covering the essential context: the overwrite behavior, usage scenarios, and directory restrictions. However, it doesn't mention what happens on success/failure or what the tool returns, which would be valuable for an agent invoking it.

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?

With 0% schema description coverage, the description doesn't provide any parameter-specific information beyond what's implied by the tool name. While it mentions 'path' and 'content' indirectly through context, it doesn't explain format requirements, constraints, or examples for either parameter. The baseline is 3 since the schema covers the parameters structurally.

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

Purpose5/5

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

The description clearly states the tool's purpose with specific verbs ('Completely replace file contents') and distinguishes it from sibling tools ('when edit_block fails'). It explicitly identifies the resource (files) and the operation (overwrite/replace), making it easy to understand what this tool does differently from other file-related tools.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('Best for large changes (>20% of file) or when edit_block fails') and when to use alternatives (edit_block). It also includes cautionary advice ('Use with caution') and constraints ('Only works within allowed directories'), giving clear context for appropriate usage.

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/StrawHatAI/claude-dev-tools'

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