regexguard
regexguard-mcp-server
あらゆるAIエージェントが、生成したばかりの正規表現を出荷する前に検証できるようにするMCPサーバーです。実際に何にマッチするか、そして信頼できない入力に対して実行しても安全かどうかを確認できます。完全にローカルで動作し、APIキーもネットワーク呼び出しも不要で、依存関係はMCP SDKとZodのみです。
なぜ必要か
正規表現は、たまたまテストしたすべての例で問題なく見えるバグを混入させやすいことで有名です。特に、目視では見逃しやすい一般的な障害モードが2つあります。
思っているものにマッチしない。
explain_regexはパターンを実際の構文木に変換し、平易な英語で説明します。そのため、「これには実際に数字が1つ以上必要か?」という疑問に対して、入れ子になった括弧を自分で読むことに頼らずに、素早く答えを得られます。サービス拒否のベクトルになる。 入れ子になった量指定子(
(a+)+)や、繰り返しグループ内の曖昧な選択((a|a)+)を含む正規表現は、バックトラッキングエンジンが巧妙に(あるいは偶然に)作られた非マッチ入力に対して指数関数的な時間を要する可能性があります。これはReDoSとして知られる、実際に繰り返し悪用されてきた脆弱性クラスであり、敵対的な入力をテストせずにエージェントが書いた正規表現にはあり得る欠陥です。check_redos_riskは、パターンを実行することなく構造的な形状をフラグ付けします。つまり、信頼できない、または意図的に悪意のある正規表現ソースに対して安全に実行できます。
Related MCP server: Regex Toolkit MCP Server
ツール
explain_regex
パターンをASTに解析し、何にマッチするかを平易な英語で説明します。
check_redos_risk
パターンの構造を静的に解析し、入れ子になった量指定子と、繰り返しグループ内の曖昧な選択(破滅的なバックトラッキングの2大原因)を検出します。"safe"、"high"、"critical" のいずれかを返し、見つかった各問題について具体的な所見を示します。
両方のツールは1つのパーサー(src/services/parser.ts)を共有しています。これは、リテラル、文字クラス、省略形クラス、アンカー、キャプチャ/非キャプチャ/名前付きグループ、先読み、選択、量指定子、後方参照を扱う本格的な再帰下降正規表現パーサーであり、パターンの生のソーステキストに対する文字列マッチングのヒューリスティックの集まりではありません。
これはヒューリスティックな構造チェックであり、正式な検証器ではありません。 check_redos_risk は、パターンが教科書的な指数爆発の形状を持っていることを示せますが、すべての入力で高速であることを証明することはできません。また、現在検出している2つの形状以外にもReDoSパターンは存在します。"safe" という結果は「明らかな問題は見つからなかった」という意味であり、保証ではありません。
インストールと設定
git clone https://github.com/wedo911/regexguard-mcp-server.git
cd regexguard-mcp-server
npm install
npm run buildMCPクライアントの設定に追加します(例: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.mjs44のテストが、パーサーの文法、説明出力、そして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 を参照してください。
Maintenance
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceRegexForge 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
- FlicenseAqualityCmaintenanceEnables LLM agents to extract, validate, and mask personally identifiable information using deterministic regular expressions, reducing token usage and hallucination risks.373
- AlicenseAqualityAmaintenanceEnables AI agents to parse, validate, explain, and preview cron expressions, surfacing common silent bugs before deployment.4108MIT
- AlicenseAqualityCmaintenanceProvides 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.9MIT
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.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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