Skip to main content
Glama

regexforge

ラベル付きの例から実用レベルの正規表現を合成するMCP(Model Context Protocol)サーバー。 サービス提供時にLLMを一切使用せず、テンプレートバンクに対する純粋な記号的合成と文字クラス推論のフォールバックを行います。すべてのレスポンスには、証明行列とバックトラッキングのリスク監査が含まれます。


MCPツール

regexforgeは単一のMCPツールを公開しています。AIクライアント(Claude Desktop、Cline、Continue、Cursor、またはMCP対応エージェント)は、他のMCPツールを呼び出すのと同様に、JSON-RPC 2.0経由で tools/call を呼び出します。

regexforge_synth

ラベル付きの例から、実戦で検証済みの正規表現を合成します。

入力スキーマ (モデルが提供するもの):

{
  "type": "object",
  "required": ["examples"],
  "properties": {
    "description": {
      "type": "string",
      "description": "Optional natural-language description of the target pattern. Used only for tie-breaking when multiple templates fit."
    },
    "examples": {
      "type": "array",
      "minItems": 2,
      "maxItems": 100,
      "items": {
        "type": "object",
        "required": ["text", "match"],
        "properties": {
          "text":  { "type": "string", "maxLength": 2048 },
          "match": { "type": "boolean", "description": "true if the regex should match this string; false if it should NOT match." }
        }
      }
    }
  }
}

出力スキーマ:

{
  "regex": "string",
  "flags": "string",
  "source": "template | char_class",
  "template_name": "string (if source=template)",
  "test_matrix": [
    { "text": "string", "expected": "boolean", "actual": "boolean", "pass": "boolean" }
  ],
  "all_pass": "boolean",
  "backtrack_risk": "none | low | high",
  "backtrack_reasons": [ "string" ],
  "candidates_considered": "integer",
  "candidates_passing": "integer",
  "notes": [ "string" ]
}

エラーが発生した場合は、構造化された修正案を含むJSON-RPCエラーオブジェクトが返されます:

  • not_expressible (HTTP 422) — 例が非正規言語(括弧の対応、カウントなど)であることを示唆している場合。

  • no_credits (HTTP 402) — ウォレットが空の場合。/v1/credits から購入してください。

  • missing_input (HTTP 400) — fix フィールドに何が不足しているかが正確に示されます。


MCPクライアントからの接続

Claude Desktop

~/Library/Application Support/Claude/claude_desktop_config.json (macOS) または %APPDATA%\Claude\claude_desktop_config.json (Windows) に以下を追加します:

{
  "mcpServers": {
    "regexforge": {
      "transport": {
        "type": "http",
        "url": "https://regexforge.jason-12c.workers.dev/mcp"
      },
      "headers": {
        "Authorization": "Bearer YOUR_API_KEY_HERE"
      }
    }
  }
}

APIキーの取得: curl -X POST https://regexforge.jason-12c.workers.dev/v1/keys (無料、サインアップ時に50クレジット付与)。

Python (公式 mcp SDK)

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async def main():
    url = "https://regexforge.jason-12c.workers.dev/mcp"
    headers = {"Authorization": "Bearer YOUR_API_KEY"}
    async with streamablehttp_client(url, headers=headers) as (read, write, _):
        async with ClientSession(read, write) as session:
            await session.initialize()
            tools = await session.list_tools()
            result = await session.call_tool(
                "regexforge_synth",
                arguments={
                    "description": "ISO 8601 date like 2024-12-30",
                    "examples": [
                        {"text": "2024-12-30", "match": True},
                        {"text": "2023-01-01", "match": True},
                        {"text": "12/30/2024", "match": False},
                        {"text": "abc",        "match": False},
                    ],
                },
            )
            print(result.content[0].text)

TypeScript (公式 @modelcontextprotocol/sdk)

import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";

const transport = new StreamableHTTPClientTransport(
  new URL("https://regexforge.jason-12c.workers.dev/mcp"),
  { requestInit: { headers: { Authorization: "Bearer YOUR_API_KEY" } } }
);
const client = new Client({ name: "demo", version: "1.0.0" }, { capabilities: {} });
await client.connect(transport);

