Skip to main content
Glama

add_test_case

Add a test case to validate regex patterns by specifying an input string, expected matches, and groups to extract.

Instructions

Add a test case for regex pattern validation. Each test case consists of an input string and the expected match/output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_stringYesThe input string to test the regex pattern against
expected_matchesYesArray of substrings that should be matched/extracted by the regex
groupsYesThe groups that should be extracted by the regex. This is an array of numbers
descriptionNoOptional description of what this test case is checking for

Implementation Reference

  • Schema/registration of the add_test_case tool, defining its name, description, inputSchema (with properties input_string, expected_matches, groups, description) and required fields.
    types.Tool(
        name="add_test_case",
        description="Add a test case for regex pattern validation. Each test case consists of an input string and the expected match/output.",
        inputSchema={
            "type": "object",
            "properties": {
                "input_string": {
                    "type": "string",
                    "description": "The input string to test the regex pattern against"
                },
                "expected_matches": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    },
                    "description": "Array of substrings that should be matched/extracted by the regex"
                },
                "groups": {
                    "type": "array",
                    "items": {
                        "type": "number"
                    },
                    "description": "The groups that should be extracted by the regex. This is an array of numbers"
                },
                "description": {
                    "type": "string",
                    "description": "Optional description of what this test case is checking for"
                }
            },
            "required": ["input_string", "expected_matches", "groups"]
        }
  • Registration of all tools (including add_test_case) via the @server.list_tools() decorator, which returns the Tool definition for listing by the MCP client.
    @server.list_tools()
    async def handle_list_tools() -> List[types.Tool]:
        """List available tools for regex pattern testing."""
        return [
            types.Tool(
                name="add_test_case",
                description="Add a test case for regex pattern validation. Each test case consists of an input string and the expected match/output.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "input_string": {
                            "type": "string",
                            "description": "The input string to test the regex pattern against"
                        },
                        "expected_matches": {
                            "type": "array",
                            "items": {
                                "type": "string"
                            },
                            "description": "Array of substrings that should be matched/extracted by the regex"
                        },
                        "groups": {
                            "type": "array",
                            "items": {
                                "type": "number"
                            },
                            "description": "The groups that should be extracted by the regex. This is an array of numbers"
                        },
                        "description": {
                            "type": "string",
                            "description": "Optional description of what this test case is checking for"
                        }
                    },
                    "required": ["input_string", "expected_matches", "groups"]
                }
            ),
            types.Tool(
                name="test_regex",
                description="Test a regex pattern against all current test cases to see if it satisfies the requirements.",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "pattern": {
                            "type": "string",
                            "description": "The regex pattern to test"
                        },
                        "flags": {
                            "type": "string",
                            "description": "Optional regex flags (e.g., 'i' for case-insensitive, 'm' for multiline, 's' for dotall). Default is no flags.",
                            "default": ""
                        }
                    },
                    "required": ["pattern"]
                }
            ),
            types.Tool(
                name="get_test_cases",
                description="Get all current test cases to see what requirements the regex pattern needs to satisfy.",
                inputSchema={
                    "type": "object",
                    "properties": {},
                    "additionalProperties": False
                }
            ),
            types.Tool(
                name="clear_test_cases",
                description="Clear all test cases to start fresh with new requirements.",
                inputSchema={
                    "type": "object",
                    "properties": {},
                    "additionalProperties": False
                }
            )
        ]
  • Handler logic for add_test_case: extracts arguments, validates groups match expected_matches length, appends the test case to global list, and returns a confirmation message.
    if name == "add_test_case":
        input_string = arguments.get("input_string", "")
        expected_matches = arguments.get("expected_matches", [])
        groups = arguments.get("groups", [])
        description = arguments.get("description", "")
    
        if len(groups) != len(expected_matches):
            return [
                types.TextContent(
                    type="text",
                    text=f"Error: Invalid test case. Number of groups ({len(groups)}) does not match number of expected matches ({len(expected_matches)}). Perhaps, input string contains multiple matches?"
                )
            ]
    
        test_case = {
            "input_string": input_string,
            "expected_matches": expected_matches,
            "groups": groups,
            "description": description
        }
    
        test_cases.append(test_case)
    
        return [
            types.TextContent(
                type="text",
                text=f"Added test case:\n- Input: '{input_string}'\n- Expected matches: {expected_matches}\n- Groups: {groups}\n- Description: {description or 'None'}\n\nTotal test cases: {len(test_cases)}"
            )
        ]
  • Global storage list for test cases, used by add_test_case (appends) and other tools (reads/clears).
    test_cases: List[Dict[str, Any]] = []
Behavior2/5

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

With no annotations, the description fails to disclose any side effects, persistence, or constraints (e.g., does it overwrite? Are test cases stored?). Only states the basic action.

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 concise sentences with no fluff. The first sentence states the primary action and resource, the second provides the structure of a test case. Well front-loaded.

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?

Adequate for a simple add operation with well-defined parameters in the schema. However, lacks mention of return value or confirmation, and does not address potential constraints like duplicate test cases.

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

Parameters2/5

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

Schema description coverage is 100%, and the tool description adds minimal value beyond a summary. It repeats 'input string and expected match/output' but does not clarify groups parameter behavior or optional description.

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 clearly states the action (add a test case), the resource (regex pattern validation), and the components of a test case. It distinguishes from sibling tools (clear, get, test).

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 guidance on when to use this tool versus alternatives like clear_test_cases or test_regex. Missing context about prerequisites or typical workflow order.

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/PatzEdi/MCPGex'

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