Extract regular expressions from code, each with a ReDoS safety verdict.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Find, test, and validate the regex patterns in the current file
Literal patterns, RegExp constructors, ReDoS screening
Useful? A star or rating is how other developers find it β β GitHub Β· β Open VSX Β· β Marketplace
Open any file and run one of three commands. Extract lists every regex pattern found in the document. Test (Ctrl+Alt+R / Cmd+Alt+R) runs a found β or manually entered β pattern against the file content and reports matches with real line/column positions and capture groups (named groups included). Validate checks every found pattern for syntax errors and screens it for catastrophic backtracking, reporting the input that causes it. Works in VS Code and VS Codeβbased editors like Cursor and VSCodium (installable from Open VSX).
| Where | What you get | Install |
|---|---|---|
| VS Code | The lint and the tester, in your editor | Marketplace |
| Cursor, VSCodium, Windsurf | The same extension | Open VSX |
| A terminal or a CI step | The same run over a whole tree, with exit codes | cargo install regex-le Β· crates.io |
| Any MCP agent, via Node | extract_patterns over stdio | npx regex-le-mcp Β· npm |
| Zed | The MCP server as a context server | add it by hand (no listing yet) |
The same engine runs as an MCP server, so an agent can call it directly instead of you running a command.
| Editor | How |
|---|---|
| VS Code 1.101+ | Nothing to install β the extension registers extract_patterns with agent mode |
| Zed | No listing yet β add the MCP server by hand |
| Claude Code | claude mcp add regex-le -- npx -y regex-le-mcp |
| Cursor, Windsurf, anything else | point it at npx regex-le-mcp |
Returns every pattern with its flags, 1-based position and a ReDoS verdict, so "are any of the regexes in this file dangerous?" is one call rather than two. A verdict that reports a blow-up carries the witness that caused it, so an agent can check the finding instead of trusting it.
The server takes content and returns data β it reads no files and makes no network requests of its own. Published as regex-le-mcp on npm and as io.github.nolindnaidoo/regex-le in the MCP registry.
Most hosts read a JSON config. Add one entry:
-y skips the install prompt on first run. Pin a version if you would rather not track releases β regex-le-mcp@2.4.0.
Prefer not to go through npx on every launch? Install it once and point at the binary instead:
It speaks MCP over stdio and needs no environment variables, no API key and no configuration of its own. To check it before wiring it into anything:
That prints the tool list and exits β if you see extract_patterns, the server works.
Extraction scans the whole document, so constructors split across lines are found too. The document's language chooses which spellings to look for:
| Language | Form | Example |
|---|---|---|
| JavaScript, TypeScript, Ruby | Literal | /[a-z]+/gi |
| JavaScript, TypeScript | Constructor | new RegExp('\\d{4}-\\d{2}', 'g') β including multiline |
| JavaScript, TypeScript | Bare constructor call | RegExp("x|y", "i") |
| Python | re.compile and friends | re.compile(r'(a+)+') |
| Rust | Regex::new, RegexBuilder::new | Regex::new(r"(a+)+") |
| Go | regexp.MustCompile, regexp.Compile | regexp.MustCompile(`(a+)+`) |
| Java | Pattern.compile, Pattern.matches | Pattern.compile("(a+)+") |
| Ruby | Regexp.new | Regexp.new('(a+)+') |
| PHP | preg_match and friends | preg_match('/(a+)+/i', $s) |
| C# | new Regex(β¦), Regex.IsMatch and friends | new Regex(@"(a+)+") |
A language nothing recognises is not a refusal β every spelling above is looked for. Naming it buys precision: a Python file is not scanned for bare /β¦/, so #!/usr/bin/env python stops reading as a pattern.
What is deliberately not extracted:
a / b, 10/29/2025, /usr/local/bin): a / preceded by an identifier, number, ), ], ., or another / is not treated as a regex β after keywords like return, it is. That question is only asked where a bare /β¦/ is legal.re.compile(r'(?P<word>\w+)+@') is reported as written, and still flagged.(?i) rather than a string argument.re.compile(r"(a+)+b") keeps its quoted argument while a docstring holding that whole line is prose. Only when the language is known: a document nothing recognises is scanned as written, because a comment rule guessed from the wrong grammar would drop real patterns instead of phantom ones.Duplicate pattern+flags pairs are listed once. This is lexing by heuristic, not a parser for nine languages: a slash inside a string can still be picked up when its context looks expression-like.
Validate (and Test, before running a risky pattern) reports a pattern only when an input was found that demonstrably drives it into catastrophic backtracking β and reports that input alongside it, as the witness.
Your pattern is never run. It is compiled to an automaton, and that automaton is walked the way a backtracking engine walks one β depth-first, every edge in order, a dead end unwound rather than remembered β while the steps are counted. An attack string is built, pumped at two lengths, and measured against a step budget. So a finding is falsifiable: run the witness and watch.
Nothing is reported on the strength of how a pattern is shaped. Shape is a poor predictor in both directions: ^[a-z0-9]+(?:-[a-z0-9]+)*$ looks dangerous and is not, because every iteration must eat a - the inner class cannot produce, while (.*a){20} looks bounded and is not. A separator forcing the split is a fact about strings, so no test on syntax settles it.
Silence is not a clearance. A pattern this cannot read β a backreference, lookaround, syntax it does not parse β comes back as not decided: <reason>, never as safe.
The reports also include a rough performance score based on execution time relative to input size β treat it as a hint, not a benchmark (memory is not measured).
The same lint runs from a terminal or a shell pipeline: a Rust CLI in
crate/, sharing one corpus with the extension β
crate/fixtures/ β so the two can never read a
document differently.
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/regex-le)<a href="https://allmcps.com/mcp/regex-le"><img src="https://allmcps.com/api/badge/regex-le?style=directory" alt="Regex Le on AllMCPs" /></a>