What Regex Safety Audit MCP server does
Regex Safety Audit MCP server examines regular expressions for structural patterns associated with catastrophic backtracking, also known as regular expression denial of service (ReDoS). It uses a hand-written parser to build an abstract syntax tree rather than applying string-based detection heuristics.
The scanner covers three documented risk shapes: nested unbounded quantifiers such as (a+)+, ambiguous alternation inside a repeated group such as (a|ab)+, and backreferences. The analysis reports an overall risk level and provides each finding with its specific reason.
A key use case is JavaScript review. JavaScript does not support atomic groups or possessive quantifiers, despite those constructs appearing in general ReDoS remediation advice. Regex Safety Audit MCP server identifies this limitation and focuses rewrite suggestions on syntax that JavaScript can actually use.
How it works
The server analyzes the pattern structurally and does not execute the pattern during scanning. This design avoids the problem of a safety checker hanging while testing the potentially dangerous expression it is supposed to inspect.
For a pattern that has been flagged, generate_attack_string creates candidate proof-of-concept inputs at several sizes. It also returns a Node snippet for timing the match. The generated test uses a hard operating-system-level subprocess timeout, providing a boundary around experiments with expressions that may backtrack catastrophically.
The project states that its detection was checked against canonical examples from the ReDoS literature. The available material describes detection and rewrite behavior, but does not specify a complete list of supported regular-expression syntax beyond the reported risk patterns.
Tools and capabilities
analyze_redos_risk: Performs the full structural scan, returning a risk level, findings, reasons, and the JavaScript caveat about atomic groups and possessive quantifiers.
generate_attack_string: Produces candidate inputs in multiple sizes and a timeout-protected Node timing snippet for a flagged pattern.
suggest_safe_rewrite: Returns a concrete rewrite for mechanically fixable patterns. When an automatic rewrite is not appropriate, it explains that manual changes are needed instead.
The rewrite behavior includes collapsing redundant quantifier nesting or restructuring a pattern with a negated character class where those changes apply. It does not promise an automatic fix for every finding.
Setup and configuration
The repository documents two ways to use Regex Safety Audit MCP server. The hosted option is available through MCPize, which lists a free tier and a $7-per-month Pro tier. The self-hosted instructions are:
npm install
node server.js
The provided material does not document environment variables, additional configuration files, or client-specific setup steps. It also does not identify particular editor clients as supported.
Limitations and notes
Regex Safety Audit MCP server is a structural audit tool, not a runtime benchmark. Its scanner deliberately avoids executing the expression, while its optional attack-string output provides a separate, timeout-bounded way to test a flagged pattern.
The rewrite tool is limited to mechanically fixable shapes. Findings that require a design decision or a hand-written restructuring are reported as such rather than being forced into a potentially invalid rewrite. JavaScript syntax constraints are central to the guidance: atomic-group and possessive-quantifier recommendations from other engines may not be valid JavaScript solutions.