Skip to main content
Glama

Write service file

write_service_file
Destructive

Writes a small file (up to 1 MiB) to a VPS with compare-and-swap safety, replacing content only when the expected version or SHA-256 matches, or creating a new file that must not already exist.

Instructions

Write a small file (at most 1 MiB) with compare-and-swap. Pass the content as text (UTF-8) or contentBase64, and exactly one precondition: expectedVersion or expectedSha256 from stat_service_file/read_service_file to replace an existing file, or createOnly=true for a new one. A file changed meanwhile answers 409 filesVersionConflict (+currentVersion) and is not touched; re-read it instead of forcing. A replaced file keeps its owner, mode, SELinux label and ACL. Use upload_service_file for larger files. A slow guest answers 202 with an operation: this tool polls it itself and returns the final answer, or, after waitSeconds, the operationId to continue with get_service_file_operation (never repeat the call). Requires files:manage on a FULL-access API key as an explicit grant; the hosted connector needs vm:files:write. Execution-equivalent targets (authorized_keys, cron, systemd units, sudoers, PAM, profile files) are refused to every API key (filesExecEquivalentScopeMissing). Availability: Firecracker servers need the updated guest agent (filesUnavailable reason agent_update_required; node_update_required while the host node is not updated yet) and Cloud VPS (KVM) servers need the VDS file-manager switch (reason feature_disabled while it is off); relay any unavailable reason verbatim and never work around it. A server whose 2FA lock is on answers 423.

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": {
      "orderNo": "<orderNo>",
      "path": "<path>"
    },
    "name": "write_service_file"
  }
}

Input Schema

NameRequiredDescriptionDefault
modeNoOctal permission bits for a NEW file, e.g. 0644
pathYesAbsolute path inside the server (UTF-8, at most 4096 bytes, no . or .. components)
contentNoNew content as UTF-8 text
orderNoYesTenant-owned service order number, e.g. VP12345
createOnlyNo
waitSecondsNoHow long this tool waits for a slow guest's operation before returning its operationId (default 30, recursive delete and extract 60)
contentBase64NoNew content as base64 (binary)
expectedSha256No
expectedVersionNo
confirmSystemPathNoSet true only after the user explicitly approved changing this operating-system path (otherwise 409 filesSystemPathConfirmRequired)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv2.3.17

TDQS

A4.9/5.0
Behavior5/5

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

Annotations declare a non-idempotent destructive write; the description adds substantial context beyond that: CAS conflict returns 409 filesVersionConflict with currentVersion and leaves the file untouched, metadata (owner, mode, SELinux label, ACL) survives replacement, and 202 polling is handled internally unless waitSeconds expires. It also discloses authorization requirements (files:manage on a FULL-access key, vm:files:write on the hosted connector), hard refusals for exec-equivalent targets, availability gates with reason codes to relay verbatim, and 423 under 2FA lock.

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?

Purpose and size cap are front-loaded, and each sentence carries operational payload rather than filler. It is a dense single paragraph for a 10-parameter destructive tool, so the error, permission, and availability clauses run together; light grouping would improve scanability without shortening it.

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?

For a destructive, availability-gated mutation with no output schema, the description covers the full lifecycle an agent needs: preconditions, conflict handling, async 202 behavior and continuation, permission grants, refused path classes, and feature-availability failure modes. Nothing material required to call it correctly is missing.

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 coverage is 70%, but the description supplies a constraint the schema cannot express: exactly one precondition (expectedVersion, expectedSha256, or createOnly=true) must be passed, and the expected* values must originate from stat_service_file/read_service_file. It also clarifies content vs contentBase64 as alternative encodings and that mode applies only to a NEW file.

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?

Opens with a specific verb+resource and scope: 'Write a small file (at most 1 MiB) with compare-and-swap.' It immediately distinguishes itself from the sibling upload_service_file ('Use upload_service_file for larger files'), so an agent can route between write and upload without opening either schema.

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?

Explicitly states when to use it (small files, CAS replacement or createOnly creation) and when not to (larger files go to upload_service_file; slow-guest continuations go to get_service_file_operation), including the prohibition 'never repeat the call'. It also gives the correct recovery path on 409 ('re-read it instead of forcing') rather than leaving the agent to improvise.

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

Deploy Server

Other Tools