Skip to main content
Glama

Test a regular expression

regex_test
Read-onlyIdempotent

Run a JavaScript regular expression against text and return all matches with index, capture groups and named groups, or the replaced text. Confirms a regex works before you rely on it.

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": "regex_test"
  }
}

Input Schema

NameRequiredDescriptionDefault
textYesText to search
flagsNoFlags, e.g. gi
patternYesJavaScript regex pattern (no slashes)
replaceNoOptional replacement string ($1 etc.)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observed

TDQS

A3.8/5.0
Behavior4/5

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

Annotations already declare readOnlyHint=true, idempotentHint=true and openWorldHint=false, so the safety profile is covered. The description adds genuinely new behavioral context: it discloses what the return value contains (all matches with index and both capture group forms) and that supplying a replacement changes the output to replaced text — not something the annotations or the bare schema convey.

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?

Two sentences, both front-loaded: the capability and its return format come first, the rationale second. No filler, no repetition of the schema, and nothing a reader would need to skip.

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

Completeness4/5

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

For a 4-parameter tool with no output schema, the description usefully covers the return contract (match entries with index/captures vs. replaced text), which is the main missing structured information. It stops short of describing edge cases such as no-match behavior or invalid-pattern errors, which an agent would benefit from knowing since no output schema exists to reveal them.

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

Parameters3/5

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

Schema description coverage is 100%, so every parameter (pattern, text, flags, replace) is already documented in the input schema, which sets the baseline at 3. The description adds only marginal meaning beyond that — chiefly that `replace` switches the output from a match list to substituted text — and does not, for instance, explain the "$1 etc." backreference convention or flag syntax further.

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

Purpose4/5

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

"Run a JavaScript regular expression against text and return all matches" names a specific verb (run/test) and resource (regex against text), and the second clause spells out the return shape: index, capture groups, named groups, or replaced text. It is unambiguous on its own; the only small gap is that it does not explicitly position itself against the string/utility siblings, though none of them overlap in behavior.

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

Usage Guidelines3/5

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

"Confirms a regex works before you rely on it" gives a real usage context for the match path, and the mention of replaced text implies the substitution-testing path. However, there is no explicit when-not guidance, no statement about which alternative tools to use for other text tasks (e.g. text_diff or slugify), and no note on when to prefer this over simply embedding a regex in another tool.

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