const res = await client.callTool({
  name: "regexforge_synth",
  arguments: {
    description: "ethereum wallet address",
    examples: [
      { text: "0x8ABCE477e22B76121f04c6c6a69eE2e6a12De53e", match: true },
      { text: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", match: true },
      { text: "0x123", match: false },
      { text: "xyz",   match: false },
    ],
  },
});
console.log(res.content[0].text);

Raw JSON-RPC over HTTP

プロトコルを直接操作したい場合:

# 1. initialize
curl -X POST https://regexforge.jason-12c.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize"}'

# 2. list tools
curl -X POST https://regexforge.jason-12c.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"jsonrpc":"2.0","id":2,"method":"tools/list"}'

# 3. call the tool
curl -X POST https://regexforge.jason-12c.workers.dev/mcp \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_KEY" \
  -d '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"regexforge_synth","arguments":{"examples":[{"text":"2024-12-30","match":true},{"text":"abc","match":false}]}}}'

内部の仕組み

  1. テンプレートバンクマッチング — 約65個の事前コンパイル済みで実戦検証済みの正規表現テンプレート(メール、UUID v4、ISO日付、セマンティックバージョニング、ETHアドレス、米国電話番号、SHA-256、base64、米国郵便番号、MACアドレスなど)をすべての例に対してテストします。すべての例を正しく分類できるテンプレートが候補となります。

  2. タイブレーク — 複数のテンプレートが合格した場合、呼び出し元の description に最もキーワードが一致するものを選択し、さらに同点の場合はパターン長で決定します。

  3. 文字クラス推論のフォールバック — 適合するテンプレートがない場合、肯定的な例から最長共通接頭辞と接尾辞を抽出し、中間部分を長さ制限付きの文字クラスの和集合 [a-z0-9-]{n,m} として推論し、合成されたパターンがすべての否定的な例を拒否することを確認します。

  4. 証明付きの返却 — レスポンスには完全な test_matrix が含まれており、呼び出し元(モデル)はコードで正規表現を使用する前に、すべての例が正しく分類されることを検証できます。

  5. バックトラッキング監査 — 返された正規表現に対して静的解析を行い、壊滅的なバックトラッキングを引き起こす可能性のあるネストされた量指定子、後方参照、先読み/後読みをフラグ立てします。

すべて決定論的です。サービス提供時にLLMの呼び出しは発生しません。典型的なレイテンシは100ms未満です。


エージェントのワークフロー例

ユーザーが入力した文字列を解析する必要があるコードを書くAIエージェントは、正規表現自体を生成する(弱いモデルでは頻繁に間違える)代わりに regexforge_synth を呼び出します:

モデルの思考: 「このSKU-1234-ABパターンを解析する必要がある。正規表現をハルシネーションさせないようにしよう。」

呼び出し: regexforge_synth({ description: "SKU like SKU-1234-AB", examples: [<3つの肯定例, 5つの否定例>] })

返却: { regex: "^SKU-[-0-9A-Z]{7}$", all_pass: true, backtrack_risk: "none", source: "char_class" }

すべての既知の例が正しく分類されるという確信を持って、"^SKU-[-0-9A-Z]{7}$" をコードに貼り付けます。

これは、(a) LLMが正規表現を書く、(b) LLMがテストケースを書く、(c) LLMが正規表現の実行をシミュレートする、(d) LLMが再考して書き直す…といった、トークンを10倍消費し、それでも間違える可能性のあるプロセスを、単一のツール呼び出しに置き換えるものです。


認証と料金

  • プログラムによるキー発行: POST /v1/keys{ key, credits: 50 }。メール不要。CAPTCHA不要。エージェントが自身で発行します。

  • 1回あたりのコスト: $0.002。パック: スターター ($5 / 2,500回)、スケール ($50 / 30,000回)、バルク ($500 / 350,000回)。

  • 支払い (エージェント自律型): POST /v1/credits { "pack": "starter" } は実際のStripe Checkout URL + x402 USDC-on-Baseヘッダーを返します。支払いを完了し、POST /v1/credits/verify { "session_id": "cs_..." } を実行するとキーにクレジットがチャージされます。

  • すべてのエラーレスポンスには、エージェントに何を修正すべきかを正確に伝える構造化された fix フィールドが含まれています。


その他の発見用インターフェース (エージェント専用、機械可読)

エンドポイント

フォーマット

GET /.well-known/ai-plugin.json

OpenAIプラグインマニフェスト

GET /.well-known/mcp.json

MCPサーバーマニフェスト (ツール + トランスポート)

GET /llms.txt

llms.txt 標準

GET /openapi.json

OpenAPI 3.1

GET /v1/pricing

機械可読な価格表

GET /v1/errors

完全なエラーコードカタログ

GET /

上記すべてのルートインデックス


実装

  • トランスポート: HTTPストリーミング可能 (MCP仕様 2024-11-05)、JSON-RPC 2.0

  • デプロイ: Cloudflare Workers (コールドスタート <10ms)

  • 基盤: @walko/agent-microsaas — MCPトランスポート、発見マニフェスト、ベアラーキー認証、クレジット台帳を処理するスケルトン。regexforge自体は約300行の純粋な合成ロジックです。

ライセンス

Apache-2.0。

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

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

Related MCP Connectors

  • Deterministic JSON repair, validate, example-gen, schema-coerce for agents. Zero LLM, sub-10ms.

  • The WAF for agents. Pattern-based + heuristic firewall scans prompts, RAG documents, tool argume...

  • JSON/YAML, regex, diff, JWT, SQL dialects — the keyless millisecond ops an agent needs mid-task.

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/walkojas-boop/regexforge'

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