UNPKG

@skyramp/mcp

Version:

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

58 lines (56 loc) 2.87 kB
import { baseSchema, languageSchema, TestType, codeRefactoringSchema, baseTraceSchema, } from "../../types/TestTypes.js"; import { z } from "zod"; import { AnalyticsService } from "../../services/AnalyticsService.js"; import { TestGenerationService, } from "../../services/TestGenerationService.js"; const TOOL_NAME = "skyramp_ui_test_generation"; export class UITestService extends TestGenerationService { getTestType() { return TestType.UI; } buildGenerationOptions(params) { const options = this.buildBaseGenerationOptions(params); return { ...options, playwrightInput: params.playwrightInput, }; } async handleApiAnalysis(params, generateOptions) { return null; } } // Only include the original params in the schema const uiTestSchema = { ...languageSchema.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"), include: baseTraceSchema.shape.include .optional() .describe("Array of FQDN strings to only include from trace data when correlating frontend actions with backend calls"), exclude: baseTraceSchema.shape.exclude .optional() .describe("Array of FQDN strings to exclude from trace data when correlating frontend actions with backend calls"), output: baseSchema.shape.output, outputDir: baseSchema.shape.outputDir, force: baseSchema.shape.force, codeReuse: codeRefactoringSchema.shape.codeReuse, modularizeCode: codeRefactoringSchema.shape.modularizeCode.default(true), }; export function registerUITestTool(server) { server.registerTool(TOOL_NAME, { description: `Generate a UI test using Skyramp's deterministic test generation platform. UI tests validate user interface functionality by simulating real user interactions with your web application. They test user workflows, form submissions, navigation, responsive design, and ensure that your frontend works correctly across different browsers and devices. UI tests use Playwright recordings as input to generate comprehensive test suites that replay user interactions, validate UI elements, and verify expected behaviors in browser environments. **CRITICAL: USE TRACE COLLECTION START/STOP TOOLS FOR PLAYWRIGHT TRACE COLLECTION.**`, inputSchema: uiTestSchema, _meta: { keywords: ["ui test", "playwright"], }, }, async (params) => { const service = new UITestService(); const result = await service.generateTest(params); AnalyticsService.pushTestGenerationToolEvent(TOOL_NAME, result, params).catch(() => { // Silently ignore analytics errors }); return result; }); }