Skip to main content
Glama

write_file

Update existing files by writing new content that replaces the old version. Read the file first, then modify and save; for new files, use create_file instead.

Instructions

WRITE OR UPDATE content to existing file, completely replacing current content. Workflow: read file first, modify content, then write back. For new files use 'create_file'. Keywords: write, update, modify, save, edit file, change file. / 写入或更新现有文件内容,完全替换当前内容。工作流程:先读取文件,修改内容,然后写回。新文件请使用 'create_file'。关键词:写入、更新、修改、保存、编辑文件。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe file path to write to. The file should already exist (use 'create_file' for new files). Can be absolute or relative path. Examples: 'src/main.go' (update source code), 'config.yaml' (update configuration), 'index.html' (update web page).
contentYesThe new content to write to the file. This will completely replace the existing content. Make sure to include all content you want to keep, as the old content will be lost.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageYes
successYes
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 transparently states that writing completely replaces the existing content and that the file must already exist (via the path parameter description). This discloses the destructive nature of the operation. However, it doesn't mention what happens if the file does not exist, permissions required, or whether changes are atomic, but for a simple file write, this is adequate.

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?

The description is front-loaded with the key action, but includes redundant elements: the Chinese translation duplicates the English content, and the keyword list repeats information already in the description and schema. While structured logically (action, workflow, distinction), it could be more concise by removing the bilingual duplication and excessive keywords. It earns a 3 for being somewhat verbose but still organized.

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?

The tool is simple (2 params) and has a rich output schema, so the description need not cover return values. It covers the core aspects: what it does, the destructive replacement, the required existence of the file, and the recommended workflow. For a write tool, this is quite complete, though it could mention error cases (e.g., file not found) for extra clarity. Overall, it's contextually complete for the complexity.

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?

The schema description coverage is 100% and both parameters (path and content) have detailed descriptions with examples. The tool description adds little beyond the schema for parameter semantics; it repeats the replacement behavior but doesn't add new parameter-specific meaning. The baseline of 3 is appropriate since schema carries the load.

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 action ('WRITE OR UPDATE content to existing file') with the specific effect of completely replacing current content. It explicitly distinguishes itself from 'create_file' for new files, and the verb 'write' is specific to the resource. This makes the purpose unambiguous and differentiates it from sibling tools like read_file and create_file.

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 usage guidance: it tells the agent to read the file first, modify content, then write back, and directly instructs to use 'create_file' for new files. This clearly indicates when to use this tool versus the alternative. The keyword list also reinforces the intended use cases (update, modify, save, edit).

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/shibingli/mcp-toolkit'

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