PM

patzedi/mcpgex

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

6 stars 3 forks 质量 54 趋势 14MIT

MCP server for finding, testing and refining regex patterns

概览

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. 1. : You provide what the goal regex pattern should return. The LLM will generate test cases for you. 2. : The LLM can test different regex patterns against all defined test cases to see which ones pass or fail. 3. : Based on the results, the LLM can refine the regex pattern until all test cases pass. 4. : Once all tests pass, you have a regex pattern that works for your specific use cases. You can also add a configuration. For example, for Claude Desktop, you can have: Then, you will be able to use the server in these tools without having to run the python script manually! Add a new test case with an input string and expected match.

README

以下为原文 README 节选,完整内容请查看原文。

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

  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"]
    }
  }
}

Then, you will be able to use the server in these tools without having to run the python script manually!

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 [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 test
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "mcpgex": { "command": "python3", "args": ["-m", "mcpgex"] } } }