Skip to main content
Glama
GeminiDesk MCP
by LZ7TOP

Write or Create File

fs_write_file

Create a new file or overwrite/append existing file content, with optional encoding, permissions, and automatic parent directory creation.

Instructions

创建新文件,或覆盖/追加修改已有文件内容。

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "path": "<path>",
      "content": "<content>"
    },
    "name": "fs_write_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNo可选文件权限(八进制字符串,如 "644" 或 "755")
pathYes目标文件路径
appendNo是否追加到文件末尾(默认覆盖)
contentYes写入的文件内容
encodingNo内容编码utf8
createDirsNo父目录不存在时是否自动创建

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.2.0

TDQS

B3.2/5.0
Behavior2/5

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

No annotations are supplied, so the description carries the full behavioral burden. It does disclose the most important trait, that existing content is overwritten by default unless appending, but it says nothing about irreversibility, permission or encoding implications, failure behavior, or what happens when the parent directory is missing — all of which are real concerns for a write tool.

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?

A single compact sentence with the destructive overwrite behavior front-loaded alongside the create case. Nothing is wasted, though the brevity leaves little room for routing information.

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

Completeness3/5

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

For a six-parameter mutation tool with no annotations and no output schema, the description covers the core operation but not the risk profile or return expectations. The rich schema compensates for parameter detail, yet the agent still lacks guidance on side effects and sibling selection.

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 description coverage is 100%, so all six parameters including mode, encoding, and createDirs are already documented in the schema. The description's overwrite/append language mirrors the 'append' parameter without adding syntax or format detail, so the baseline of 3 applies.

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

Purpose4/5

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

The description names a specific verb and resource ('创建新文件', '覆盖/追加修改已有文件内容'), so an agent immediately knows this performs whole-file writes. It does not differentiate itself from close siblings such as fs_edit_file, fs_patch_lines, or fs_multi_edit, which also mutate file content, so the agent must infer the boundary.

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

Usage Guidelines3/5

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

Usage is only implied: the create/overwrite/append framing suggests this is for supplying full file content rather than targeted edits, which indirectly points away from the edit-family siblings. There is no explicit statement of when to prefer this over fs_edit_file or fs_patch_lines, and no prerequisites are mentioned.

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