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);

HTTP를 통한 원시 JSON-RPC

프로토콜을 직접 사용하려는 경우:

# 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 날짜, semver, 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-1234-AB와 같은 SKU", 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 }. 이메일 없음. 캡차 없음. 에이전트가 직접 생성.

  • 호출당 비용: $0.002. 패키지: 스타터($5 / 2,500), 스케일($50 / 30k), 벌크($500 / 350k).

  • 결제 (에이전트 자율): POST /v1/credits { "pack": "starter" }는 실제 Stripe 결제 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.

-
security - not tested
F
license - not found
-
quality - not tested

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

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

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