Skip to main content
Glama
uarlouski

TestRail MCP Server

update_cases

Bulk update multiple test cases with the same field values. Use valid field names from get_case_fields to specify updates.

Instructions

Bulk update multiple test cases with the same field values. The update operation requires knowing valid field names that are returned by get_case_fields tool. More efficient than calling update_case multiple times.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
case_idsYesArray of case IDs to update (e.g. [123, 456, 789])
fieldsYes Must use system_name values from get_case_fields. Call get_case_fields with project_id first if field names are not already known. Using an unknown field name (e.g. 'label_ids') will result in an error. Example: {"priority_id": 2, "template_id": 1, "labels": [1, 2]}

Implementation Reference

  • The updateCasesTool handler function that takes case_ids and fields, validates them, and calls client.updateCases to bulk-update test cases via TestRail API.
    export const updateCasesTool: ToolDefinition<typeof parameters, TestRailClient> = {
        name: "update_cases",
        description: description.trim(),
        parameters,
        handler: async ({ case_ids, fields }, client) => {
            validateCaseFields(fields, await client.getCaseFields());
    
            const caseData = await client.getCase(case_ids[0]);
            const updatedCases = await client.updateCases(caseData.suite_id, case_ids, fields);
    
            return {
                success: true,
                updated_count: updatedCases.length,
                case_ids: updatedCases.map(c => c.id),
                message: `Successfully updated ${updatedCases.length} test cases`,
            };
        }
    };
  • Zod schema defining input parameters: case_ids (array of numbers) and fields (record of key-value pairs).
    const parameters = {
        case_ids: z.array(z.number()).min(1).describe("Array of case IDs to update (e.g. [123, 456, 789])"),
        fields: z.record(z.string(), z.any()).describe(CASE_FIELDS_PARAM_DESCRIPTION),
    };
  • client.updateCases() method - makes the HTTP POST request to TestRail API endpoint /update_cases/{suite_id} with case_ids and fields.
    async updateCases(suiteId: number, caseIds: number[], fields: Record<string, any>): Promise<Case[]> {
        const response = await this.post<{ updated_cases: Case[] }>(`${API_BASE_V2}/update_cases/${suiteId}`, {
            case_ids: caseIds,
            ...fields,
        });
    
        return response.updated_cases;
    }
  • src/index.ts:87-115 (registration)
    Generic tool registration loop that calls server.registerTool() with each tool's name, description, input schema, and handler (including error handling).
    for (const tool of tools) {
        server.registerTool(
            tool.name,
            {
                description: tool.description,
                inputSchema: tool.parameters,
            },
            async (args: any) => {
                try {
                    const output: Record<string, any> = await tool.handler(args, client);
                    const sanitized = removeNullish(output);
    
                    return {
                        content: [
                            {
                                type: "text" as const,
                                text: JSON.stringify(sanitized),
                            },
                        ],
                    } as any;
                } catch (error: any) {
                    return {
                        content: [{ type: "text", text: `Error: ${error.message}` }],
                        isError: true,
                    };
                }
            }
        );
    }
  • validateCaseFields helper function used to verify that the provided field names exist in the TestRail case schema before the update.
    export function validateCaseFields(fields: Record<string, any> | string[], caseFields: CaseField[]): void {
        const fieldKeys = Array.isArray(fields) ? fields : Object.keys(fields);
    
        if (fieldKeys.length === 0) {
            return;
        }
    
        const customFieldSchemas = caseFields.filter(field => field.is_active).map(mapToFieldSchema);
    
        const validFieldNames = new Set(
            [...SYSTEM_FIELDS, ...customFieldSchemas].map(f => f.system_name)
        );
    
        validFieldNames.add('id');
        validFieldNames.add('suite_id');
    
        const invalidFields: string[] = [];
        for (const key of fieldKeys) {
            if (!validFieldNames.has(key)) {
                invalidFields.push(key);
            }
        }
    
        if (invalidFields.length > 0) {
            const validKeysList = Array.from(validFieldNames).sort().join(', ');
            const invalidFieldsList = invalidFields.map(f => `'${f}'`).join(', ');
            throw new Error(`Invalid fields provided: ${invalidFieldsList}. Available fields are: ${validKeysList}`);
        }
    }
Behavior2/5

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

With no annotations, the description bears full responsibility for behavioral disclosure. It only states the update operation and prerequisite, but does not discuss whether updates are destructive or merge, authentication needs, rate limits, or idempotency. A score of 2 reflects significant gaps in transparency.

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?

The description is exceptionally concise with three short, front-loaded sentences. Each sentence adds value: purpose, prerequisite, and efficiency comparison. No redundancy or fluff.

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?

Given no output schema and simple parameters, the description covers primary operation and prerequisite. However, it omits return value, error behavior (e.g., partial updates), and confirmation of successful updates. A score of 3 indicates minimally adequate completeness.

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%, providing baseline 3. The description adds context that field values are applied uniformly across cases and references get_case_fields, but does not introduce new meaning beyond what the schema already provides. Thus, a score of 3 is appropriate.

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 tool's purpose: bulk update multiple test cases with same field values. It uses a specific verb (update) and resource (test cases), and hints at differentiation from the sibling 'update_case' by noting efficiency, making it easy for an agent to understand when to use this tool.

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

Usage Guidelines4/5

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

The description provides a clear usage prerequisite: must know valid field names from get_case_fields. It also implicitly suggests using this tool over update_case for efficiency. However, it lacks explicit exclusions or alternative tools for different scenarios, which would strengthen the guidance.

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/uarlouski/testrail-mcp-server'

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