
regex mcp
处理正则相关的mcp
Repository Info
About This Server
处理正则相关的mcp
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP正则表达式测试服务
这是一个基于MCP(Model Context Protocol)的正则表达式测试工具,可以被集成到支持MCP的AI助手中,如Claude等。
功能
本服务提供以下MCP工具:
- regex_parse - 解析各种格式的正则表达式
- regex_match - 使用正则表达式匹配测试字符串
- regex_explain - 解释正则表达式的含义
- regex_generate - 根据自然语言描述生成正则表达式
安装
依赖项
确保安装了必要的依赖:
pip install -r requirements.txt
使用方法
启动服务
使用以下命令启动MCP服务器:
python run_mcp_server.py
或者指定主机和端口:
python run_mcp_server.py --host 0.0.0.0 --port 8080
连接到MCP客户端
在支持MCP的客户端中,配置以下连接信息:
- 服务器URL:
http://localhost:8000/sse(使用实际的主机和端口)
工具用法示例
regex_parse
解析各种格式的正则表达式:
输入: r"pattern"
输出: {"patterns": ["pattern"], "count": 1}
regex_match
匹配正则表达式:
输入:
- pattern: "[a-z]+"
- test_string: "abc123"
- flags: ["IGNORECASE"]
输出: 包含匹配结果的详细信息
regex_explain
解释正则表达式:
输入: "\d+\.\d{2}"
输出: "\d: 匹配任何十进制数字 | +: 匹配前面的子表达式一次或多次 | \.: 匹配任何字符(除了换行符) | \d: 匹配任何十进制数字 | {: 指定匹配前面子表达式的次数范围"
regex_generate
生成正则表达式:
输入: "电子邮件"
输出: {
"pattern": "[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}",
"explanation": "匹配标准电子邮件地址格式",
"examples": ["user@example.com", "name.surname@domain.co.uk"]
}
开发
项目结构
mcp_regex_service/
├── __init__.py # 包初始化文件
├── server.py # MCP服务器和工具定义
├── regex_tools.py # 核心正则表达式处理函数
└── utils/ # 辅助工具模块
└── __init__.py
Quick Start
Clone the repository
git clone https://github.com/yzofish/regex-mcpInstall dependencies
cd regex-mcp
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.