Skip to main content
Glama
uarlouski

TestRail MCP Server

get_tests

Retrieve tests for a specific test run, with optional filtering by status IDs to narrow results.

Instructions

Get tests for a test run, optionally filtered by status

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYesThe ID of the test run
status_idNoOptional array of status IDs to filter by. Use get_statuses to retrieve available status IDs

Implementation Reference

  • The handler function that executes the get_tests tool logic. Takes run_id and optional status_id filter, calls the TestRail API client, and returns parsed test results.
    export const getTestsTool: ToolDefinition<typeof parameters, TestRailClient> = {
        name: "get_tests",
        description: "Get tests for a test run, optionally filtered by status",
        parameters,
        handler: async ({ run_id, status_id }, client: TestRailClient) => {
            const tests: Test[] = await client.getTests(run_id, status_id);
    
            return {
                tests: tests.map(test => TestSchema.parse(test)),
            };
        },
    };
  • Input parameter schema for get_tests tool: run_id (required number) and status_id (optional array of numbers).
    const parameters = {
        run_id: z.number().describe("The ID of the test run"),
        status_id: z.array(z.number()).optional().describe("Optional array of status IDs to filter by. Use get_statuses to retrieve available status IDs"),
    }
  • Zod schema defining the output shape of a Test object (id, case_id, status_id, title, run_id).
    export const TestSchema = z.object({
        id: z.number(),
        case_id: z.number(),
        status_id: z.number(),
        title: z.string(),
        run_id: z.number(),
    })
  • src/index.ts:87-115 (registration)
    Registration of get_tests tool on the MCP server. The tool is included in the tools array (line 71) and registered via server.registerTool in the loop.
    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,
                    };
                }
            }
        );
    }
  • TestRail API client method that calls the TestRail API endpoint get_tests with pagination support and optional status_id filter.
    async getTests(runId: number, statusId?: number[]): Promise<Test[]> {
        let url = `${API_BASE_V2}/get_tests/${runId}`;
    
        if (statusId && statusId.length > 0) {
            url += `&status_id=${statusId.join(',')}`;
        }
    
        return this.paginateAll<Test>(url, 'tests');
    }
Behavior2/5

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

No annotations provided; description only states 'Get', implying read-only but no details on permissions, side effects, or return behavior beyond the minimal.

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 of 10 words, front-loaded with the core purpose, no wasted 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?

Lacks details on return format, but for a simple GET tool with well-defined parameters, it is minimally adequate; could be more helpful by describing what test fields are returned.

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%; the description adds no new meaning beyond the schema, only restating the optional filter capability.

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 'Get tests for a test run', specifying the action (Get) and resource (tests), and distinguishes from siblings like 'get_cases' or 'add_tests'.

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?

Description mentions optional filtering by status but gives no explicit guidance on when to use this tool versus alternatives, no exclusions or prerequisites.

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