Skip to main content
Glama
Derrbal

TestRail MCP Server

by Derrbal

Get TestRail Test

get_test

Retrieve existing test details from TestRail test management system using test ID to access test case information and related data.

Instructions

Returns an existing test.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
test_idYesThe ID of the test
with_dataNoThe parameter to get data

Implementation Reference

  • MCP tool handler function for 'get_test': prepares filters and calls service getTest, returns formatted JSON response.
    async ({ test_id, with_data }) => {
      logger.debug(`Get test tool called with test_id: ${test_id}`);
      const filters = {
        test_id,
        with_data,
      };
      const result = await getTest(filters);
      logger.debug(`Get test tool completed. Retrieved test: ${result.title}`);
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    },
  • Input schema validation using Zod for the get_test tool parameters.
    inputSchema: {
      test_id: z.number().int().positive().describe('The ID of the test'),
      with_data: z.string().optional().describe('The parameter to get data'),
    },
  • src/server.ts:757-784 (registration)
    Registration of the 'get_test' tool with the MCP server, including schema and handler.
    server.registerTool(
      'get_test',
      {
        title: 'Get TestRail Test',
        description: 'Returns an existing test.',
        inputSchema: {
          test_id: z.number().int().positive().describe('The ID of the test'),
          with_data: z.string().optional().describe('The parameter to get data'),
        },
      },
      async ({ test_id, with_data }) => {
        logger.debug(`Get test tool called with test_id: ${test_id}`);
        const filters = {
          test_id,
          with_data,
        };
        const result = await getTest(filters);
        logger.debug(`Get test tool completed. Retrieved test: ${result.title}`);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      },
    );
  • Service layer wrapper for getTest: transforms params, calls client, normalizes and extracts custom fields from response.
    export async function getTest(filters: GetTestFilters): Promise<TestDetailSummary> {
      // Transform service filters to client parameters
      const clientParams: GetTestParams = {
        test_id: filters.test_id,
        with_data: filters.with_data,
      };
    
      const response: TestRailTestDetailDto = await testRailClient.getTest(clientParams);
      
      // Extract custom fields (any fields not in the standard interface)
      const standardFields = [
        'id', 'title', 'assignedto_id', 'case_id', 'custom_expected', 'custom_preconds',
        'custom_steps_separated', 'estimate', 'estimate_forecast', 'priority_id',
        'run_id', 'status_id', 'type_id', 'milestone_id', 'refs', 'labels'
      ];
      const custom: Record<string, unknown> = {};
      
      Object.keys(response).forEach((key) => {
        if (!standardFields.includes(key)) {
          custom[key] = response[key];
        }
      });
    
      return {
        id: response.id,
        title: response.title,
        assignedto_id: response.assignedto_id,
        case_id: response.case_id,
        custom_expected: response.custom_expected,
        custom_preconds: response.custom_preconds,
        custom_steps_separated: response.custom_steps_separated,
        estimate: response.estimate,
        estimate_forecast: response.estimate_forecast,
        priority_id: response.priority_id,
        run_id: response.run_id,
        status_id: response.status_id,
        type_id: response.type_id,
        milestone_id: response.milestone_id,
        refs: response.refs,
        labels: response.labels,
        custom: Object.keys(custom).length > 0 ? custom : undefined,
      };
    }
  • TestRailClient getTest method: constructs API URL /get_test/{test_id}, makes HTTP GET request with optional with_data query param, handles response and errors.
    async getTest(params: GetTestParams): Promise<TestRailTestDetailDto> {
      try {
        // Build query parameters
        const queryParams = new URLSearchParams();
        
        // Handle with_data parameter
        if (params.with_data !== undefined) {
          queryParams.append('with_data', params.with_data);
        }
        
        const queryString = queryParams.toString();
        const url = `/get_test/${params.test_id}${queryString ? `?${queryString}` : ''}`;
        
        const res = await this.http.get(url);
        if (res.status >= 200 && res.status < 300) {
          logger.info({
            message: 'Successfully retrieved test details',
            testId: params.test_id,
            responseSize: JSON.stringify(res.data).length,
          });
          return res.data;
        } else {
          throw new Error(`HTTP ${res.status}: ${res.statusText}`);
        }
      } catch (error) {
        const normalized = this.normalizeError(error);
        logger.error({
          message: 'Failed to retrieve test details',
          testId: params.test_id,
          error: normalized,
        });
        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 of behavioral disclosure. It states the tool returns data (a read operation), but doesn't cover aspects like authentication needs, rate limits, error handling, or what the return format looks like (e.g., JSON structure). For a read tool with zero annotation coverage, this is a significant gap 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 extremely concise—a single sentence with zero waste. It's front-loaded with the core action ('Returns'), making it easy to scan. Every word earns its place, though this brevity contributes to gaps in other dimensions like guidelines and transparency.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a read operation with 2 parameters) and lack of annotations and output schema, the description is incomplete. It doesn't explain what 'test' data is returned, how to interpret 'with_data,' or any behavioral traits. For a tool with no structured output and full parameter reliance on the schema, more context is needed to be fully helpful.

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?

The description adds no meaning beyond what the input schema provides. Schema description coverage is 100%, with clear documentation for 'test_id' (ID of the test) and 'with_data' (parameter to get data). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate or add extra context.

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

Purpose3/5

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

The description 'Returns an existing test' states the basic action (return) and resource (test), but it's vague—it doesn't specify what a 'test' entails in TestRail (e.g., test case details, results) or differentiate it from sibling tools like 'get_tests' (plural). It avoids tautology by not just restating the name, but lacks specificity.

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 guidance is provided on when to use this tool versus alternatives. For example, it doesn't explain if this is for retrieving a single test by ID (vs. 'get_tests' for multiple tests) or mention prerequisites like needing a valid test ID. The description implies usage only through the action 'returns,' but no explicit context or exclusions are stated.

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