open_test_result
Opens test results in your browser using a test run ID to view detailed reports from QIT MCP Server testing workflows.
Instructions
Open a test result in the default web browser and return the report URL.
⚠️ QIT CLI not detected. QIT CLI not found. Please install it using one of these methods:
Via Composer (recommended): composer require woocommerce/qit-cli --dev
Set QIT_CLI_PATH environment variable: export QIT_CLI_PATH=/path/to/qit
Ensure 'qit' is available in your system PATH
For more information, visit: https://github.com/woocommerce/qit-cli
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| test_run_id | Yes | Test run ID to open in browser |
Implementation Reference
- src/tools/test-results.ts:166-194 (handler)The handler function that implements the core logic of the 'open_test_result' tool. It runs the QIT CLI 'open' command, extracts the report URL from the output, and returns a formatted text response.handler: async (args: { test_run_id: string }) => { const cmdArgs = ["open", args.test_run_id]; const result = await executeQitCommand(cmdArgs); // The open command outputs to stderr and may exit with code 1 even on success // Extract URL from output (either stdout or stderr) const output = result.stdout || result.stderr || ""; const urlMatch = output.match(/https?:\/\/[^\s]+/); if (urlMatch) { return { content: `Report opened in browser.\n\nURL: ${urlMatch[0]}`, isError: false, }; } // If we can't find a URL but there's output, return it if (output) { return { content: output, isError: false, }; } return { content: "Report opened in browser.", isError: false, }; },
- src/tools/test-results.ts:163-165 (schema)Zod schema defining the input parameters for the tool: a required string 'test_run_id'.inputSchema: z.object({ test_run_id: z.string().describe("Test run ID to open in browser"), }),
- src/tools/index.ts:10-19 (registration)Registers the 'open_test_result' tool (contained within testResultsTools) by spreading it into the central allTools object used by the MCP server.export const allTools = { ...authTools, ...testExecutionTools, ...testResultsTools, ...groupsTools, ...environmentTools, ...packagesTools, ...configTools, ...utilitiesTools, };
- src/server.ts:25-38 (registration)MCP server handler for listing tools, dynamically generates tool list including 'open_test_result' from allTools with JSON schema conversion.server.setRequestHandler(ListToolsRequestSchema, async () => { // Check if QIT CLI is available const cliInfo = detectQitCli(); const tools = Object.entries(allTools).map(([_, tool]) => ({ name: tool.name, description: cliInfo ? tool.description : `${tool.description}\n\n⚠️ QIT CLI not detected. ${getQitCliNotFoundError()}`, inputSchema: zodToJsonSchema(tool.inputSchema), })); return { tools }; });
- src/server.ts:41-87 (registration)MCP server handler for calling tools, retrieves 'open_test_result' from allTools, validates input with its schema, and invokes its handler.server.setRequestHandler(CallToolRequestSchema, async (request) => { const { name, arguments: args } = request.params; const tool = allTools[name as ToolName]; if (!tool) { return { content: [ { type: "text", text: `Unknown tool: ${name}`, }, ], isError: true, }; } try { // Validate input const validatedArgs = tool.inputSchema.parse(args); // Execute tool // eslint-disable-next-line @typescript-eslint/no-explicit-any const result = await (tool.handler as (args: any) => Promise<{ content: string; isError: boolean }>)(validatedArgs); return { content: [ { type: "text", text: result.content, }, ], isError: result.isError, }; } catch (error) { const message = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: `Error: ${message}`, }, ], isError: true, }; } });