Skip to main content
Glama

Serena

by oraios

replace_regex

Replace text in files using Python-style regular expressions on the Serena MCP server. Specify regex patterns and replacement strings to update content efficiently. Use wildcards for broad or multi-line matches.

Instructions

Replaces one or more occurrences of the given regular expression. This is the preferred way to replace content in a file whenever the symbol-level tools are not appropriate. Even large sections of code can be replaced by providing a concise regular expression of the form "beginning.*?end-of-text-to-be-replaced". Always try to use wildcards to avoid specifying the exact content of the code to be replaced, especially if it spans several lines.

IMPORTANT: REMEMBER TO USE WILDCARDS WEHEN APPROPRIATE! I WILL BE VERY UNHAPPY IF YOU WRITE LONG REGEXES WITHOUT USING WILDCARDS INSTEAD!.

Input Schema

NameRequiredDescriptionDefault
allow_multiple_occurrencesNoIf True, the regex may match multiple occurrences in the file and all of them will be replaced. If this is set to False and the regex matches multiple occurrences, an error will be returned (and you may retry with a revised, more specific regex).
regexYesA Python-style regular expression, matches of which will be replaced. Dot matches all characters, multi-line matching is enabled.
relative_pathYesThe relative path to the file.
replYesThe string to replace the matched content with, which may contain backreferences like \1, \2, etc.

Input Schema (JSON Schema)

{ "properties": { "allow_multiple_occurrences": { "default": false, "description": "If True, the regex may match multiple occurrences in the file\nand all of them will be replaced.\nIf this is set to False and the regex matches multiple occurrences, an error will be returned\n(and you may retry with a revised, more specific regex).", "title": "Allow Multiple Occurrences", "type": "boolean" }, "regex": { "description": "A Python-style regular expression, matches of which will be replaced.\nDot matches all characters, multi-line matching is enabled.", "title": "Regex", "type": "string" }, "relative_path": { "description": "The relative path to the file.", "title": "Relative Path", "type": "string" }, "repl": { "description": "The string to replace the matched content with, which may contain\nbackreferences like \\1, \\2, etc.", "title": "Repl", "type": "string" } }, "required": [ "relative_path", "regex", "repl" ], "title": "applyArguments", "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/oraios/serena'

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