Skip to main content
Glama

Run a regular expression on test strings (JavaScript or RE2/Go) and check it for ReDoS

sieve_test_regex
Read-onlyIdempotent

Use when you have written, been given or are about to commit a regular expression and need to know what it really matches, instead of predicting it (signals: "write a regex for", "does this regex match", "validate emails/phone numbers/dates/slugs/URLs with a regex", "why doesn't my regex match", "test this pattern", "regex for Go", "is this regex safe", "catastrophic backtracking", "convert this Python regex to JavaScript"). Executes the pattern on the real engine: JavaScript (V8 RegExp, the engine in Chrome, Node.js and Cloudflare Workers; flags d g i m s u v y) or RE2 (re2js, with Go regexp parity: Go, RE2, Google Sheets and BigQuery syntax; flags i m s). Give strings that must match and strings that must not; each case comes back pass/fail with the matched text, index and capture groups (numbered and named), and why a "should not match" string matched (usually a missing ^...$). match: "full" tests the whole string. texts lists every match, replace_with shows the replacement ($1/$ in JavaScript, $1/${name} in Go). For JavaScript it also runs a ReDoS analysis (recheck): proven linear, or exponential/polynomial backtracking with a concrete attack string and the hot part of the pattern. Flags patterns that compile but mislead: ^a|b$ anchoring, \A/\Z/\h read as letters, [[:alpha:]], {,3}, [A-z], unescaped dots before extensions. Invalid patterns return the engine's error and a hint (Python (?P), (?i), possessive and atomic groups; lookarounds and backreferences in RE2). Example: {"pattern":"[\w.+-]+@[\w-]+\.[a-z]{2,}","should_match":["ann@example.com"],"should_not_match":["ann@example","see ann@x.io now"]}. Does not run Python, PCRE, Java or .NET engines; it reports what differs for common constructs. Up to 100 strings of 20000 characters; on a ReDoS-vulnerable pattern, long strings are skipped instead of hanging. Returns {valid, verdict: ok|warnings|redos|fails|invalid, summary, engine, engine_name, pattern, flags, match_mode, counts:{should_match, should_not_match, texts, passed, failed, skipped}, group_count, cases:[{text, length, expect: match|no_match|any, matched, pass (null = skipped), match_count, match:{text, index, end, groups?, named?}, matches? (texts only), why?, replaced?, skipped?}], warnings:[{rule, message, fix?, index?}], redos:{status: safe|vulnerable|unknown, complexity: linear|polynomial (degree n)|exponential|no attack found|unknown, attack?:{repr, length, string|null, sample}, hotspots?:[{start, end, text}], explanation?, fix_hint?, note?}|null, fix_message (ready-to-apply list, null when clean), error? and hint? (invalid patterns), notes, checked_at, open_url}.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "pattern": "<pattern>"
    },
    "name": "sieve_test_regex"
  }
}

Input Schema

NameRequiredDescriptionDefault
flagsNoJavaScript: any of d g i m s u v y. RE2: i m s. Default none.
matchNo"search" (default): a match anywhere counts, like RegExp.test, re.search or Go MatchString. "full": the whole string must match, like Python re.fullmatch.
textsNoStrings to search; every match is listed with its groups (no pass/fail).
engineNo"javascript" (default; also TypeScript, Node.js, browsers, Deno, Bun) or "re2" (Go regexp, RE2, Google Sheets REGEXMATCH, BigQuery).
patternYesThe regex source, e.g. "^\\d{4}-\\d{2}$" (JSON-escaped), or a JavaScript literal "/^\\d+$/i" (flags then come from the literal).
check_redosNoRun the ReDoS analysis (JavaScript engine). Default true.
max_matchesNoMost matches listed per text (default 10). match_count is always the full count.
replace_withNoOptional replacement; each case also returns the string with every match replaced.
should_matchNoStrings the pattern must match (in match mode).
should_not_matchNoStrings the pattern must not match.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A4.3/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover readOnly/idempotent/non-destructive/closed-world, yet the description still adds real behavior: engine limits (100 strings of 20000 chars), that long strings are skipped rather than hanging on a vulnerable pattern, engine-specific error hints, and the verdict taxonomy. The one thing not spelled out is how expensive a call is in the worst case, but the skip behavior largely covers that concern.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The trigger sentence is correctly front-loaded and almost every sentence carries information, but the body is a single dense run-on paragraph mixing engine support, return shape, warnings, ReDoS output, and limits. With no output schema the return-value detail is justified, yet it would read far better as structured sections rather than one block.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 10-parameter tool with no output schema, the description documents the full return shape (verdict, counts, per-case fields, warnings, redos block, fix_message, error/hint) and the failure modes. An agent has everything needed to call it and interpret results.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so 3 is the baseline, but the description goes beyond it: it clarifies match:'full' means the whole string must match, that texts lists every match rather than pass/fail, and that replacement syntax differs by engine ($1/$<name> in JavaScript vs $1/${name} in Go). Flags per engine are already in the schema, so the gain is incremental rather than comprehensive.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a concrete verb and resource — executes a regex against supplied strings on a named engine (V8 JavaScript or RE2/Go) and additionally runs a ReDoS analysis. An agent can tell this apart from a pure ReDoS checker or a CORS/DNS sibling without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Opens with an explicit trigger ('when you have written, been given or are about to commit a regular expression') plus a list of concrete user signals, and closes with an exclusion ('Does not run Python, PCRE, Java or .NET engines'). It stops short of routing to the sibling sieve_check_redos when ReDoS is the only concern, so the alternative-selection guidance is implied rather than stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

Resources