Skip to main content
Glama
Derrbal

TestRail MCP Server

by Derrbal

Get TestRail Suites

get_suites

Retrieve all test suites for a specific TestRail project using the project ID to organize and access test case collections within your test management system.

Instructions

Get all test suites for a specific TestRail project by ID.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesTestRail project ID

Implementation Reference

  • src/server.ts:277-317 (registration)
    Registers the MCP 'get_suites' tool with input schema (project_id) and handler that delegates to testrailService.getSuites(project_id), formats result as JSON text content, and handles errors.
    server.registerTool(
      'get_suites',
      {
        title: 'Get TestRail Suites',
        description: 'Get all test suites for a specific TestRail project by ID.',
        inputSchema: {
          project_id: z.number().int().positive().describe('TestRail project ID'),
        },
      },
      async ({ project_id }) => {
        logger.debug(`Get suites tool called with project_id: ${project_id}`);
        try {
          const result = await getSuites(project_id);
          logger.debug(`Get suites tool completed successfully for project_id: ${project_id}. Found ${result.length} suites`);
          return {
            content: [
              {
                type: 'text',
                text: JSON.stringify(result, null, 2),
              },
            ],
          };
        } catch (err) {
          logger.error({ err }, `Get suites tool failed for project_id: ${project_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 = `Project ${project_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,
          };
        }
      },
  • MCP tool handler function for get_suites: calls service layer, returns JSON suites or error message.
    async ({ project_id }) => {
      logger.debug(`Get suites tool called with project_id: ${project_id}`);
      try {
        const result = await getSuites(project_id);
        logger.debug(`Get suites tool completed successfully for project_id: ${project_id}. Found ${result.length} suites`);
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(result, null, 2),
            },
          ],
        };
      } catch (err) {
        logger.error({ err }, `Get suites tool failed for project_id: ${project_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 = `Project ${project_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,
        };
      }
  • Tool metadata and input schema validation using Zod for project_id parameter.
    {
      title: 'Get TestRail Suites',
      description: 'Get all test suites for a specific TestRail project by ID.',
      inputSchema: {
        project_id: z.number().int().positive().describe('TestRail project ID'),
      },
  • Service layer getSuites: fetches raw suites from client, normalizes custom fields into SuiteSummary[]
    export async function getSuites(projectId: number): Promise<SuiteSummary[]> {
      const suites: TestRailSuiteDto[] = await testRailClient.getSuites(projectId);
      
      return suites.map((suite) => {
        const {
          id,
          name,
          description,
          project_id,
          url,
          is_baseline,
          is_master,
          is_completed,
          completed_on,
          created_on,
          created_by,
          updated_on,
          updated_by,
          ...rest
        } = suite;
    
        const custom: Record<string, unknown> = {};
        for (const [key, value] of Object.entries(rest)) {
          if (key.startsWith('custom_')) custom[key] = value;
        }
    
        return {
          id,
          name,
          description,
          project_id,
          url,
          is_baseline,
          is_master,
          is_completed,
          completed_on,
          created_on,
          created_by,
          updated_on,
          updated_by,
          custom: Object.keys(custom).length ? custom : undefined,
        };
      });
    }
  • HTTP client implementation: GET /get_suites/{projectId}, handles direct/paginated responses, error normalization.
    async getSuites(projectId: number): Promise<TestRailSuiteDto[]> {
      try {
        const res = await this.http.get(`/get_suites/${projectId}`);
        logger.info({ 
          status: res.status, 
          dataType: typeof res.data,
          dataIsArray: Array.isArray(res.data),
          projectId 
        }, 'TestRail getSuites response info');
        
        if (res.status >= 200 && res.status < 300) {
          // Handle both direct array and paginated response formats
          let suites: TestRailSuiteDto[];
          
          if (Array.isArray(res.data)) {
            // Direct array format (most common)
            suites = res.data as TestRailSuiteDto[];
          } else if (res.data && typeof res.data === 'object' && 'suites' in res.data) {
            // Paginated format (if TestRail supports it)
            const paginatedResponse = res.data as { suites: TestRailSuiteDto[] };
            if (!Array.isArray(paginatedResponse.suites)) {
              throw Object.assign(new Error('API returned paginated response with non-array suites field'), {
                response: { status: 200 } // Make it look like a server error
              });
            }
            suites = paginatedResponse.suites;
            logger.info({ 
              returnedSuites: suites.length
            }, 'TestRail paginated suites response');
          } else {
            logger.error({ 
              status: res.status, 
              responseData: res.data,
              dataType: typeof res.data 
            }, 'TestRail getSuites returned unexpected response format');
            throw Object.assign(new Error('API returned unexpected response format'), { 
              response: { status: 200 } // Make it look like a server error
            });
          }
          
          return suites;
        }
        throw Object.assign(new Error(`HTTP ${res.status}`), { response: res });
      } catch (err) {
        const normalized = this.normalizeError(err);
        const safeDetails = this.getSafeErrorDetails(err);
        logger.error({ err: normalized, details: safeDetails, projectId }, 'TestRail getSuites failed');
        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 the action ('Get all test suites') but lacks behavioral details such as whether this is a read-only operation, if it requires authentication, any rate limits, pagination behavior, or error handling. For a tool with zero annotation coverage, this is a significant gap in disclosing operational traits.

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 front-loads the core purpose ('Get all test suites') and specifies the context ('for a specific TestRail project by ID'). There is zero waste, making it highly concise and well-structured for quick understanding.

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 low complexity (one parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose and parameter context, but lacks completeness in behavioral aspects like safety or output details, which are important for a tool with no annotations or output schema to guide the agent.

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 schema description coverage is 100%, with the single parameter 'project_id' documented as 'TestRail project ID'. The description adds no additional meaning beyond this, such as format examples or constraints not in the schema. With high schema coverage, the baseline score of 3 is appropriate as the description doesn't compensate but doesn't detract either.

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 ('Get') and resource ('all test suites'), specifying the scope ('for a specific TestRail project by ID'). It distinguishes from siblings like 'get_suite' (singular) by indicating it retrieves multiple suites, though it doesn't explicitly contrast with other list tools like 'get_cases' or 'get_projects' beyond the resource type.

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 when needing suites for a project, but provides no explicit guidance on when to use this versus alternatives like 'get_suite' (for a single suite) or other list tools. It mentions the required 'project_id' parameter, which hints at prerequisites, but lacks context on exclusions or comparisons with siblings.

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