MCPGex
Enables LLMs to systematically develop and validate regex patterns by defining test cases with expected matches, testing patterns against them, and iteratively refining until all requirements are satisfied.
README
MCPGex
MCP server for finding, testing and refining regex patterns
<div align="center"> <img src="https://github.com/PatzEdi/MCPGex/raw/main/assets/logo.png" alt="mcpgex-high-resolution-logo-transparent" width="500"> </div>
<p align="center"> <img src="https://img.shields.io/badge/License-MIT-brightgreen?style=flat-square" height="23"> <img src="https://img.shields.io/badge/Creator-PatzEdi-brightgreen?style=flat-square" height="23"> </p>
<p align = "center"> <img src="https://img.shields.io/pypi/v/MCPGex?style=flat-square&color=%23FFA500" height="23"> </p>
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"]
}
}
}
Then, you will be able to use the server in these tools without having to run the python script manually!
<details> <summary>
Available Tools (click to expand)
</summary>
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.
</details>
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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
E2B
Using MCP to run code via e2b.