Skip to main content
Glama
uarlouski

TestRail MCP Server

get_sections

Retrieve all sections for a project, returning section IDs and names needed to add test cases.

Instructions

Get all sections for a project. Returns section IDs and names that can be used with add_case

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
project_idYesThe ID of the project. Use get_projects to find available projects

Implementation Reference

  • Handler function implementing the get_sections tool logic. Takes project_id, calls client.getSections, and returns parsed sections.
    export const getSectionsTool: ToolDefinition<typeof parameters, TestRailClient> = {
        name: "get_sections",
        description: "Get all sections for a project. Returns section IDs and names that can be used with add_case",
        parameters,
        handler: async ({ project_id }, client) => {
            const sections = await client.getSections(project_id);
    
            return {
                sections: sections.map(s => SectionSchema.parse(s)),
            };
        }
    };
  • Input schema for get_sections tool: requires a project_id number.
    const parameters = {
        project_id: z.number().describe("The ID of the project. Use get_projects to find available projects"),
    };
  • Zod schema for Section output type, used to validate/parse the API response.
    export const SectionSchema = z.object({
        id: z.number(),
        name: z.string(),
        description: z.string().nullish(),
        parent_id: z.number().nullish(),
        suite_id: z.number(),
    });
  • src/index.ts:58-115 (registration)
    Registration of get_sections tool in the tools array and registered via server.registerTool with its name, description, input schema, and handler wrapper.
    const tools = [
        getProjectsTool,
        getCaseTool,
        getCasesTool,
        getCaseFieldsTool,
        getTemplatesTool,
        getSectionsTool,
        updateCaseTool,
        updateCasesTool,
        addCaseTool,
        addRunTool,
        getStatusesTool,
        getPrioritiesTool,
        getTestsTool,
        addResultsTool,
        addResultsForCasesTool,
        addAttachmentToRunTool,
        getLabelsTool,
    ]
    
    if (TESTRAIL_ENABLE_SHARED_STEPS) {
        tools.push(getSharedStepsTool as any);
        tools.push(getSharedStepTool as any);
        tools.push(getSharedStepHistoryTool as any);
        tools.push(addSharedStepTool as any);
        tools.push(updateSharedStepTool as any);
        tools.push(deleteSharedStepTool as any);
    }
    
    for (const tool of tools) {
        server.registerTool(
            tool.name,
            {
                description: tool.description,
                inputSchema: tool.parameters,
            },
            async (args: any) => {
                try {
                    const output: Record<string, any> = await tool.handler(args, client);
                    const sanitized = removeNullish(output);
    
                    return {
                        content: [
                            {
                                type: "text" as const,
                                text: JSON.stringify(sanitized),
                            },
                        ],
                    } as any;
                } catch (error: any) {
                    return {
                        content: [{ type: "text", text: `Error: ${error.message}` }],
                        isError: true,
                    };
                }
            }
        );
    }
  • TestRailClient method that calls the TestRail API to fetch sections for a given project with pagination.
    async getSections(projectId: number): Promise<Section[]> {
        const url = `${API_BASE_V2}/get_sections/${projectId}`;
        return this.paginateAll<Section>(url, 'sections');
    }
Behavior3/5

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

No annotations are provided, so the description carries full burden. It indicates a safe read operation but does not disclose potential side effects, authentication requirements, or pagination behavior.

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—two sentences with no redundant information. The key action and purpose are front-loaded.

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

Completeness4/5

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

Given the simplicity of the tool (one parameter, no output schema), the description covers the required information: what it does, what it returns, and how to use it. Minor omission: no mention of possible permissions or edge cases.

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 coverage is 100% and already describes the parameter. The description adds no additional meaning beyond what the schema provides, meeting the baseline for high 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 tool retrieves all sections for a project, including return details (IDs and names) and a use case for add_case. It is distinct from sibling tools but lacks explicit differentiation.

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 implies usage when needing section IDs for add_case but provides no explicit guidance on when to use this tool versus alternatives or when not to use it.

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

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