create-test-run
Create a new test run for a project in QA Studio by specifying project ID, name, environment, and optional details to organize testing activities.
Instructions
Create a new test run for a project
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | The project ID to create the test run for | |
| name | Yes | Name of the test run | |
| environment | Yes | Environment name (e.g., "production", "staging", "local") | |
| description | No | Optional description of the test run | |
| milestoneId | No | Optional milestone ID to associate with the test run |
Implementation Reference
- src/index.ts:101-135 (handler)The main handler function for the 'create-test-run' tool. It extracts arguments, sends a POST request to the /runs API endpoint to create a test run, and returns a formatted success message with the new run's details or an error response.async (args) => { try { const { projectId, name, description, environment, milestoneId } = args; const data = await apiRequest(`/runs`, { method: 'POST', body: JSON.stringify({ projectId, name, description, environment, milestoneId }) }); return { content: [ { type: 'text' as const, text: `✅ Test run created successfully!\n\nID: ${data.id}\nName: ${data.name}\nEnvironment: ${data.environment}\n\nView: ${API_URL.replace('/api', '')}/projects/${projectId}/runs/${data.id}` } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/index.ts:90-99 (schema)Zod input schema defining the required and optional parameters for creating a test run: projectId, name, environment, description, and milestoneId.inputSchema: { projectId: z.string().describe('The project ID to create the test run for'), name: z.string().describe('Name of the test run'), environment: z.string().describe('Environment name (e.g., "production", "staging", "local")'), description: z.string().optional().describe('Optional description of the test run'), milestoneId: z .string() .optional() .describe('Optional milestone ID to associate with the test run') }
- src/index.ts:86-136 (registration)Registration of the 'create-test-run' tool using server.registerTool, including schema and inline handler function.server.registerTool( 'create-test-run', { description: 'Create a new test run for a project', inputSchema: { projectId: z.string().describe('The project ID to create the test run for'), name: z.string().describe('Name of the test run'), environment: z.string().describe('Environment name (e.g., "production", "staging", "local")'), description: z.string().optional().describe('Optional description of the test run'), milestoneId: z .string() .optional() .describe('Optional milestone ID to associate with the test run') } }, async (args) => { try { const { projectId, name, description, environment, milestoneId } = args; const data = await apiRequest(`/runs`, { method: 'POST', body: JSON.stringify({ projectId, name, description, environment, milestoneId }) }); return { content: [ { type: 'text' as const, text: `✅ Test run created successfully!\n\nID: ${data.id}\nName: ${data.name}\nEnvironment: ${data.environment}\n\nView: ${API_URL.replace('/api', '')}/projects/${projectId}/runs/${data.id}` } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Error: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } );
- src/index.ts:17-34 (helper)Shared helper function apiRequest used by the handler to make authenticated API requests to the QA Studio backend.async function apiRequest(endpoint: string, options: RequestInit = {}): Promise<any> { const url = `${API_URL}${endpoint}`; const response = await fetch(url, { ...options, headers: { 'Content-Type': 'application/json', 'X-API-Key': API_KEY, ...options.headers } }); if (!response.ok) { const error = await response.text(); throw new Error(`API Error (${response.status}): ${error}`); } return response.json(); }