Skip to main content
Glama

Reemplazar con expresión regular

regex-replace
Read-onlyIdempotent

Reemplaza coincidencias de una expresión regular ($1, $) en un contexto vm con límite de 50 ms y resultado máx. de 1.000.000 caracteres. Cuándo: hay que transformar, comparar o medir un texto con exactitud y no por aproximación. No para: escapar una cadena literal para usarla dentro de una expresión regular (regex-escape). Efectos secundarios: ninguno (solo lectura, sin red, sin estado guardado). Determinista: la misma entrada da la misma salida. Límites: entrada JSON de hasta 64 KB, 1 s por llamada, resultado de hasta 1 MB.

EN: Replaces regex matches ($1, $, $&, $` and $' supported) in a vm context with a 50 ms limit and a 1,000,000-character result cap. Without the g flag only the first match is replaced. When: text has to be transformed, compared or measured exactly instead of approximated. Not for: escaping a literal string so it can be embedded in a regular expression and match itself exactly (regex-escape). [EN completo / full EN: inputSchema.description]

Input Schema

NameRequiredDescriptionDefault
textYesSubject text (string; required).
flagsNoFlags from dgimsuyv (string; optional; default ""; up to 8 chars; pattern ^[dgimsuyv]*$).
patternYesJavaScript regular expression source (no slashes) (string; required; at least 1 chars; up to 500 chars).
replacementYesReplacement string (string; required; up to 10000 chars).

Output Schema

NameRequiredDescriptionDefault
textNo
replacementsNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • addedInput schema / properties / pattern / examples
      Added value: +[
      +  "(\\w+)@(\\w+)"
      +]
    • addedInput schema / properties / replacement / examples
      Added value: +[
      +  "$2:$1"
      +]
    • addedInput schema / properties / text / examples
      Added value: +[
      +  "ana@x bob@y"
      +]
  2. Changed1 schema field changed
    • addedInput schema / description
      Added value: +"EN: Replaces regex matches ($1, $<name>, $&, $` and $' supported) in a vm context with a 50 ms limit and a 1,000,000-character result cap. Without the g flag only the first match is replaced. When: text has to be transformed, compared or measured exactly instead of approximated. Not for: escaping a literal string so it can be embedded in a regular expression and match itself exactly (regex-escape). Side effects: none (read-only, no network access, no stored state). Deterministic: the same input gives the same output. Limits: JSON input up to 64 KB, 1 s per call, result up to 1 MB."
  3. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive/closed-world, and the description goes further with a 50 ms vm limit, 1,000,000-char result cap, 64 KB input / 1 s call limits, determinism, and the first-match-only behavior without the g flag. These are real execution constraints an agent cannot get from annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the core operation and limits, and the when/not-for clauses are well placed. However the English block largely restates the Spanish block and then points back to inputSchema.description, which duplicates text already in a structured field.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

An output schema exists and annotations cover the safety profile, so the remaining burden is limits, determinism and alternative routing — all present. Nothing an agent needs to invoke this correctly is missing.

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 still adds value by explaining replacement-token syntax and that the g flag governs first-match vs global replacement, which the schema does not say. It does not explain individual flags (d, i, m, s, u, y, v) beyond listing them.

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?

States a precise verb+resource ('Reemplaza coincidencias de una expresión regular') and adds the operative detail that replacement tokens ($1, $<name>, $&, $`, $') are supported, plus the g-flag behavior. It explicitly distinguishes itself from regex-escape, so an agent can separate it from at least one close sibling without opening a schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Contains explicit 'Cuándo' (transform/compare/measure text exactly) and 'No para' (escaping a literal string → regex-escape) clauses. The when/when-not pair with a named alternative is exactly the routing guidance an agent needs.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources