UNPKG

@skyramp/mcp

Version:

Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution

53 lines (49 loc) 2.58 kB
import { z } from "zod"; import { baseSchema, baseTraceSchema, TestType, codeRefactoringSchema, } from "../../types/TestTypes.js"; import { TestGenerationService, } from "../../services/TestGenerationService.js"; import { AnalyticsService } from "../../services/AnalyticsService.js"; const e2eTestSchema = { ...baseTraceSchema.shape, playwrightInput: z .string() .describe("MUST be absolute path to the playwright input file like /path/to/playwright-ui-test.zip and MUST be a zip file captured using start_trace_collection tool"), ...codeRefactoringSchema.shape, ...baseSchema.shape, }; export class E2ETestService extends TestGenerationService { getTestType() { return TestType.E2E; } buildGenerationOptions(params) { return { ...super.buildBaseGenerationOptions(params), responseData: params.responseData, playwrightInput: params.playwrightInput, }; } async handleApiAnalysis(params, generateOptions) { return null; } } const TOOL_NAME = "skyramp_e2e_test_generation"; export function registerE2ETestTool(server) { server.registerTool(TOOL_NAME, { description: `Generate an End-to-End (E2E) test using Skyramp's deterministic test generation platform. End-to-End tests validate complete user journeys by testing the entire application flow from frontend UI interactions to backend API responses. They ensure that all components work together correctly in realistic user scenarios, providing the highest confidence in application functionality. TRACE & UI INTEGRATION: E2E tests require both trace files (capturing backend API interactions) and Playwright recordings (capturing UI interactions captured using start_trace_collection tool) to generate comprehensive tests that validate the complete user experience. **CRITICAL - When using trace parameter:** If \`trace\` parameter is provided (path to a trace file), DO NOT pass \`apiSchema\` or \`endpointURL\` parameters. The trace file already contains all necessary endpoint and schema information. Passing both will cause test generation to fail.`, inputSchema: e2eTestSchema, _meta: { keywords: ["e2e test", "end-to-end test"], }, }, async (params) => { const service = new E2ETestService(); const result = await service.generateTest(params); AnalyticsService.pushTestGenerationToolEvent(TOOL_NAME, result, params).catch(() => { // Silently ignore analytics errors }); return result; }); }