MCPGex
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCPGex test the pattern \d{3}-\d{3}-\d{4} for phone number extraction"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCPGex
MCP server for finding, testing and refining regex patterns
MCPGex is an MCP server that allows LLMs to test and validate regex patterns against test cases. It provides a systematic way to develop regex patterns by defining or generating expected outcomes and iteratively testing patterns until all requirements are satisfied.
MCPGex is still in its early stages.
Index
Related MCP server: Regex Toolkit MCP Server
How it works
Define the goal: You provide what the goal regex pattern should return. The LLM will generate test cases for you.
Test patterns: The LLM can test different regex patterns against all defined test cases to see which ones pass or fail.
Iterate: Based on the results, the LLM can refine the regex pattern until all test cases pass.
Validate: Once all tests pass, you have a regex pattern that works for your specific use cases.
Installation
Go ahead and install through pip:
pip3 install mcpgexUsage
Running the Server
If you want to start the MCP server:
mcpgexConfiguration
You can also add a configuration. For example, for Claude Desktop, you can have:
{
"mcpServers": {
"mcpgex": {
"command": "python3",
"args": ["-m", "mcpgex"]
}
}
}Then, you will be able to use the server in these tools without having to run the python script manually!
Available Tools (click to expand)
The server provides four main tools:
1. add_test_case
Add a new test case with an input string and expected match.
Parameters:
input_string(required): The text to test againstexpected_matches(required): The array of substrings that should be extracted/matcheddescription(optional): Description of what this test case validates
Example:
{
"input_string": "Contact me at john@example.com for details",
"expected_matches": ["john@example.com"],
"description": "Basic email extraction"
}2. test_regex
Test a regex pattern against all current test cases.
Parameters:
pattern(required): The regex pattern to testflags(optional): Regex flags like 'i' (case-insensitive), 'm' (multiline), 's' (dotall)
Example:
{
"pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
"flags": "i"
}3. get_test_cases
View all currently defined test cases.
4. clear_test_cases
Remove all test cases to start fresh.
Benefits
Comprehensive testing: Ensure patterns work across various use cases
Iterative improvement: Easy to test and refine patterns
Documentation: Test cases serve as examples and documentation
Confidence: Know your regex works before deploying it
Fully Automated: Give it instructions, let it do the rest
Requirements (installed automatically through pip3)
Python 3.8+
MCP library (
pip3 install mcp)
License
This project is open source under the MIT license. Feel free to use and modify as needed.
Available Tools
4 toolsadd_test_caseB
Add a test case for regex pattern validation. Each test case consists of an input string and the expected match/output.
Inputs: input_string (required), expected_matches (required), groups (required), description.
clear_test_casesA
Clear all test cases to start fresh with new requirements.
Inputs: no named parameters.
get_test_casesA
Get all current test cases to see what requirements the regex pattern needs to satisfy.
Inputs: no named parameters.
test_regexA
Test a regex pattern against all current test cases to see if it satisfies the requirements.
Inputs: pattern (required), flags.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Each tool has a distinct purpose: adding test cases, running tests, viewing test cases, and clearing them. There is no overlap or ambiguity between the four operations.
All tool names follow a consistent verb_noun pattern: add_test_case, test_regex, get_test_cases, clear_test_cases. The naming is uniform and predictable.
Four tools is well-scoped for a focused regex testing server. Each tool covers a necessary part of the workflow without redundancy or bloat.
The tool set covers the full lifecycle of regex test case management: add, view, test, and clear. There are no obvious gaps for the stated purpose.
Maintenance
Related MCP Connectors
Deterministic regex synthesis from labeled examples. Zero LLM, proof matrix, backtracking audit.
33 tools that make AI write, implement, and verify intent against explicit, testable constraints.
Deterministic validation for AI-generated artifacts: JSON Schema, OpenAPI response, SQL syntax.
Practices for building software with coding agents, each with a test you check on your repo.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceRegexForge gives AI agents a reliable way to get a regex without asking an LLM to hallucinate one. Pass in labeled examples (strings that should match, strings that shouldn't) plus an optional description; get back the regex, a proof matrix showing it handles every example, and a backtracking-risk audit flagging catastrophic-backtracking patterns. Pure symbolic synthesis over a template bank with-
- FlicenseAqualityDmaintenanceEnables LLM agents to extract, validate, and mask personally identifiable information using deterministic regular expressions, reducing token usage and hallucination risks.34 npm3-
- AlicenseAqualityDmaintenanceProvides tools to test regex patterns for correctness, performance (ReDoS), and memory usage, and suggests safe rewrites. Enables LLMs to iterate on regex generation with verifiable feedback.9MIT
- AlicenseNot gradedqualityDmaintenanceValidates regex, cron, and SQL expressions by executing them in real runtimes, with payments via x402 USDC on Base.MIT