Skip to main content
Glama
Derrbal

TestRail MCP Server

by Derrbal

Get TestRail Case

get_case

Fetch a TestRail test case by ID to retrieve detailed case information for test management workflows.

Instructions

Fetch a TestRail test case by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
case_idYesTestRail case ID

Implementation Reference

  • Core handler function that fetches a single TestRail test case by ID via the TestRail client, destructures the response, extracts custom fields, and returns a normalized CaseSummary object.
    export async function getCase(caseId: number): Promise<CaseSummary> {
      const data: TestRailCaseDto = await testRailClient.getCase(caseId);
      const {
        id,
        title,
        section_id,
        type_id,
        priority_id,
        refs,
        created_on,
        updated_on,
        ...rest
      } = data;
    
      const custom: Record<string, unknown> = {};
      for (const [key, value] of Object.entries(rest)) {
        if (key.startsWith('custom_')) custom[key] = value;
      }
    
      return {
        id,
        title,
        section_id,
        type_id,
        priority_id,
        refs: refs ?? null,
        created_on,
        updated_on,
        custom: Object.keys(custom).length ? custom : undefined,
      };
    }
  • src/server.ts:19-60 (registration)
    Registers the 'get_case' MCP tool, including input schema validation with Zod (case_id as positive integer), description, and the handler wrapper that invokes getCase from testrailService and formats the response as JSON text.
    server.registerTool(
      'get_case',
      {
        title: 'Get TestRail Case',
        description: 'Fetch a TestRail test case by ID.',
        inputSchema: {
          case_id: z.number().int().positive().describe('TestRail case ID'),
        },
      },
      async ({ case_id }) => {
        logger.debug(`Tool called with case_id: ${case_id}`);
        try {
          const result = await getCase(case_id);
          logger.debug(`Tool completed successfully for case_id: ${case_id}`);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (err) {
          logger.error({ err }, `Tool failed for case_id: ${case_id}`);
          const e = err as { type?: string; status?: number; message?: string };
          let message = 'Unexpected error';
          if (e?.type === 'auth') message = 'Authentication failed: check TESTRAIL_USER/API_KEY';
          else if (e?.type === 'not_found') message = `Case ${case_id} not found`;
          else if (e?.type === 'rate_limited') message = 'Rate limited by TestRail; try again later';
          else if (e?.type === 'server') message = 'TestRail server error';
          else if (e?.type === 'network') message = 'Network error contacting TestRail';
          else if (e?.message) message = e.message;
    
          return {
            content: [
              { type: 'text', text: message },
            ],
            isError: true,
          };
        }
      },
    );
  • TypeScript interface defining the structure of the normalized case data returned by the getCase handler, including core fields and optional custom fields.
    export interface CaseSummary {
      id: number;
      title: string;
      section_id?: number;
      type_id?: number;
      priority_id?: number;
      refs?: string | null;
      created_on?: number;
      updated_on?: number;
      custom?: Record<string, unknown> | undefined;
    }
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 'fetch', implying a read operation, but lacks details on permissions, rate limits, error handling, or response format. For a tool with no annotations, this leaves significant gaps in understanding its behavior and constraints.

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 a single, efficient sentence that directly states the tool's purpose without any unnecessary words. It is front-loaded and appropriately sized, making it easy to parse quickly while conveying the essential action.

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 lack of annotations and output schema, the description is incomplete. It doesn't explain what data is returned (e.g., case details, fields), potential errors, or how it differs from sibling tools. For a retrieval tool in a context with multiple similar tools, more context is needed to ensure proper usage.

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 mentions 'by ID', which aligns with the single parameter 'case_id' in the schema. With 100% schema description coverage, the schema already documents the parameter as 'TestRail case ID' with type and constraints, so the description adds minimal value beyond reinforcing the ID-based lookup, meeting the baseline for high schema coverage.

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 'fetch' and the resource 'TestRail test case by ID', making the purpose specific and understandable. However, it doesn't explicitly distinguish this tool from similar siblings like 'get_cases' (plural) or 'get_test', which also retrieve test-related data, leaving some ambiguity about when to use this specific tool versus others.

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?

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'get_cases', 'get_test', and 'get_case_fields', there is no indication of context, prerequisites, or exclusions, such as whether this is for single-case retrieval versus bulk operations or other related queries.

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