Skip to main content
Glama

Task Trellis MCP

replace_object_body_regex

Replace specific sections of an object’s body using regex patterns to make precise edits without recreating the entire text. Ensure surgical text modifications with multiline matching, backreferences, and single-match enforcement for safety. Ideal for updating documentation, code snippets, or targeted content.

Instructions

Replaces portions of an object's body using regular expressions

Use this tool to make targeted edits to specific sections of an object's body content without recreating the entire text. This is safer and more efficient than wholesale body replacement for surgical text modifications.

The tool uses regex pattern matching with multiline and global capabilities, similar to Python's re.sub(). When allowMultipleOccurrences is false (default), it prevents unintended bulk replacements by throwing an error if multiple matches are found.

Regex Features:

  • Multiline matching: patterns can span multiple lines
  • Dot-all mode: . matches newlines
  • Backreferences: use \1, \2, etc. in replacement text
  • Case-sensitive matching (use (?i) flag in pattern for case-insensitive)

Common use cases:

  • Update specific sections of documentation
  • Modify code snippets within object descriptions
  • Replace outdated information while preserving structure
  • Update specific parameters or values
  • Fix formatting or content errors in targeted areas

Safety features:

  • Single-match enforcement (unless explicitly allowed)
  • Pattern validation before execution
  • Graceful error handling with detailed messages
  • Original content preservation on pattern mismatch

Example patterns:

  • Simple text: "old text" → "new text"
  • With context: "(section:\s*)old content(\s*end)" → "\1new content\2"
  • Multi-line: "BEGIN.*?END" → "BEGIN\nnew content\nEND"
  • Backreferences: "(\w+) (\w+)" → "\2, \1"

The replacement preserves all object metadata and relationships while only modifying the body content that matches your pattern.

Input Schema

NameRequiredDescriptionDefault
allowMultipleOccurrencesNoAllow replacing multiple pattern matches (defaults to false)
idYesID of the object whose body should be modified
regexYesRegular expression pattern to match content in the body
replacementYesReplacement text (may contain backreferences like \1, \2, etc.)

Input Schema (JSON Schema)

{ "properties": { "allowMultipleOccurrences": { "default": false, "description": "Allow replacing multiple pattern matches (defaults to false)", "type": "boolean" }, "id": { "description": "ID of the object whose body should be modified", "type": "string" }, "regex": { "description": "Regular expression pattern to match content in the body", "type": "string" }, "replacement": { "description": "Replacement text (may contain backreferences like \\1, \\2, etc.)", "type": "string" } }, "required": [ "id", "regex", "replacement" ], "type": "object" }

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/langadventurellc/task-trellis-mcp'

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