Skip to main content
Glama

Verified Regex Generator

Typing SVG

Python Tests MCP FastAPI Groq

MCP → Verified Regex Generator。 用户用自然语言描述一个模式。LLM 生成正则表达式。一个智能体生成真实的样本字符串(正例 + 反例), 用真正的 re 引擎对正则进行测试,如果出错则迭代修正。 正则表达式以"看起来正确"但实际微妙出错而臭名昭著——验证才是这里的核心价值, 而不是生成本身。

运行在 Groq 上(默认使用 openai/gpt-oss-120b)——速度快且免费额度 友好,因此公开演示成本很低。

这不是"让 LLM 写个正则然后碰运气"。这是一个闭环验证流程:

description  ──►  LLM writes a candidate regex
                        │
description  ──►  LLM writes real test strings (incl. tricky near-misses)
                        │
                        ▼
              Python's `re` engine checks the candidate
              against every test string — ground truth,
              not the model's opinion of itself
                        │
              ┌─────────┴─────────┐
          all pass             something failed
              │                     │
              ▼                     ▼
           done               feed the exact failures
                               back to the model, try again

演示

一次真实运行:"美国电话号码" → 智能体编写 16 个测试字符串,提出一个候选正则, 用 Python 真正的 re 引擎进行校验,并在 2 次迭代内收敛到一个经过验证的模式。

Demo

Screenshot

Related MCP server: EvalView

项目内容

  • regex_agent/core.py — 实际的智能体循环(与传输方式无关,模型无关)。其他 一切都是围绕这个的薄封装。

  • mcp_server/ — 一个真正的 MCP 服务器,将 generate_verified_regex 作为工具暴露出来,因此可以直接从 Claude Desktop 或 Claude Code 中使用。

  • web/ — 一个 FastAPI + 原生 JS 演示,包含两个部分:

    1. 智能体推理过程的实时动画视图:测试用例、每个候选正则,以及每次迭代的 通过/失败表格。

    2. 下方的 regex101 风格实时测试器 — 一个可编辑的模式字段,支持标志 (g/i/m/s/全匹配)、针对你自己的测试字符串的实时匹配高亮、 带捕获组的匹配列表,以及正则的逐 token 自然语言解析 (全部在客户端完成,无需 API 调用)。它会自动填入智能体刚刚验证过的 内容,但也可以独立使用,适用于你粘贴进来的任何正则——即使你已经精通 正则、只想测试一个,也很有用。

    无需 MCP 客户端——在浏览器中即可运行。

环境搭建

pip install -r requirements.txt
cp .env.example .env   # then add your GROQ_API_KEY

运行 Web 演示

cd web
python server.py

打开 http://127.0.0.1:8000

运行 MCP 服务器

将其添加到你的 MCP 客户端配置中(例如 Claude Desktop 的 claude_desktop_config.json, 或 Claude Code 的 .claude/settings.json):

{
  "mcpServers": {
    "verified-regex-generator": {
      "command": "python",
      "args": ["/absolute/path/to/2 project/mcp_server/server.py"]
    }
  }
}

然后向 Claude 提问,例如 "用 verified regex generator 帮我构建一个美国电话号码的正则。" ——它会调用该工具,在服务端运行完整的 生成 → 测试 → 验证 循环, 并返回一份 JSON 报告。

为什么这是一个很好的展示

大多数"AI 写代码"的演示止步于生成。这个项目将 LLM 的首次回答视为一个假设, 而非答案——并且只有在它通过真实基准(真正的正则引擎、真实的字符串, 包括模型自己提出的对抗性近似误例)验证之后才宣称成功。这个循环——生成 → 验证 → 修订—— 是可靠的智能体工具背后的核心模式,而且它足够小,可以在 regex_agent/core.py 中 从头到尾读完。

F
license - not found
Not graded
quality - not tested
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Dynamically generates MCP tools from OpenAPI specifications, enabling AI assistants to interact with any REST API through natural language. Supports multiple APIs with authentication, parameter validation, and integration with Claude Desktop and LangChain.
    1
    MIT
  • A
    license
    A
    quality
    A
    maintenance
    MCP server that lets coding agents test AI agents. Create YAML test cases, snapshot golden baselines, check for regressions, and generate visual reports all from inside Claude Code or any MCP-compatible tool. Works with LangGraph, CrewAI, OpenAI, Claude, Mistral, and any HTTP API.
    10
    29
    128
    Apache 2.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    Transforms single-attempt coding into a multi-attempt, test-validated refinement loop by running your actual test suite and feeding failures back to the LLM as structured directives.
    3

View all related MCP servers

Related MCP Connectors

  • Deterministic regex synthesis from labeled examples. Zero LLM, proof matrix, backtracking audit.

  • Proves AI-generated Python does what you asked: lint, types, security, sandbox run, exact fixes.

  • Deterministic validation for AI-generated artifacts: JSON Schema, OpenAPI response, SQL syntax.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zeelShah-12/verified-regex-generator'

If you have feedback or need assistance with the MCP directory API, please join our Discord server