regexguard
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@regexguard Check if (a|a)+ is vulnerable to ReDoS"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
regexguard-mcp-server
An MCP server that gives any AI agent a way to sanity-check a regex it just generated -- both what it actually matches and whether it's safe to run against untrusted input -- before shipping it. Fully local: no API key, no network call, no dependency beyond the MCP SDK and Zod.
Why
Regexes are a notoriously easy place to introduce a bug that looks fine in every example you happen to test. Two failure modes in particular are both common and easy to miss by eye:
It doesn't match what you think it matches.
explain_regexturns the pattern into a real syntax tree and describes it in plain English, so "does this actually require at least one digit?" has a fast answer that doesn't depend on trusting your own reading of nested brackets.It's a denial-of-service vector. A regex with nested quantifiers (
(a+)+) or ambiguous alternation inside a repeated group ((a|a)+) can make a backtracking engine take exponential time on a crafted (or even accidental) non-matching input -- this is ReDoS, a real and repeatedly-exploited vulnerability class, and a plausible defect in any regex an agent writes without testing it against adversarial input.check_redos_riskflags the structural shape without ever executing the pattern -- it's safe to run on untrusted or deliberately malicious regex source.
Related MCP server: regex-quality
Tools
explain_regex
Parses a pattern into an AST and returns a plain-English description of what it matches.
check_redos_risk
Statically analyzes a pattern's structure for nested quantifiers and
ambiguous alternation inside a repeated group -- the two classic causes of
catastrophic backtracking. Returns "safe", "high", or "critical",
with a specific finding for each issue found.
Both tools share one parser
(src/services/parser.ts): a real recursive-descent
regex parser (literals, character classes, shorthand classes, anchors,
capturing/non-capturing/named groups, lookaround, alternation, quantifiers,
backreferences), not a bag of string-matching heuristics against the
pattern's raw source text.
This is a heuristic structural check, not a formal verifier --
check_redos_risk can tell you a pattern has the textbook exponential-blowup
shape; it can't prove a pattern is fast on all inputs, and there are ReDoS
patterns outside the two shapes it currently detects. Treat a "safe"
result as "nothing obvious found," not a guarantee.
Install and configure
git clone https://github.com/wedo911/regexguard-mcp-server.git
cd regexguard-mcp-server
npm install
npm run buildAdd it to your MCP client's config (e.g. claude_desktop_config.json, or a
project's .mcp.json for Claude Code):
{
"mcpServers": {
"regexguard": {
"command": "node",
"args": ["/absolute/path/to/regexguard-mcp-server/dist/index.js"]
}
}
}Run the tests
npm run build
node --test tests/parser.test.mjs tests/explain.test.mjs tests/redosCheck.test.mjs44 tests cover the parser grammar, the explanation output, and both true
positives ((a+)+, (a*)*, (a|a)+, (a|ab)+, patterns nested inside
non-capturing groups) and true negatives ((cat|dog)+, a realistic
username pattern, a realistic email pattern, sibling — not nested —
repetitions) for the ReDoS check, so the false-positive rate on ordinary
patterns is a tested property, not a hope.
Try it without a client
npx @modelcontextprotocol/inspector --cli node dist/index.js \
--method tools/call --tool-name check_redos_risk \
--tool-arg pattern='^(([a-zA-Z0-9])+([\.-]?([a-zA-Z0-9])+)*)$'License
MIT — see LICENSE.
Available Tools
2 toolscheck_redos_riskCheck Regex for Catastrophic Backtracking (ReDoS) RiskARead-onlyIdempotent
Statically analyze a regex's structure for the two classic causes of catastrophic backtracking: nested quantifiers (e.g. "(a+)+") and ambiguous alternation inside a repeated group (e.g. "(a|a)+"). Both can make a backtracking regex engine take exponential time on a crafted or even accidental non-matching input -- a real, exploitable denial-of-service vector, and a common defect in regexes generated without testing against adversarial input.
This tool NEVER executes the pattern -- it only parses and inspects the pattern's source structure, so it's safe to run on untrusted or deliberately malicious patterns without risk of hanging.
Args:
pattern (string, 1-1000 chars): the regex source, without delimiters.
Returns: For JSON format: { "parsed": boolean, "error": string | null, "risk": "safe" | "high" | "critical", "findings": [ { "category": "nested_quantifier" | "ambiguous_alternation", "severity": "high" | "critical", "message": string } ] }
Examples:
Use when: "is this regex I just generated safe to run against user input?" -> pass the pattern before using it
Use when: reviewing a regex from an untrusted source before adding it to a codebase
Don't use when: you need proof a regex is fast on all inputs -- this is a heuristic structural check (no false negatives are guaranteed to be caught), not a formal verifier
Error Handling:
Returns an error (not an exception) if the pattern doesn't parse.
Inputs: pattern (required).
explain_regexExplain a RegexARead-onlyIdempotent
Parse a regular expression into a real syntax tree and describe in plain English what it matches. Use this to sanity-check a regex you (or someone else) wrote actually does what you intended, before shipping it.
Args:
pattern (string, 1-1000 chars): the regex source, without delimiters (no leading/trailing "/").
Returns: For JSON format: { "explanation": string, "parsed": boolean, "error": string | null } explanation is empty and error is set if the pattern could not be parsed (e.g. unbalanced parentheses, unsupported syntax).
Examples:
Use when: "does this regex actually require the string to start with a letter?" -> pass the pattern, read the explanation
Don't use when: you need to actually run the regex against text -- this tool never executes the pattern, only analyzes its source
Error Handling:
Returns an error (not an exception) if the pattern doesn't parse, with the parser's best guess at where the problem is.
Inputs: pattern (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
The two tools have clearly distinct purposes: explain_regex describes what a pattern matches, while check_redos_risk analyzes vulnerability to catastrophic backtracking. They share input format but have no functional overlap, making misselection unlikely.
Both tools follow a consistent verb_noun snake_case pattern (explain_regex and check_redos_risk). The naming is predictable and aligns with the domain.
With only two tools, the server is minimally scoped, but for a dedicated regex-analysis utility this is reasonable and each tool addresses a core need. Slightly under typical range but appropriate for the narrow focus.
The server covers the essential aspects of regex analysis: comprehension (explain_regex) and security risk (check_redos_risk). Syntax validation is implicitly handled via parse errors. There are no obvious missing operations within the stated purpose.
Maintenance
Related MCP Connectors
Security scanner for AI agents: prompt injection, leaked secrets, PII, and SSRF-risk URL detection.
The WAF for agents. Pattern-based + heuristic firewall scans prompts, RAG documents, tool argume...
Agent security: prompt injection, PII & secret scans, TLS/header/CORS audits, MCP checks. Free.
Checks AI-written code for leaked keys and made-up packages, on your machine. Never uploads code.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceRegexForge gives AI agents a reliable way to get a regex without asking an LLM to hallucinate one. Pass in labeled examples (strings that should match, strings that shouldn't) plus an optional description; get back the regex, a proof matrix showing it handles every example, and a backtracking-risk audit flagging catastrophic-backtracking patterns. Pure symbolic synthesis over a template bank with-
- AlicenseAqualityDmaintenanceProvides tools to test regex patterns for correctness, performance (ReDoS), and memory usage, and suggests safe rewrites. Enables LLMs to iterate on regex generation with verifiable feedback.9MIT
- AlicenseNot gradedqualityBmaintenanceProvides a tool to extract and validate regex patterns from text content, including flags, positions, and ReDoS risk assessment. Enables AI agents to identify potentially dangerous regular expressions in code or files without needing filesystem access.10 npm2MIT
- AlicenseNot gradedqualityDmaintenanceEnables users to statically analyze regular expressions for catastrophic-backtracking (ReDoS) risk through real AST parsing rather than executing the pattern, flagging nested quantifiers, ambiguous alternation, and backreferences. It also generates candidate proof-of-concept attack strings with a timeout-guarded test snippet and suggests JavaScript-safe rewrites.MIT