Skip to main content

MCP server for testing and validating regex patterns against test cases

Project description

MCPGex

MCP server for finding, testing and refining regex patterns

mcpgex-high-resolution-logo-transparent

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

  1. Define the goal: You provide what the goal regex pattern should return. The LLM will generate test cases for you.
  2. Test patterns: The LLM can test different regex patterns against all defined test cases to see which ones pass or fail.
  3. Iterate: Based on the results, the LLM can refine the regex pattern until all test cases pass.
  4. 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:

"context_servers": {
  "mcpgex": {
    "command": {
      "path": "python3",
      "args": ["-m", "mcpgex"]
    },
    "settings": {}
  }
}

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 against
  • expected_matches (required): The array of substrings that should be extracted/matched
  • description (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 test
  • flags (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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpgex-0.1.3.tar.gz (120.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpgex-0.1.3-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file mcpgex-0.1.3.tar.gz.

File metadata

  • Download URL: mcpgex-0.1.3.tar.gz
  • Upload date:
  • Size: 120.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mcpgex-0.1.3.tar.gz
Algorithm Hash digest
SHA256 bac79432b5257577d5c5c43bf28a7f58aac5e63e12f5bc7e507b0e7d0551a942
MD5 77dc29c2281b3a6f53aecc0ef4450cb0
BLAKE2b-256 a16dd284b8a52cc4c6743f610ce61a79fa38b6cd26d8fc02879119dd96509872

See more details on using hashes here.

File details

Details for the file mcpgex-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: mcpgex-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for mcpgex-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0080ea77e986355c94b5830309096593a56fd8add33fa17ba8da65c8fee4cf79
MD5 1a5c1d67eb8cd6cd62883a40191a3647
BLAKE2b-256 9ed60922aa660a9815437d84b29653cab970406e268e6a648a7d410bb5121712

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page