Skip to main content
Glama

write_symbol

Safely modify one code symbol at a time: replace, patch, or insert after a function/method/class, using a base version from read_symbol to avoid write conflicts.

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)
locatorYes
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.

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