Skip to main content
Glama
wedo911

regexguard

regexguard-mcp-server

Glama score

모든 AI 에이전트가 방금 생성한 정규식을 배포 전에 검증할 수 있게 해주는 MCP 서버입니다. 정규식이 실제로 무엇과 매칭되는지, 그리고 신뢰할 수 없는 입력에 대해 실행해도 안전한지 여부를 모두 확인할 수 있습니다. 완전히 로컬에서 동작합니다: API 키가 필요 없고, 네트워크 호출도 없으며, MCP SDK와 Zod 외에는 의존성이 없습니다.

정규식은 우연히 테스트한 모든 예제에서는 멀쩡해 보이는 버그가 유입되기로 악명 높은 영역입니다. 특히 다음 두 가지 실패 모드는 흔하면서도 눈으로 놓치기 쉽습니다:

  1. 생각한 대로 매칭되지 않습니다. explain_regex는 패턴을 실제 구문 트리로 변환하고 평이한 언어로 설명하므로, "이 패턴이 실제로 숫자를 하나 이상 요구하나요?"라는 질문에 중첩된 괄호를 직접 읽고 판단하지 않아도 되는 빠른 답을 얻을 수 있습니다.

  2. 서비스 거부(denial-of-service) 벡터입니다. 중첩된 수량자((a+)+)나 반복 그룹 내부의 모호한 선택((a|a)+)이 있는 정규식은 백트래킹 엔진이 악의적으로 만들어진(또는 우연한) 매칭 실패 입력에 대해 지수적 시간을 소요하게 만들 수 있습니다. 이것은 ReDoS로, 실존하며 반복적으로 악용되어 온 취약점 클래스이고, 에이전트가 적대적 입력에 대해 테스트하지 않고 작성한 정규식에서 나타날 수 있는 그럴듯한 결함입니다. check_redos_risk패턴을 실행하지 않고도 구조적 형태를 감지하므로, 신뢰할 수 없거나 의도적으로 악의적인 정규식 소스에 대해 실행해도 안전합니다.

Related MCP server: Regex Toolkit MCP Server

도구

explain_regex

패턴을 AST로 파싱하고 무엇과 매칭되는지에 대한 평이한 언어 설명을 반환합니다.

check_redos_risk

패턴의 구조에서 중첩된 수량자와 반복 그룹 내부의 모호한 선택(파국적 백트래킹의 두 가지 전형적인 원인)을 정적으로 분석합니다. 발견된 각 문제에 대한 구체적인 근거와 함께 "safe", "high", 또는 "critical"을 반환합니다.

두 도구 모두 하나의 파서(src/services/parser.ts)를 공유합니다. 이는 패턴의 원본 소스 텍스트에 문자열 매칭 휴리스틱을 적용하는 방식이 아니라 실제 재귀 하강(recursive-descent) 정규식 파서입니다(리터럴, 문자 클래스, 축약 클래스, 앵커, 캡처/비캡처/명명된 그룹, 전후방 탐색(lookaround), 선택, 수량자, 역참조).

이 검사는 형식 검증기가 아니라 휴리스틱 구조 검사입니다. check_redos_risk는 패턴이 교과서적인 지수 폭발 형태를 가졌는지 알려줄 수 있지만, 패턴이 모든 입력에서 빠르게 동작한다는 것을 증명할 수는 없으며, 현재 감지하는 두 가지 형태 밖의 ReDoS 패턴도 존재합니다. "safe" 결과는 "뚜렷한 문제가 없음"으로 취급하되, 보장으로 받아들이지 마세요.

설치 및 구성

git clone https://github.com/wedo911/regexguard-mcp-server.git
cd regexguard-mcp-server
npm install
npm run build

MCP 클라이언트의 설정에 추가하세요(예: claude_desktop_config.json, 또는 Claude Code의 프로젝트 .mcp.json):

{
  "mcpServers": {
    "regexguard": {
      "command": "node",
      "args": ["/absolute/path/to/regexguard-mcp-server/dist/index.js"]
    }
  }
}

테스트 실행

npm run build
node --test tests/parser.test.mjs tests/explain.test.mjs tests/redosCheck.test.mjs

44개의 테스트가 파서 문법, 설명 출력, 그리고 ReDoS 검사의 참긍정((a+)+, (a*)*, (a|a)+, (a|ab)+, 비캡처 그룹 내부에 중첩된 패턴)과 참부정((cat|dog)+, 현실적인 사용자 이름 패턴, 현실적인 이메일 패턴, 중첩이 아닌 형제 관계의 반복)을 모두 다룹니다. 따라서 일반적인 패턴에 대한 오탐률은 막연한 기대가 아니라 테스트로 검증된 속성입니다.

클라이언트 없이 사용해 보기

npx @modelcontextprotocol/inspector --cli node dist/index.js \
  --method tools/call --tool-name check_redos_risk \
  --tool-arg pattern='^(([a-zA-Z0-9])+([\.-]?([a-zA-Z0-9])+)*)$'

라이선스

MIT — LICENSE를 참조하세요.

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

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

Related MCP Servers

  • F
    license
    Not graded
    quality
    C
    maintenance
    RegexForge gives AI agents a reliable way to get a regex without asking an LLM to hallucinate one. Pass in labeled examples (strings that should match, strings that shouldn't) plus an optional description; get back the regex, a proof matrix showing it handles every example, and a backtracking-risk audit flagging catastrophic-backtracking patterns. Pure symbolic synthesis over a template bank with
  • F
    license
    A
    quality
    C
    maintenance
    Enables LLM agents to extract, validate, and mask personally identifiable information using deterministic regular expressions, reducing token usage and hallucination risks.
    3
    7
    3
  • A
    license
    A
    quality
    C
    maintenance
    Provides tools to test regex patterns for correctness, performance (ReDoS), and memory usage, and suggests safe rewrites. Enables LLMs to iterate on regex generation with verifiable feedback.
    9
    MIT

View all related MCP servers

Related MCP Connectors

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

  • Zero-config MCP security scanner for AI-generated apps. 25K+ vulnerability patterns.

  • Pay-per-call cybersecurity for AI agents: vuln scans, threat intel, compliance, code security.

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/wedo911/regexguard-mcp-server'

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