About regex-test-mcp
regex-test-mcp is an MCP server for checking JavaScript regular expressions with the actual JS regex engine. It is for agents and developers who need exact match offsets, groups, and replacement behavior.
Key features
- 01Test the first regex match
- 02Find all non-overlapping matches
- 03Replace text with regex captures
- 04Return offsets and named groups
- 05Handle zero-width matches safely
Use cases
- 01Verify whether a pattern matches text
- 02Inspect match positions and capture groups
- 03Find every match without zero-width loops
- 04Check regex-based replacement results
MCP support
Exposes `test_regex`, `find_all`, and `replace` tools to MCP clients for JavaScript regex testing.
Configuration
Local server config is the same for every client. Copy it into your client’s MCP config file.
Tools
3Saved tool list · updated 3w ago
| Parameter | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | |
| flags | string | No | JS regex flags, e.g. 'i', 'gm', 'isu'. |
| pattern | string | Yes | JS regex pattern (no surrounding slashes). |
Details
From the project README@mukundakatta/regex-test-mcp
MCP server for trustworthy regex testing. Three tools: test_regex, find_all, replace. All use the actual JS regex engine, so you get exact semantics for lookahead, anchors, named groups, and Unicode escapes.
Why this exists
LLMs reliably hallucinate regex behavior. Common ways they're wrong:
- Confidently stating a pattern matches when it doesn't (or vice versa)
- Wrong group indices when there are nested capture groups
- Forgetting that
.excludes newlines without thesflag - Hand-rolling
replaceresults that miss edge cases ($&semantics, named-group syntax)
Routing the actual test through this MCP server avoids all of those.
Tools
| Tool | Returns |
|---|---|
test_regex(pattern, text, flags?) | {matched, match, start, end, groups, named_groups} for the first match |
find_all(pattern, text, flags?) | All non-overlapping matches (always behaves as g); zero-width safe |
replace(pattern, text, replacement, flags?) | New string + replaced boolean; supports $1, $<name>, $& |
Install — Claude Desktop
{
"mcpServers": {
"regex-test": { "command": "npx", "args": ["-y", "@mukundakatta/regex-test-mcp"] }
}
}
Same shape for Cursor / Cline / Windsurf / Zed.
License
MIT OR Apache-2.0.
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.