Skip to main content
Glama

Test a regular expression

test_regex
Read-only

Run a JavaScript (ECMAScript) regular expression against text. Returns the match count and, for each match, the matched text, its 0-based index, numbered capture groups and named groups. Returns 'No matches.' when nothing matches. All matches are listed (the g flag is added automatically), up to 200. Invalid patterns or flags return an error explaining why; patterns that run longer than 0.5 seconds are stopped with an error. Text up to 100 KB.

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>",
      "text": "<text>"
    },
    "name": "test_regex"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesThe text to search
flagsNoAny of d, g, i, m, s, u, v, y; for example gi for case-insensitiveg
patternYesThe pattern without surrounding slashes, for example (\d+)-(?<unit>[a-z]+)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed3 schema fields changed
    • changedInput schema / properties / flags / description
      Previous value: -"JavaScript flags such as gi"New value: +"Any of d, g, i, m, s, u, v, y; for example gi for case-insensitive"
    • changedInput schema / properties / pattern / description
      Previous value: -"Pattern without slashes"New value: +"The pattern without surrounding slashes, for example (\\d+)-(?<unit>[a-z]+)"
    • addedInput schema / properties / text / description
      Added value: +"The text to search"
  2. First observed

TDQS

A4.7/5.0
Behavior5/5

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

Beyond the readOnly/destructive/openWorld annotations, the description discloses substantial behavior: automatic addition of the g flag, a 200-match ceiling, a 100 KB text limit, a 0.5-second execution timeout, and error behavior for invalid patterns or flags. It also specifies the exact return shape, including match count, index, numbered and named groups, and the 'No matches.' response.

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

Conciseness5/5

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

The description is front-loaded with the primary action, then moves through return shape, limits, and error cases in a compact sequence. Every sentence carries information an agent needs, with no filler or repetition.

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?

There is no output schema, so the description must explain return values, and it does so thoroughly: match count, matched text, 0-based index, numbered groups, named groups, and the no-match sentinel. Combined with the limits and timeout behavior, an agent has everything needed to call the tool correctly and interpret its output.

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 the baseline would be 3, but the description adds meaningful semantics for the flags parameter: the g flag is added automatically regardless of what the caller supplies. That changes how an agent should reason about the flags argument in a way the schema does not make explicit.

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?

The description opens with a specific verb and resource: 'Run a JavaScript (ECMAScript) regular expression against text.' That is unambiguous and distinct from utility siblings such as base64, hash_text, or count_words, which perform unrelated transformations.

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?

The context for use is clear from the opening sentence, and there is no obvious sibling alternative that performs regex matching. However, the description never explicitly states when to prefer this tool or when another approach is more appropriate, so it stops short of full when/when-not guidance.

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.