Skip to main content
Glama

write_file

DestructiveIdempotent

Save files with encoding conversion from UTF-8, preserving original encoding, BOM, and line endings. Use after read_text_file for non-UTF-8 content.

Instructions

Write file with encoding conversion from UTF-8. PREFER THIS over built-in Write for non-UTF-8 files. Use after read_text_file to keep the original encoding. Parameters: path, content, encoding (default: the existing file's detected encoding, else utf-8), bom, lineEndings. bom: "auto" (default) writes a BOM for utf-16-* targets, else keeps one only if the file already had a BOM of the same encoding; "preserve" keeps it even when the encoding changed; "never" strips it; "always" fails on encodings with no BOM (e.g. cp1251). lineEndings: "preserve" (default) converts content to the file's existing style, so sending LF into a CRLF file will NOT leave it mixed; also "crlf", "lf", "asis" (byte for byte). Example — strip a UTF-8 BOM that breaks PHP: {"path": "D:\www\index.php", "content": "<?php ...", "bom": "never"}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bomNo
pathYes
contentYes
encodingNo
lineEndingsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
hasBomYes
bomTypeNo
messageYes
lineEndingsNo
Behavior5/5

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

Although annotations already indicate destructiveHint=true and idempotentHint=true, the description adds substantial behavioral context: encoding default behavior, BOM modes ('auto', 'preserve', 'never', 'always') with failure cases, and lineEndings 'preserve' ensuring LF does not mix into CRLF files. These details enrich the annotation hints without contradiction.

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

Conciseness4/5

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

The description is dense but not bloated; every clause adds value. It could be more structured with bullets, but the linear narrative with the example is effective and front-loaded with the primary purpose.

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

Completeness5/5

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

The tool has five parameters, no enum constraints, and an output schema, so the description need not cover return values. It covers all parameter semantics, behavioral subtleties, and provides a practical example. No critical gaps remain.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must explain all parameters. It does so exhaustively: path and content are straightforward, encoding has a default, bom has four modes with behavior, lineEndings has four modes. A concrete PHP BOM-stripping example further clarifies usage.

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 opens with 'Write file with encoding conversion from UTF-8', a specific verb+resource statement. It further distinguishes the tool from alternatives by saying 'PREFER THIS over built-in Write for non-UTF-8 files', making its purpose clear and unique.

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

Usage Guidelines4/5

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

The description gives explicit guidance: 'PREFER THIS over built-in Write for non-UTF-8 files' and 'Use after read_text_file to keep the original encoding'. It names alternatives (built-in Write, read_text_file) and provides a workflow context, though it does not explicitly contrast with sibling tools like edit_file or convert_encoding.

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/dimitar-grigorov/mcp-file-tools'

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