Skip to main content
Glama
Derrbal

TestRail MCP Server

by Derrbal

Get TestRail Run

get_run

Retrieve a specific test run from TestRail using its unique ID to access run details and included test cases for test management and analysis.

Instructions

Returns an existing test run. Please see get tests for the list of included tests in this run.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
run_idYesThe ID of the test run

Implementation Reference

  • MCP tool handler for 'get_run': takes run_id, calls getRun service function, returns JSON stringified result as text content.
    async ({ run_id }) => {
      logger.debug(`Get run tool called with run_id: ${run_id}`);
      const result = await getRun(run_id);
      logger.debug(`Get run tool completed. Retrieved run: ${result.name}`);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    },
  • Input schema for 'get_run' tool using Zod: requires positive integer run_id.
    {
      title: 'Get TestRail Run',
      description: 'Returns an existing test run. Please see get tests for the list of included tests in this run.',
      inputSchema: {
        run_id: z.number().int().positive().describe('The ID of the test run'),
      },
    },
  • src/server.ts:619-641 (registration)
    Registers the 'get_run' MCP tool with McpServer.registerTool, including title, description, input schema, and handler function.
    server.registerTool(
      'get_run',
      {
        title: 'Get TestRail Run',
        description: 'Returns an existing test run. Please see get tests for the list of included tests in this run.',
        inputSchema: {
          run_id: z.number().int().positive().describe('The ID of the test run'),
        },
      },
      async ({ run_id }) => {
        logger.debug(`Get run tool called with run_id: ${run_id}`);
        const result = await getRun(run_id);
        logger.debug(`Get run tool completed. Retrieved run: ${result.name}`);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      },
    );
  • Service layer function getRun that calls client.getRun and normalizes the TestRailRunDetailDto response into RunDetailSummary, extracting custom fields.
    export async function getRun(runId: number): Promise<RunDetailSummary> {
      const response: TestRailRunDetailDto = await testRailClient.getRun(runId);
      
      // Extract custom fields (any fields not in the standard interface)
      const standardFields = [
        'id', 'name', 'description', 'suite_id', 'milestone_id', 'assignedto_id',
        'include_all', 'is_completed', 'completed_on', 'config', 'config_ids',
        'passed_count', 'blocked_count', 'untested_count', 'retest_count',
        'failed_count', 'custom_status1_count', 'custom_status2_count',
        'custom_status3_count', 'custom_status4_count', 'custom_status5_count',
        'custom_status6_count', 'custom_status7_count', 'project_id', 'plan_id',
        'created_on', 'updated_on', 'refs', 'start_on', 'due_on', 'url'
      ];
      
      const custom: Record<string, unknown> = {};
      Object.keys(response).forEach(key => {
        if (!standardFields.includes(key)) {
          custom[key] = response[key];
        }
      });
    
      return {
        id: response.id,
        name: response.name,
        description: response.description,
        suite_id: response.suite_id,
        milestone_id: response.milestone_id,
        assignedto_id: response.assignedto_id,
        include_all: response.include_all,
        is_completed: response.is_completed,
        completed_on: response.completed_on,
        config: response.config,
        config_ids: response.config_ids,
        passed_count: response.passed_count,
        blocked_count: response.blocked_count,
        untested_count: response.untested_count,
        retest_count: response.retest_count,
        failed_count: response.failed_count,
        custom_status1_count: response.custom_status1_count,
        custom_status2_count: response.custom_status2_count,
        custom_status3_count: response.custom_status3_count,
        custom_status4_count: response.custom_status4_count,
        custom_status5_count: response.custom_status5_count,
        custom_status6_count: response.custom_status6_count,
        custom_status7_count: response.custom_status7_count,
        project_id: response.project_id,
        plan_id: response.plan_id,
        created_on: response.created_on,
        updated_on: response.updated_on,
        refs: response.refs,
        start_on: response.start_on,
        due_on: response.due_on,
        url: response.url,
        custom: Object.keys(custom).length > 0 ? custom : undefined,
      };
    }
  • Client HTTP call to TestRail API /get_run/{runId}, handles errors and logging.
    async getRun(runId: number): Promise<TestRailRunDetailDto> {
      try {
        const res = await this.http.get(`/get_run/${runId}`);
        if (res.status >= 200 && res.status < 300) {
          logger.info({
            message: 'Successfully retrieved test run',
            runId,
            responseSize: JSON.stringify(res.data).length,
          });
          return res.data as TestRailRunDetailDto;
        }
        throw Object.assign(new Error(`HTTP ${res.status}`), { response: res });
      } catch (error) {
        const normalized = this.normalizeError(error);
        const safeDetails = this.getSafeErrorDetails(error);
        logger.error({
          message: 'Failed to retrieve test run',
          runId,
          error: normalized,
          details: safeDetails,
        });
        throw normalized;
      }
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It states this is a read operation ('Returns'), which is clear, but doesn't disclose behavioral traits such as error handling (e.g., what happens if the run_id is invalid), authentication needs, rate limits, or response format. The reference to 'get tests' adds some context but is insufficient for a mutation-free tool with no annotation coverage.

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 two sentences, front-loaded with the core purpose and efficiently references another tool for additional context. Every sentence earns its place with no wasted words, making it appropriately sized and easy to parse.

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 the tool's simplicity (1 parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and points to related information, but as a read tool with no annotations, it should ideally include more on response behavior or error cases to be fully complete for agent use.

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%, with the single parameter 'run_id' well-documented in the schema as 'The ID of the test run'. The description doesn't add any meaning beyond this, such as format examples or constraints not in the schema. Baseline 3 is appropriate since the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb ('Returns') and resource ('an existing test run'), making the purpose understandable. However, it doesn't explicitly differentiate from sibling tools like 'get_runs' (plural) or 'get_test', which could retrieve similar resources. The mention of 'get tests' is helpful but not a direct sibling distinction.

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?

The description implies usage by referencing 'get tests' for related information, suggesting it's for retrieving a specific run's details. However, it lacks explicit guidance on when to use this versus alternatives like 'get_runs' (for multiple runs) or 'get_test' (for individual tests), and doesn't mention prerequisites or exclusions.

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

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