Skip to main content
Glama
regexlab-mcp
by 0xmortuex

replace_preview

Preview regex substitutions by showing each match, its expanded replacement, and the final text across Python and JavaScript engines, with warnings for syntax that differs between them.

Instructions

Preview a regex substitution: every match, what it becomes, and the final text.

The replacement is expanded by each engine's own template rules, so the preview shows what the code will really do. Python uses \1, \g<1> and \g; JavaScript uses $1, $, $&, $` , $' and $$. If the replacement uses the other language's syntax (a common bug: "$1" in Python is literal text) a WARNING says so, and differing results between engines are called out.

engines: any of "python", "javascript" (or "js"), "regex"; default all available.

Input Schema

NameRequiredDescriptionDefault
flagsNo
enginesNo
patternYes
subjectYes
timeout_sNo
max_matchesNo
replacementYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.6/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses that replacement templates are expanded per engine, lists the exact syntax each engine honors, and warns that wrong-language syntax produces a WARNING and divergent results. It omits operational behavior such as what timeout_s and max_matches do when hit, and whether output is truncated.

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?

The core capability is front-loaded in sentence one, and the engine-syntax detail is genuinely necessary to avoid the '$1' vs '\1' mistake. The engine enumeration at the end is slightly redundant with the earlier syntax discussion and could be tightened.

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

Completeness3/5

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

An output schema exists, so return values need no explanation, but for a 7-parameter tool with zero schema coverage and no annotations the description should cover flags syntax and the effect of timeout_s/max_matches. Missing failure behavior (invalid pattern, timeout exceeded) leaves the agent under-informed about edge cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0% across 7 parameters, so the description must compensate. It explains 'engines' thoroughly (accepted values, the 'js' alias, default to all available) and adds real meaning to 'replacement' via engine-specific template syntax, but leaves pattern, subject, flags, timeout_s, and max_matches entirely to their bare titles.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The first sentence names a specific verb and resource — 'Preview a regex substitution' — and enumerates the output: 'every match, what it becomes, and the final text.' That is clearly distinct from siblings like explain_regex or check_backtracking, though the description never explicitly names an alternative.

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

Usage Guidelines3/5

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

Usage is implied by the word 'preview' (check before committing a substitution), but there is no explicit when-to-use guidance, no prerequisites, and no pointer to siblings such as test_regex or compare_engines, which overlap on the cross-engine comparison angle.

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