Test and extract regex matches from text via mcpzoo-regex (uvx)
Regex operations are a common agent need — validating input formats, extracting structured data from unstructured text, finding patterns. mcpzoo-regex provides two tools: regex_test (does this text match this pattern?) and regex_extract (find all matches, with capture group support). Useful for email extraction, date validation, URL parsing, log analysis, and any pattern-matching task where the agent needs deterministic results rather than LLM guessing.
Recipe: Regex testing and extraction via mcpzoo-regex
Server: mcpzoo-regex (server name: "regex") v1.27.2 via uvx Transport: stdio, NDJSON framing Launch: uvx mcpzoo-regex
Tools
| Tool | Purpose | Key params |
|---|---|---|
regex_extract | Find all matches of a pattern in text | text, pattern, group (optional, default 0) |
regex_test | Test if text matches a pattern, with match position | text, pattern |
Handshake
→ {"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"agent","version":"1.0"}}}
← serverInfo: {name:"regex", version:"1.27.2"}
→ {"jsonrpc":"2.0","method":"notifications/initialized"}
→ {"jsonrpc":"2.0","id":2,"method":"tools/list"}
← tools: [regex_extract, regex_test]Example 1: Extract email addresses from text
→ {"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"regex_extract","arguments":{"text":"Contact us at [email protected] or [email protected] for help. Not an email: @mention","pattern":"[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"}}}
← {"count": 2, "matches": ["[email protected]", "[email protected]"]}Example 2: Extract capture groups (domains from URLs)
→ {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"regex_extract","arguments":{"text":"Visit https://tani.ai/registry and http://example.com/page","pattern":"https?://([^/\\s]+)","group":1}}}
← {"count": 2, "matches": ["tani.ai", "example.com"]}Example 3: Test if a string matches an ISO date format
→ {"jsonrpc":"2.0","id":5,"method":"tools/call","params":{"name":"regex_test","arguments":{"text":"2026-06-13","pattern":"^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])$"}}}
← {"matched": true, "full_match": "2026-06-13", "start": 0, "end": 10}Example 4: Non-matching test
→ {"jsonrpc":"2.0","id":6,"method":"tools/call","params":{"name":"regex_test","arguments":{"text":"not-a-date","pattern":"^\\d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\\d|3[01])$"}}}
← "不匹配" (Chinese for "no match")Gotchas
- NDJSON framing — Python server, send one JSON object per line.
- Descriptions are in Chinese — tool descriptions use Chinese text (e.g. "用正则表达式从文本中提取所有匹配内容"), but the tools work fine with any input language.
- "No match" response is in Chinese —
regex_testreturns"不匹配"when the pattern doesn't match, rather than a structured{matched: false}. - Python regex syntax — uses Python's
remodule, so backslash-heavy patterns need proper JSON escaping (double backslash). regex_extractreturns structured JSON withcountandmatchesarray.regex_testreturnsmatched,full_match,start,endon success.
When to use this vs. the LLM
Use regex_test/regex_extract when you need deterministic, exact pattern matching — email validation, log parsing, data extraction. Don't use it for fuzzy matching or semantic understanding where the LLM is better.
{ "request": { "jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": { "name": "regex_extract", "arguments": { "text": "Contact us at [email protected] or [email protected] for help. Not an email: @mention", "pattern": "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}" } } }, "response": { "jsonrpc": "2.0", "id": 3, "result": { "content": [ { "type": "text", "text": "{"count": 2, "matches": ["[email protected]", "[email protected]"]}" } ], "isError": false } }, "server": "mcpzoo-regex", "server_name": "regex", "version": "1.27.2", "launcher": "uvx", "transport": "stdio", "framing": "NDJSON", "latency_ms": "<50" }