Skip to main content
Glama

Create or update a file

create_or_update_file
Destructive

Creates a repository file or replaces its full UTF-8 content in one commit; pass the current SHA to safely update an existing file, or omit it to create a new one.

Instructions

Create a file, or replace one's content, as a single commit (owner/repo/path/content; requires write mode). content is the whole file as UTF-8 text. To update, pass the file's current sha from get_file_contents; without sha the file is created, and the forge refuses if it already exists. A stale sha is refused too, so a change made meanwhile is not overwritten. Commits to branch (default: the default branch), or to new_branch created from it — the way to prepare a pull request. Answers with the file's new sha and the commit.

Input Schema

NameRequiredDescriptionDefault
shaNoTo update an existing file: its current blob SHA, from `get_file_contents`. Omit it to create a new file. A stale SHA is refused, so a change made meanwhile is not overwritten.
pathYesFile path from the repository root, e.g. `docs/setup.md`.
repoYesRepository name.
ownerYesRepository owner.
branchNoBranch to commit to. Defaults to the repository's default branch.
contentYesThe whole new content, as UTF-8 text.
messageNoCommit message. The forge composes one when absent.
new_branchNoCreate this branch from `branch` and commit there instead — the way to propose a change as a pull request.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.26.0

TDQS

A4.9/5.0
Behavior5/5

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

The description adds substantial context beyond the annotations: write-mode requirement, single-commit behavior, stale-sha refusal to avoid overwriting concurrent changes, branch versus new_branch commit behavior, and the return payload of new sha and commit.

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 core operation and its create/update distinction are front-loaded, followed by the relevant safety and branch workflow details. The paragraph is dense but every sentence contributes to correct invocation.

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?

Given a mutation tool with no output schema, the description covers the important behavioral details, safety constraints, branch workflow, and return values. Nothing critical for an agent to call it correctly appears missing.

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

Parameters4/5

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

Schema coverage is 100%, so the schema already documents all parameters. The description still adds useful synthesis by explaining the sha create/update distinction, the whole-file UTF-8 content expectation, branch defaults, and the PR-oriented purpose of new_branch.

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 states a specific action and resource: create a file or replace its content as a single commit. It clearly distinguishes the create-vs-update behavior via the sha parameter and names get_file_contents as the source for that sha.

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?

It explicitly explains when the tool creates versus updates, requires write mode, warns that missing sha creates and stale sha is refused, and describes branch/new_branch usage for direct commits or pull request preparation. The alternative source for sha is named.

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