Skip to main content
Glama
lisamaraventano-spine

Underground Cultural District MCP Server

test-regex

Test a regular expression pattern against any text to find matches, capture groups, and their positions. Validate regex quickly.

Instructions

Test a regular expression against text. Returns all matches with positions and capture groups.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
patternYesRegex pattern
textYesText to test
flagsNoRegex flags (default: g)g

Implementation Reference

  • The handler function that executes the test-regex tool logic. Creates a RegExp from the pattern and flags, uses matchAll() to find all matches, and formats them with positions and capture groups.
    function handleTestRegex(args) {
      const re = new RegExp(args.pattern, args.flags || "g");
      const matches = [...args.text.matchAll(re)];
      if (!matches.length) return "No matches found.";
      const lines = matches.map((m, i) => {
        let line = `Match ${i + 1}: "${m[0]}" at index ${m.index}`;
        if (m.length > 1) {
          line += "\n  Groups: " + m.slice(1).map((g, j) => `$${j + 1}="${g}"`).join(", ");
        }
        return line;
      });
      return `Found ${matches.length} match(es):\n\n${lines.join("\n")}`;
    }
  • Input schema definition for test-regex. Defines pattern (string), text (string), and optional flags (string, default 'g') as inputs.
    {
      name: "test-regex",
      description:
        "Test a regular expression against text. Returns all matches with positions and capture groups.",
      inputSchema: {
        type: "object",
        properties: {
          pattern: { type: "string", description: "Regex pattern" },
          text: { type: "string", description: "Text to test" },
          flags: {
            type: "string",
            description: "Regex flags (default: g)",
            default: "g",
          },
        },
        required: ["pattern", "text"],
      },
  • src/index.js:830-843 (registration)
    Registration of the test-regex tool in the HANDLERS map, mapping 'test-regex' to the handleTestRegex function.
      "test-regex": handleTestRegex,
      "build-cron": handleBuildCron,
      "convert-eth-units": handleConvertEthUnits,
      "validate-wallet": handleValidateWallet,
      "encode-url": handleEncodeUrl,
      "browse-underground": handleBrowse,
      "search-underground": handleSearch,
      "buy-from-underground": handleBuy,
      "get-free-content": handleGetFreeContent,
      "verify-receipt": handleVerifyReceipt,
      "agent-identity": handleAgentIdentity,
      "agent-mesh": handleAgentMesh,
      "pet-rock-lobster": handlePetRockLobster,
    };
Behavior3/5

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

No annotations provided, so description carries burden. Mentions return of matches, positions, and capture groups, but does not address error handling (e.g., invalid regex) or edge cases (e.g., no matches).

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?

Single sentence that is front-loaded with action and result. No unnecessary words; highly efficient.

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?

Given no output schema, description explains return value adequately. However, lacks mention of default flag behavior (though schema includes it) and error handling. Still fairly complete for a simple tool.

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 covers all parameters with descriptions (100% coverage). Description does not add significant meaning beyond schema, so baseline 3 applies.

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?

Clearly states the action ('Test a regular expression against text') and the result ('Returns all matches with positions and capture groups'). Distinct from sibling tools as no other regex tool exists.

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?

No explicit guidance on when to use or alternatives. Since no sibling tools overlap, the use case is implied, but lacks clarity on prerequisites or limitations.

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/lisamaraventano-spine/mcp-server'

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