Skip to main content
Glama

github_mcp.write_file

Destructive

Creates or replaces a planned file in an editable job workspace, requiring the current SHA-256 checksum for existing files and returning path, checksum, and byte count.

Instructions

Create or replace a planned file in an editable job workspace. For existing files, first read_file with the job ID and supply its checksum; for new files use null. Returns path, SHA-256 checksum and byte count. Invalidates preview and checks; does not commit or push.

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": {
      "job_id": "<job_id>",
      "path": "<path>",
      "content": "<content>"
    },
    "name": "github_mcp.write_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
pathYesPlanned repository-relative file path.
job_idYesExisting editable job identifier.
contentYesComplete replacement content, UTF-8 text or base64 according to encoding.
encodingNoutf-8 (default) or base64; binary writes require trusted policy.utf-8
executableNoOptional executable-bit setting; null preserves existing behavior.
expected_checksumNoCurrent SHA-256 checksum for an existing file; null for a new file.

Output Schema

NameRequiredDescriptionDefault
okYes
dataNo
messageNo
error_codeNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed6 schema fields changedv1.0.2
    • addedInput schema / properties / content / description
      Added value: +"Complete replacement content, UTF-8 text or base64 according to encoding."
    • addedInput schema / properties / encoding / description
      Added value: +"utf-8 (default) or base64; binary writes require trusted policy."
    • addedInput schema / properties / executable / description
      Added value: +"Optional executable-bit setting; null preserves existing behavior."
    • addedInput schema / properties / expected_checksum / description
      Added value: +"Current SHA-256 checksum for an existing file; null for a new file."
    • addedInput schema / properties / job_id / description
      Added value: +"Existing editable job identifier."
    • addedInput schema / properties / path / description
      Added value: +"Planned repository-relative file path."
  2. First observedv1.0.1

TDQS

A4.2/5.0
Behavior4/5

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

Adds real behavior beyond the annotations: the write invalidates preview and checks, it does not commit or push, and it returns path, SHA-256 checksum and byte count. The optimistic-concurrency expectation around the checksum is a meaningful disclosure that destructiveHint alone does not convey; the only omission is explicit mention that prior content is replaced wholesale.

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?

Four short sentences with zero filler, front-loaded with the core action, then the precondition, then the return value, then the side effects. Every clause carries information an agent needs.

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?

Complete enough for a six-parameter mutation tool: an output schema exists so return values need not be detailed, yet the description still summarizes them, and safety profile plus side effects are covered. Minor gap: it does not clarify what makes a job 'editable' or how to reach that state.

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 the schema already documents every parameter, including expected_checksum semantics and encoding. The description only restates the null-for-new-file rule and adds the read_file precondition, which is marginal added meaning — baseline 3 applies.

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?

Names a specific verb and resource ('Create or replace a planned file in an editable job workspace') and bounds the scope with 'does not commit or push', which separates it from commit/publish siblings like create_file_commits and publish_branch. An agent can identify the operation without opening the schema.

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?

Gives a concrete precondition workflow: for existing files, call read_file with the job ID first and supply the resulting checksum; for new files pass null. It stops short of contrasting with apply_patch or delete_file as alternative mutation paths, so it is strong context without full alternative routing.

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