Skip to main content
Glama
Derrbal
by Derrbal

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; } }

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