About Regex Lab
Regex Lab is an MCP server for developers testing and understanding JavaScript regular expressions. It explains patterns and checks for catastrophic backtracking; each execution runs in a timeout-guarded worker thread.
Key features
- 01Test patterns against sample strings
- 02Explain pattern constructs and flags
- 03Detect and probe possible catastrophic backtracking
Use cases
- 01Inspect matches and capture groups for test inputs
- 02Review a pattern for potential ReDoS behavior
MCP support
Exposes regular-expression testing, explanation, and backtracking checks as MCP tools.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
docker run -i --rm ghcr.io/basitalisandhu/mcp-regex-lab:0.3.0Local servers need a runtime on your machine (e.g. Node.js 18+). Config file locations differ by client; see your client’s docs.
ghcr.io/basitalisandhu/mcp-regex-lab:0.3.0stdioTools
Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.
Details
From the project READMEregex-lab MCP server
Tests JavaScript regular expressions against sample strings, explains a pattern construct by construct, and looks for catastrophic backtracking. Every execution runs in a worker thread that is terminated when it exceeds the timeout, so a pathological pattern cannot hang the server.
Part of dev-mcp-servers. Stdio transport only; the server never opens a port.
Tools
| Tool | Input | What it returns |
|---|---|---|
test_regex | pattern, flags?, samples[] (up to 50 of 20 000 chars), replacement?, timeout_ms? (50 to 10 000, default 2000) | Every match per sample with offsets, text, numbered and named groups (with offsets), optional replace preview. Samples finished before a timeout are still returned. |
explain_regex | pattern, flags? | Indented description of literals, classes, escapes, anchors, groups, lookarounds, quantifiers and alternation, plus the capturing group count and flag meanings. |
check_redos | pattern, flags?, probe? (default true), timeout_ms? | Static findings (nested unbounded repeats, overlapping alternatives under a repeat, adjacent overlapping repeats) with a probe character each, then timed runs against crafted inputs of growing length to confirm or clear the pattern. |
Install
Claude Code:
claude mcp add regex-lab -- docker run --rm -i ghcr.io/basitalisandhu/mcp-regex-lab:0.2.2
Add -s user to make it available in every project. Any client that reads .mcp.json (Claude Code, Claude Desktop, Cursor):
{
"mcpServers": {
"regex-lab": {
"command": "docker",
"args": ["run", "--rm", "-i", "ghcr.io/basitalisandhu/mcp-regex-lab:0.2.2"]
}
}
}
Pin the version as shown so that an update cannot change what runs in your editor without you noticing. The package is not on npmjs.com yet, so npx does not work; see the repository README for GitHub Packages npm. From a checkout, use "command": "node", "args": ["<path>/packages/regex-lab/dist/index.js"] after npm install && npm run build at the repository root.
What it touches
- Network: None.
- Local files: None.
- Telemetry: none.
Notes
- Syntax follows V8 (Node.js). PCRE, RE2 and Python differ in places such as possessive quantifiers and lookbehind.
ganddflags are added automatically when matching; the replacement preview uses the flags you gave.- No findings and flat timings are evidence, not proof, that a pattern is safe.
Build and test
npm install # at the repository root
npm run build -w @basitalisandhu/mcp-regex-lab
npm test -w @basitalisandhu/mcp-regex-lab
Tests use node:test and the SDK's in-memory transport; they do not reach the network.
Licence
MIT. See LICENSE.
Comments
New to MCP?
From what the protocol is to installing your first server, these answers cover most first questions.
An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.