Skip to main content
Glama
uarlouski

TestRail MCP Server

get_case

Retrieve detailed information about a test case, including custom fields, by providing its case ID.

Instructions

Get detailed information about a test case including its custom fields

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
case_idYesThe ID of the test case (e.g. '123' or 'C123')

Implementation Reference

  • The handler function that executes the get_case tool logic. It extracts the case ID, fetches the test case from TestRail, enriches it with section name, case type, priority, labels, references, and custom fields, and returns a TestCaseResponse.
    handler: async ({ case_id }, client) => {
        const idString = case_id.toUpperCase().startsWith("C") ? case_id.substring(1) : case_id;
        const id = Number(idString);
        const testCase = await client.getCase(id);
    
        const [section, caseTypes, priorities, caseFields] = await Promise.all([
            client.getSection(Number(testCase.section_id)),
            client.getCaseTypes(),
            client.getPriorities(),
            client.getCaseFields()
        ]);
    
        const caseType = caseTypes.find(t => t.id === testCase.type_id);
        const priority = priorities.find(p => p.id === testCase.priority_id);
    
        const customFields = processCustomFields(testCase, caseFields);
    
        const response: TestCaseResponse = {
            id: testCase.id,
            title: testCase.title,
            section: section.name,
            type: caseType ? caseType.name : "Unknown",
            priority: priority ? priority.name : "Unknown",
            labels: (testCase.labels || []).map((label) => LabelSchema.parse(label)),
            references: testCase.refs,
            updated_on: testCase.updated_on,
            ...customFields
        };
    
        return response;
    }
  • Input schema definition for the get_case tool: requires a case_id string parameter.
    const parameters = {
        case_id: z.string().describe("The ID of the test case (e.g. '123' or 'C123')"),
    };
  • src/index.ts:60-60 (registration)
    Registration of getCaseTool in the tools array that gets registered with the MCP server.
    getCaseTool,
  • src/index.ts:7-7 (registration)
    Import of getCaseTool from the get_case.ts module.
    import { getCaseTool } from "./tools/get_case.js";
  • Helper function processCustomFields used by the handler to map custom field system names to human-readable labels and resolve dropdown option values.
    export function processCustomFields(
        testCase: Case,
        caseFields: CaseField[]
    ): Record<string, any> {
        if (!testCase) {
            throw new Error("Test case is undefined or null");
        }
    
        const templateId = testCase.template_id;
        const result: Record<string, any> = {};
    
        const applicableFields = caseFields.filter(field =>
            field.include_all || field.template_ids.includes(templateId)
        );
    
        const fieldNameMap = new Map<string, string>();
        const dropdownOptionsMap = new Map<string, Map<string, string>>();
    
        for (const field of applicableFields) {
            fieldNameMap.set(field.system_name, toSnakeCase(field.label));
    
            const optionsMap = parseDropdownOptions(field);
            if (optionsMap.size > 0) {
                dropdownOptionsMap.set(field.system_name, optionsMap);
            }
        }
    
        for (const [key, value] of Object.entries(testCase)) {
            if (!key.startsWith("custom_")) continue;
            if (value === null || value === undefined) continue;
    
            if (!fieldNameMap.has(key)) {
                console.error(`No field mapping found for: ${key}`);
                result[key] = value;
                continue;
            }
    
            const outputKey = fieldNameMap.get(key)!;
            let finalValue = value;
    
            if (dropdownOptionsMap.has(key)) {
                const options = dropdownOptionsMap.get(key)!;
                const optionKey = String(value);
                finalValue = options.get(optionKey) || value;
            }
    
            result[outputKey] = sanitizeValue(finalValue);
        }
    
        return result;
    }
Behavior3/5

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

No annotations provided; description only states 'get detailed information and custom fields', which is adequate for a read operation but doesn't disclose permissions, rate limits, or any behavioral details beyond the obvious.

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, 10 words, front-loaded with the main purpose. No unnecessary words.

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?

No output schema exists, so description should hint at return structure. 'Detailed information including custom fields' is vague. Could specify fields like title, steps, etc. Also lacks mention of whether it returns a single case object (implicit from name).

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 parameter 'case_id' described in schema as 'The ID of the test case (e.g. '123' or 'C123')'. Description adds no additional meaning beyond the schema, so baseline score of 3.

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?

Description clearly states verb 'Get', resource 'test case', and includes 'including its custom fields', distinguishing it from siblings like 'get_cases' (list) and 'get_case_fields' (fields only).

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 avoid this tool relative to siblings. Usage is implied by the verb 'Get' and resource specificity, but lacks explicit when-to-use/alternatives.

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