Skip to main content
Glama
paladini

devutils-mcp-server

regex_test

Test regular expression patterns against input strings to validate matches, extract groups, and identify positions within text for debugging and development.

Instructions

Test a regular expression pattern against an input string. Returns all matches with groups and indices.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesThe regex pattern (without delimiters)
flagsNoRegex flags (default: 'g')g
inputYesThe string to test against

Implementation Reference

  • Implementation of the regex_test tool, which tests a regular expression against a string.
    server.tool(
      "regex_test",
      "Test a regular expression pattern against an input string. Returns all matches with groups and indices.",
      {
        pattern: z.string().describe("The regex pattern (without delimiters)"),
        flags: z
          .string()
          .default("g")
          .describe("Regex flags (default: 'g')"),
        input: z.string().describe("The string to test against"),
      },
      async ({ pattern, flags, input }) => {
        try {
          const regex = new RegExp(pattern, flags);
          const matches: Array<{
            match: string;
            index: number;
            groups: Record<string, string> | null;
          }> = [];
    
          let m;
          if (flags.includes("g")) {
            while ((m = regex.exec(input)) !== null) {
              matches.push({
                match: m[0],
                index: m.index,
                groups: m.groups ? { ...m.groups } : null,
              });
              if (matches.length > 100) break; // Safety limit
            }
          } else {
            m = regex.exec(input);
            if (m) {
              matches.push({
                match: m[0],
                index: m.index,
                groups: m.groups ? { ...m.groups } : null,
              });
            }
          }
    
          const result = {
            pattern,
            flags,
            input_length: input.length,
            matches_found: matches.length,
            matches,
          };
    
          return {
            content: [
              { type: "text" as const, text: JSON.stringify(result, null, 2) },
            ],
          };
        } catch (e) {
          return {
            content: [
              {
                type: "text" as const,
                text: `Error: Invalid regex — ${e instanceof Error ? e.message : String(e)}`,
              },
            ],
            isError: true,
          };
        }
      }
    );
Behavior3/5

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

No annotations provided, so description carries full disclosure burden. Mentions return format ('all matches with groups and indices') but omits critical behavioral details: error handling on invalid patterns, regex engine flavor (PCRE/JS/etc.), maximum input limits, or safety characteristics (read-only nature).

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, zero waste. First sentence defines the operation, second the return value. Appropriately front-loaded with the action verb.

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 a 3-parameter utility without output schema, description adequately explains the return structure (matches/groups/indices) and schema covers inputs completely. However, lacks essential behavioral contract details (error states, regex validation) expected when no annotations are present.

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 100% with complete parameter descriptions (including crucial 'without delimiters' note for pattern). Description adds minimal parameter-specific semantics beyond schema baseline, though 'groups and indices' hints at how capture groups in the pattern parameter will be returned.

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?

Clear specific verb ('Test') + resource ('regular expression pattern'), explicitly distinguishes from siblings (encoding, hashing, and conversion utilities) by describing unique regex matching functionality.

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

Usage Guidelines2/5

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

No explicit when-to-use or when-not-to-use guidance, and no mention of alternatives (e.g., simple string searching vs. regex). Solely relies on user inferring appropriate context from the word 'regex'.

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

Install Server

Other Tools

Latest Blog Posts

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/paladini/devutils-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server