Skip to content
Documentation

Reference

ctx_edit

Input contract and parameters for ctx_edit.

Status by featureReviewed September 2026

MCP tool · Read, search & shell

Call this tool through your MCP client. Its availability depends on your active configuration and profile.

This registry contract is separate from the SDK. For terminal commands, use the CLI reference.

Parameters

Generated from the registered input schema. “Required” reflects the schema; individual actions can impose additional requirements.

createboolean

Create file

Schema default: false

new_stringstringRequired

Replacement text

old_stringstring

Text to replace (unique unless replace_all=true)

pathstringRequired

File path to edit

replace_allboolean

Replace all occurrences (default false)

Schema default: false

Exact JSON schema

Inspect the complete input schema
{
  "properties": {
    "create": {
      "default": false,
      "description": "Create file",
      "type": "boolean"
    },
    "new_string": {
      "description": "Replacement text",
      "type": "string"
    },
    "old_string": {
      "description": "Text to replace (unique unless replace_all=true)",
      "type": "string"
    },
    "path": {
      "description": "File path to edit",
      "type": "string"
    },
    "replace_all": {
      "default": false,
      "description": "Replace all occurrences (default false)",
      "type": "boolean"
    }
  },
  "required": [
    "path",
    "new_string"
  ],
  "type": "object"
}

Runtime description

The following is the tool's own agent-facing description, reproduced from the reviewed registry. It can contain implementation terminology; it does not expand the public stability commitment.

Read the agent-facing description
Search-and-replace edit with race-condition guards — for simple text replacement in a single file.
For editing code you've read, prefer ctx_patch (hash-anchored): it never makes you reproduce old text byte-for-byte. Read with ctx_read(mode="anchored") first.
old_string must be unique unless replace_all=true. create=true writes new files.
backup creates .bak. MD5/size/mtime pre-guards prevent race conditions.
ANTIPATTERN: Do NOT loop on failures — switch to ctx_patch (anchored), or verify file content and adjust old_string.
For LSP-aware refactoring (rename, move, inline), use ctx_refactor.
Sources & versions3 references Reviewed
  • mcp_manifest.rsrust/src/core/mcp_manifest.rsReviewed checkout
  • registry.rsrust/src/server/registry.rsReviewed checkout
  • dynamic_tools.rsrust/src/server/dynamic_tools.rsReviewed checkout
Core checkout
50fbff09c9
Installed runtime
3.10.2
SDK release
1.1.0

Separate baselines for source, CLI/configuration and SDK contracts. Review does not certify every platform or integration.

Versions & compatibility