Skip to main content
Glama

regex

Read-only

Test a JavaScript regex against text or files to get matches with line/column, groups, and replace previews. Returns full, partial, or no-match cases and times out runaway backtracking.

Instructions

Test a JS regex (/x/flags ok): matches with line/col and groups, replace preview, cases (full/partial/none). Timeout catches catastrophic backtracking.

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

Input Schema

NameRequiredDescriptionDefault
pathNoor a file
textNo
casesNo
flagsNo
patternYes
replaceNo
timeout_msNo
max_matchesNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.4.2

TDQS

B3.4/5.0
Behavior3/5

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

The readOnlyHint annotation already establishes this is a safe, non-mutating operation, so the description needn't carry the safety burden. It does add genuinely useful behavior beyond annotations – line/col and group reporting, per-case outcome classification, and the fact that a timeout guards against catastrophic backtracking. It omits error handling for invalid patterns and whether a timed-out run returns partial matches.

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

Conciseness4/5

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

A single tight sentence with the core capability front-loaded and the mode list packed into parenthetical clauses. Nothing is padding, though the compression is heavy enough that some clauses (e.g. "cases (full/partial/none)") take a moment to parse.

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

Completeness3/5

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

For an 8-parameter tool with no output schema, the description does well to describe the shape of results (matches, groups, line/col, replace preview). However, it leaves the text-vs-path input choice, matching limits, and failure modes unexplained, so an agent could still call it incorrectly.

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 coverage is only 13% across 8 parameters, so the description has to compensate, and it does partially: it clarifies the pattern format (/x/flags), the role of flags, cases, replace preview, and timeout_ms. It says nothing about text vs path precedence, max_matches, or any defaults, leaving several parameters undocumented in both places.

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?

The description states a concrete verb and resource ("test a JS regex") and enumerates the outputs an agent gets back: matches with line/col and groups, replace preview, and per-case full/partial/none results. It's specific enough to distinguish this from siblings like extract or diff, though it never names an alternative explicitly.

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?

Usage is implied by the listed capabilities: use it to validate a pattern against text/cases, preview replacements, or probe for backtracking via timeout. There is no explicit when-to-use vs when-not guidance, no statement of prerequisites, and no routing to a sibling tool for related tasks.

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