Skip to main content
Glama

write_symbol

Write or replace a code symbol with version-checked, undo-safe updates. Read first for base version, then apply edits with conflict detection for reliable refactors.

Instructions

Guarded write path (one symbol) — vs edit_batch: index-aware with version/lock/undo, for symbol-level refactors. Read first (read_symbol) for base_version. For string params containing double quotes/backslashes, keep JSON escaping consistent across the whole string (escape uniformly or prefer full-width quotes), otherwise client-side parameter parsing fails.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patchNoRequired when edit_mode=patch
safetyNoSafety knobs
contentYesNew content (full symbol or body per boundary)
dry_runNoValidate and produce diff without writing (default false)
locatorYesSymbol anchor: {symbol_id} or {file_path}+{name}. Read first via read_symbol.
boundaryNofull (default): replace whole symbol. body: keep signature line, replace the rest.
edit_modeNoreplace_symbol (default) / patch (sub-symbol old_string→new_string) / insert_after_symbol
base_versionYesREQUIRED: version from read_symbol. Conflict anchor.
workspace_dirYesREQUIRED: project root (abs). reindex first if new.
preserve_decoratorsNoWarn if content drops decorators that exist above the symbol (default true)
allow_unsafe_no_baseNoBypass base_version requirement (audited). Only for deliberate full-file overwrites.

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed1 schema field changedv0.4.5-post9
    • addedInput schema / properties / locator / description
      "Symbol anchor: {symbol_id} or {file_path}+{name}. Read first via read_symbol."
  2. First observed

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations, the description carries the transparency burden. It discloses guarded write semantics, version/lock/undo, base_version requirement, and a client-side JSON escaping pitfall. It doesn't detail permissions or side effects, but adds meaningful behavioral context beyond the schema.

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?

Three focused sentences, each earning its place: purpose/vs-alternative, read-prerequisite, and a critical parameter formatting caveat. No fluff, well front-loaded.

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?

For a complex 11-parameter tool with nested objects and no output schema, the description provides the key mental model, prerequisite, and a critical gotcha. It doesn't explain all edit modes or safety knobs, but those are documented in the schema. Lacks explicit success/failure behavior, though.

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 baseline is 3. The description adds value by explaining the JSON escaping requirement for string parameters and reinforcing that base_version comes from read_symbol, which is not fully obvious from the schema alone.

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 identifies this as a guarded write path for a single symbol with version/lock/undo, and explicitly distinguishes it from edit_batch for symbol-level refactors. The resource (one symbol) and operation type are unambiguous.

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?

It gives a direct comparison to edit_batch, stating this is for symbol-level refactors with index-aware version/lock/undo. It also instructs to read_symbol first for base_version, providing a clear prerequisite. It doesn't enumerate all alternatives but offers key exclusions.

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

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/wulun811/LiuHe'

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