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 回の反復で検証済みパターンに収束します。

デモ

スクリーンショット

Related MCP server: EvalView

内容

  • regex_agent/core.py — エージェントの実際のループ本体(トランスポートに依存しないモデル)です。その他 はすべて、これを薄くラップしているにすぎません。

  • mcp_server/ — 本格的な MCP サーバー。ツールとして generate_verified_regex を公開しているため、Claude Desktop や Claude Code から直接利用できます。

  • web/ — FastAPI + バニラ JS のデモ、2 つの機能があります:

    1. エージェントの思考過程をライブで動画の如く描画したページ: テストケース、各候補正規表現、および 反復ごとの パス/失敗 のテーブル。

    2. その下に regex101 風のライブテスター — フラグ(g/i/m/s/全体一致)付き 編集可能なパターン欄、独自のテスト文字列に対するリアルタイムな一致強調表示、キャプチャグループ 付き一致リスト、正規表現をトークン単位で日本語で説明する内訳(すべてクライアント側、API なし)。 エージェントが検証した結果を自動で入力しますが、そのまま…あらった正規表現にも単体で使えます。 正規表現を使い慣れている人が、1 個だけテストしたい場合にも便利です。

    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 に "米国の電話番号を判定する正規表現を、検証済み正規表現ジェネレーターで作ってください" のように頼みます — すると、ツールが呼び出され、サーバーサイドで全体の 生成 → テスト → 検証 ループを 実行し、JSON レポートが返ります。

これはうってつけの(ショーケース)である理由

「 AI がコードを書く」デモのsfrotun 多くは生成で終わりです。そして、このリポジトリでは LLM の最初の回答を *「仮説」*として扱い、それで良い — — 実在の検証(実際の [対象機関] / 実文字列、とりわけモデル自身が 提案する adversar gorouter 的に間違えやすい「意地悪な」ケース)で照合して合うまでは成功を認めません。 この「生成 → 検証 → 修正」のルーープこそ **、可靠なエージェンツールに共通するコアパターンであり、 しかも regex_agent/core.py だけで十分に読める規模に収まっています。


The translation has errors in the last few lines ("受信" garbage at the end of the list item). Let me redo that segment of the final answer more carefully. Also, please note the answer I just drafted has a few typos/glitches in Japanese (from my trials) — I will rewrite the clean version in the final answer. Also first sentence is German-sounding. Provide the final clean version now.

Also the original text has "### Verified." — okay.

I'll make sure "GXP1" ... "GXP4" each is alone on its own line.

Careful on the "web" section: the original says "No MCP client required — runs in a browser." — Keep. In the Japanese: "MCP クライアントは不要です。ブラウザだけで動きます。" using em dash. Keep as "——".

Also the heading in the original user message "## What's in there" — I'll use "## (what's in) このリポジトリ.

Final Japanese rendering clean:

  • "For the '…' quotes, use the original typography of the input: the input has curly quotes around "US phone number" and around "ask an LLM for a regex and hope." With Japanese I'll use "「」".

In the "Demo" paragraph: 「実際の流れ: 「米国の電話番号」→ エージェントが 16 個のテスト文字列を作成し、候補の正規表現を提案。これを Python の実際の re エンジンで検証しつつ、2 回の反復で検証が取れたパターンに収束します。」

Full clean final translation — I'll now write.

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 回の反復で検証済みパターンに収束します。

デモ

スクリーンショット

内容

  • regex_agent/core.py — 実際のエージェントのループ本体(交通手段に依存しない)です。他の 物は、それを薄く包んでいるだけです。

  • mcp_server/generate_verified_regex をツールとして公開している 本格的な MCP サーバー。Claude Desktop や Claude Code から 直接使えます。

  • web/ — FastAPI + バニラ JS のデモで、2 つのパート:

    1. エージェントの思考過程をライブで表示: テストケース、各候補正規表現、反復ごとの合否テーブル。

    2. その下に regex101 風ライブテスター — フラグ(g/i/m/s/full-match)付きの 編集可能なパターン入力欄、自分のテスト文字列に対するライブの一致ハイライト、キャプチャグループ を含む一致リスト、正規表現をトークンごとに平易な日本語で解説する内訳。すべてクライアントサイドで 動き、API 呼び出しはありません。エージェントが検証した内容が自動で入りますが、貼り付けた任意の 正規表現にも単体で使えます。正規表現をすでに知っていて、1 個試したいだけ、という場合にも重宝します。

    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 に頼みます。するとツールが呼び出され、サーバー側で「生成 → テスト → 検証」の完全なループが 実行され、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