regexlab-mcp
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
A regex lab that RUNS patterns in real engines instead of guessing: Python re, JavaScript RegExp (via node, when installed) and the optional Python regex module. Always verify a regex with test_regex before presenting it as working. Use explain_regex to read a pattern, check_backtracking before putting a pattern near untrusted input (it measures ReDoS in a killable child process), compare_engines when a pattern must work in more than one language, convert_pattern to translate between Python and JavaScript syntax, replace_preview before running a substitution, and suggest_tests to get verified should-match / should-not-match examples. Spans are in Unicode code points. Tools say which engines were skipped and why.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| test_regexA | Run a regex against text in REAL engines and report every match. Use this to check any regex before telling the user it works. For each engine you get all matches (global search) with [start:end) spans in Unicode code points, the numbered and named capture groups, and a flag when engines disagree. pattern: the regex source, exactly as it would appear in code (no delimiters, no extra string escaping). subject: one text, or a list of texts; each list item is a separate case. flags: letters: i ignore case, m multiline, s dot matches newline, x verbose and a ASCII classes (Python only), u unicode, v unicodeSets and y sticky (JavaScript only). g is implied. engines: any of "python", "javascript" (or "js"), "regex". Default: every engine available on this machine; unavailable ones are reported, not silently skipped. timeout_s: hard limit (0.2-30). A run that exceeds it is killed and reported as a catastrophic-backtracking case. max_matches: cap per case (max 500). Limits: pattern 5000 chars, 100 cases, 200k characters of subject in total. |
| explain_regexA | 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 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, ...). |
| check_backtrackingA | Check a regex for catastrophic backtracking (ReDoS) by analysing AND timing it. Two stages. Static: finds nested quantifiers like (a+)+, alternation with overlapping branches inside a loop, adjacent overlapping repeats like .., and unanchored leading repeats. Empirical: builds adversarial input for the worst suspects and times it in the real engine in a child process that is KILLED at the time limit. A pattern that hits the limit is reported as exponential, with an example slow input. Static suspicions the probe cannot reproduce are reported as unconfirmed; "no finding" is evidence, not proof. engine: "python" (default), "javascript", "regex", or "all" for every available engine (V8 and Python's re have different optimisations, so results can differ). timeout_s: time budget per probe run, 0.2-30 (default 3). |
| compare_enginesA | Run one pattern in every available engine and explain where they differ. Reports whether the pattern compiles in each engine (named-group syntax (?P vs (?, \A \Z, inline flags, atomic groups, lookbehind width, \p{..}), runs your subject plus targeted variants (trailing newline, Unicode digits, non-ASCII word, emoji, Turkish case pairs) in all engines, and lists the known semantic differences that apply to this pattern ($ and trailing newline, Unicode-aware \d \w \b, dot and line terminators, case folding). Use it when a regex has to behave the same in Python and JavaScript. |
| convert_patternA | Translate a regex between Python and JavaScript syntax, with explicit warnings. Handles named groups and named backreferences, \A \Z and $ (using exact lookaround equivalents), inline global flags, verbose mode, {,n}, \U and \u{...} escapes, [^] and [], and the g/y/u flags. Things with no equivalent (atomic groups, possessive quantifiers, \p{..} in Python re, POSIX classes, recursion) are left unchanged and listed as WARNINGS. Differences that cannot be fixed syntactically (Unicode-aware \d \w vs ASCII-only) are listed too. The result is compiled in the target engine to prove it is at least valid; run test_regex or compare_engines to prove it is equivalent. from_engine / to_engine: "python", "javascript" (or "js"), "regex". flags: flags of the source pattern; the converted flags are returned. |
| replace_previewA | 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. |
| suggest_testsA | Generate should-match and should-not-match test strings for a regex, verified by running. Builds examples from the pattern's structure (each alternative, quantifier minimum
and maximum, class boundaries) plus mutations (deleted or replaced characters, junk
prefix/suffix, trailing newline, case swap, off-by-one repeat counts), then RUNS all of
them in the real engine. Only confirmed examples are listed as tests. Mutations that
unexpectedly still match are listed as SURPRISES - they often expose a missing anchor,
a engine: "python" (default), "javascript" or "regex" (must be available). |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 7 tools
Each tool has a clearly stated, distinct job: testing, explaining, ReDoS analysis, cross-engine comparison, syntax conversion, substitution preview, and test generation. Minor overlap exists because test_regex already reports engine disagreements and killed timeouts, blurring its boundary slightly with compare_engines and check_backtracking, but the descriptions explicitly cross-reference when to use which.
All seven tools follow a strict snake_case verb_noun convention (test_regex, explain_regex, check_backtracking, compare_engines, convert_pattern, replace_preview, suggest_tests). The verb choice is also semantically meaningful and consistent across the set.
Seven tools is well within the ideal 3-15 range for a regex workbench and each tool covers a genuinely different stage of the regex lifecycle. Nothing appears redundant or thin.
The surface covers validation, explanation, performance safety, portability, conversion, substitution, and test generation—essentially the full regex workflow. Minor gaps remain, such as no explicit tool to list available engines/capabilities or to benchmark raw pattern throughput, but agents can work around these via test_regex output.