- Explore MCP Servers
- MCPGex
Mcpgex
What is Mcpgex
MCPGex is an MCP server designed for the development and validation of regex patterns using large language models (LLMs). It enables users to define expected outcomes for regex patterns and iteratively refine them by testing against generated test cases until all criteria are met.
Use cases
MCPGex is useful for developers and data analysts who need to create or improve regex patterns for applications such as data extraction, validation, and transformation. It assists in ensuring accuracy across various inputs, making it suitable for tasks involving email parsing, log file analysis, and form validation.
How to use
To use MCPGex, install it via pip with ‘pip3 install mcpgex’ and start the server using the command ‘mcpgex’. Users can configure the server for different applications and utilize tools like ‘add_test_case’ to define test cases, ‘test_regex’ to validate patterns, ‘get_test_cases’ to view existing cases, and ‘clear_test_cases’ to reset the testing environment.
Key features
MCPGex offers comprehensive testing capabilities, facilitating both the addition of test cases and the iterative improvement of regex patterns based on test results. It serves as built-in documentation with test cases acting as examples, thereby boosting user confidence in the validity of regex patterns prior to deployment.
Where to use
MCPGex can be employed in development environments, data processing applications, and data science tools where regex testing and validation is essential. It is particularly applicable to software development environments, data cleansing processes, or any scenario requiring efficient pattern matching.
Overview
What is Mcpgex
MCPGex is an MCP server designed for the development and validation of regex patterns using large language models (LLMs). It enables users to define expected outcomes for regex patterns and iteratively refine them by testing against generated test cases until all criteria are met.
Use cases
MCPGex is useful for developers and data analysts who need to create or improve regex patterns for applications such as data extraction, validation, and transformation. It assists in ensuring accuracy across various inputs, making it suitable for tasks involving email parsing, log file analysis, and form validation.
How to use
To use MCPGex, install it via pip with ‘pip3 install mcpgex’ and start the server using the command ‘mcpgex’. Users can configure the server for different applications and utilize tools like ‘add_test_case’ to define test cases, ‘test_regex’ to validate patterns, ‘get_test_cases’ to view existing cases, and ‘clear_test_cases’ to reset the testing environment.
Key features
MCPGex offers comprehensive testing capabilities, facilitating both the addition of test cases and the iterative improvement of regex patterns based on test results. It serves as built-in documentation with test cases acting as examples, thereby boosting user confidence in the validity of regex patterns prior to deployment.
Where to use
MCPGex can be employed in development environments, data processing applications, and data science tools where regex testing and validation is essential. It is particularly applicable to software development environments, data cleansing processes, or any scenario requiring efficient pattern matching.
Content
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.
[!WARNING]
MCPGex is still in its early stages.
Index
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 mcpgex
Usage
Running the Server
If you want to start the MCP server:
mcpgex
Configuration
You can also add a configuration. For example, for Claude Desktop, you can have:
{
"mcpServers": {
"mcpgex": {
"command": "python3",
"args": [
"-m",
"mcpgex"
]
}
}
}
Or, for other applications, such as Zed:
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 [email protected] for details",
"expected_matches": [
"[email protected]"
],
"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.