
Regex Lab
io.github.basitalisandhuv0.1.1更新于 Oct 5, 2026
Test regular expressions in a timeout-guarded worker, explain them, find catastrophic backtracking.
概览
让助手用样本测试 JavaScript 正则表达式、逐项解释模式,并检查是否存在灾难性回溯。
- 功能
- 提供三个处理 JavaScript(V8)正则表达式的工具。test_regex 用模式和标志匹配最多 50 个样本字符串,返回每个匹配的偏移、文本、编号与命名分组,以及可选的替换预览。explain_regex 逐项说明字面量、字符类、转义、锚点、分组、环视、量词和分支,并给出捕获组数量和标志含义。check_redos 报告嵌套无界重复、重复下的重叠分支等静态问题,再用定时探测确认或排除风险。
- 适用场景
- 适合在编写、调试或审查正则表达式时使用,需要匹配细节、通俗解释或快速排查易导致 ReDoS 的模式。在重视正则正确性与安全性的编辑器或编码流程中较为实用。
- 运行要求
- 以 npm 包形式通过 stdio 在本地运行,通常用 npx 启动;也发布了 Docker 镜像 ghcr.io/basitalisandhu/mcp-regex-lab:0.1.1。npm 方式需要 Node.js。未声明认证、环境变量、请求头、网络访问或本地文件访问。
安装
在 SourceWeft 中
- 打开 控制台中的 Regex Lab,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
regex-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
Install
Claude Code:
Add -s user to make it available in every project. Any client that reads .mcp.json (Claude Code, Claude Desktop, Cursor):
Pin the version as shown so that an update to the package cannot change what runs in your editor without you noticing. 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
Tests use node:test and the SDK's in-memory transport; they do not reach the network.
Licence
MIT. See LICENSE.
来源:packages/regex-lab/README.md,提交 58c8c95
工具
0版本历史
1- v0.1.1最新Oct 5, 2026


