Skip to main content
Glama
regexlab-mcp
by 0xmortuex

explain_regex

Explains regex patterns token by token in plain English, flags engine-specific behavior and syntax errors by position for Python, JavaScript, or regex syntax.

Instructions

Explain a regex token by token in plain English, using this server's own parser.

Covers literals, escapes, classes, quantifiers (greedy, lazy, possessive), groups (capturing, named, non-capturing, atomic), lookahead and lookbehind, backreferences, anchors and inline flags, and says how each construct behaves in the chosen engine (for example Python's $ before a trailing newline, or JavaScript's ASCII-only \d). Constructs it does not model (recursion, conditionals, \N{...}) are marked "NOT EXPLAINED" rather than guessed. Syntax errors are reported with the position. Engine-specific syntax that the engine would reject is flagged as ERROR.

engine: "python" (default), "javascript" or "regex" (syntax dialect only; this tool does not need the engine installed). flags: same letters as test_regex; they change the explanation (m, s, a, x, ...).

Input Schema

NameRequiredDescriptionDefault
flagsNo
engineNopython
patternYes

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/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 so well: it discloses the unmodeled-construct policy ('NOT EXPLAINED' rather than guessed), error reporting with position, engine-invalid syntax flagged as ERROR, and that no engine installation is required. These are non-obvious behaviors an agent could not infer from the name or schema.

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 one-sentence purpose, then construct coverage, then edge-case behavior, then the per-parameter notes. Dense but every sentence adds information; the construct enumeration is long but justifies itself by setting scope expectations.

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

Completeness4/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 formatting needn't be re-explained, and the description covers engine dialect nuance and failure modes thoroughly for a 3-param, single-pattern tool. Minor gap: no guidance on the 'pattern' input itself or on behavior for very large patterns.

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 0%, so the description must compensate, and it does for two of three params: engine values are enumerated in prose ('python' default, 'javascript', or 'regex' as syntax dialect only) and flags are tied to test_regex letters with examples (m, s, a, x). Only 'pattern' lacks any explicit statement, though the entire description makes its role obvious.

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 specific verb and resource ('Explain a regex token by token in plain English') plus the method ('using this server's own parser'), and the enumerated construct coverage makes it unmistakable versus siblings like test_regex or compare_engines, which operate on matches rather than explanations.

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 rather than routed: the agent can infer this is for understanding a pattern's semantics, and 'this tool does not need the engine installed' plus the 'same letters as test_regex' cross-reference give useful context. However, it never explicitly says when to prefer test_regex or compare_engines instead, nor any exclusions.

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