get_projects
Retrieve all projects in TestRail with their IDs and names for use with sections, templates, cases, and runs.
Instructions
Get all available projects in TestRail. Returns project IDs and names that can be used with get_sections, get_templates, get_cases, and add_run
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get_projects.ts:7-20 (handler)Main handler for the 'get_projects' tool. Calls client.getProjects(), filters out completed projects, and parses each through ProjectSchema.
export const getProjectsTool: ToolDefinition<typeof parameters, TestRailClient> = { name: "get_projects", description: "Get all available projects in TestRail. Returns project IDs and names that can be used with get_sections, get_templates, get_cases, and add_run", parameters, handler: async (_args, client) => { const projects = await client.getProjects(); return { projects: projects .filter(p => !p.is_completed) .map(p => ProjectSchema.parse(p)), }; } }; - src/types/testrail.ts:91-98 (schema)Zod schema for Project: defines shape with id (number), name (string), is_completed (boolean), suite_mode (number).
export const ProjectSchema = z.object({ id: z.number(), name: z.string(), is_completed: z.boolean(), suite_mode: z.number(), }); export type Project = z.infer<typeof ProjectSchema>; - src/index.ts:15-15 (registration)Import of getProjectsTool into the main server entry point.
import { getProjectsTool } from "./tools/get_projects.js"; - src/index.ts:59-59 (registration)getProjectsTool included in the tools array used for registration with the MCP server.
getProjectsTool, - src/client/testrail.ts:159-165 (helper)Client-side helper method: fetches projects from TestRail API via GET /api/v2/get_projects, caches the result in projectsPromise.
async getProjects(): Promise<Project[]> { if (!this.projectsPromise) { this.projectsPromise = this.get<{ projects: Project[] }>(`${API_BASE_V2}/get_projects`) .then(response => response.projects); } return this.projectsPromise; }