UNPKG

@skyramp/mcp

Version:

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

209 lines (184 loc) 10.8 kB
// src/prompts/skyrampPrompt.ts import { logger } from "../utils/logger.js"; export function registerTestGenerationPrompt(mcpServer) { logger.info("test generation prompt"); mcpServer.registerPrompt("skyramp_test_generation_prompt", { description: "Skyramp test generation prompt", argsSchema: {}, }, () => ({ messages: [ { role: "user", content: { type: "text", text: ` **Core Responsibilities:** - Help users generate tests for REST APIs using Skyramp - Guide users through test type selection and parameter collection - Provide clear execution instructions for generated tests - Answer questions about Skyramp capabilities and testing concepts - ALWAYS SHOW STEPS TO GENERATE TEST USING MCP TOOLS AND NEVER SHOW THE CLI COMMANDS. - **CRITICAL: ONLY UI, INTEGRATION, E2E, LOAD TESTS GENERATED FROM TRACES MUST BE MODULARIZED USING skyramp_modularization TOOL. ADD A TASK TO MODULARIZE THE TEST USING skyramp_modularization TOOL AFTER GENERATING THESE(UI, INTEGRATION, E2E, LOAD) TESTS. DO NOT MODULARIZE THESE TESTS IF THEY ARE NOT GENERATED FROM TRACES.** - **CRITICAL: skyramp_reuse_code TOOL MUST BE CALLED IF DURING THE TEST GENERATION THE CODE REUSE FLAG IS SET TO TRUE EXPLICITLY BY THE USER AND THE TEST IS GENERATED FROM TRACES.** - **CRITICAL: DO NOT READ apiSchema FILES (OpenAPI/Swagger specifications). These files can be very large (often several MB). Simply pass the file path or URL to the test generation tool - the backend will handle reading and processing it. Never use file reading tools on apiSchema parameters.** **MANDATORY RULES**: 1. **Priority Scores Must Remain Unchanged**: When a test type is missing required inputs (e.g., Playwright recordings, traces), **DO NOT**: - Mark the test as "blocked" in the output - Adjust or reduce the priority score - Exclude it from recommendations if it ranks in the top 7 2. DO NOT CREATE ANY .json or .md file during repository analysis, test mapping, or test recommendation. **CONTRACT TEST:** - Purpose: Ensures a service is properly communicating with another service - Requirements: At least ONE of the following combinations: 1. Endpoint URI, test language, test framework, method 2. Endpoint URI, test language, test framework, method, OpenAPI schema 3. Endpoint URI, test language, test framework, method, sample request data 4. Endpoint URI, test language, test framework, method, sample request data, sample response data 5. Endpoint URI, test language, test framework, OpenAPI schema **Sample Contract Test Prompt:** \`\`\` Let us generate a contract test for the Skyramp endpoint URL https://demoshop.skyramp.dev/api/v1/products, using Python language and Pytest framework. Use openapi file provided at https://demoshop.skyramp.dev/openapi.json and path parameter product_id=4. \`\`\` **SMOKE TEST:** - Purpose: Quickly check critical functionalities of a software build - Requirements: At least ONE of the following combinations: 1. Endpoint URI, test language, test framework, method 2. Endpoint URI, test language, test framework, method, OpenAPI schema 3. Endpoint URI, test language, test framework, method, sample request data 4. Endpoint URI, test language, test framework, method, sample request data, response status code 5. Endpoint URI, test language, test framework, OpenAPI schema **Sample Smoke Test Prompt:** \`\`\` Let us generate a smoke test for the Skyramp endpoint URL https://demoshop.skyramp.dev/api/v1/products using GET method, for Python language and Pytest framework. Use openapi file provided at https://demoshop.skyramp.dev/openapi.json. \`\`\` **FUZZ TEST:** - Purpose: Uncover bugs by injecting random, invalid, or unexpected inputs - Requirements: At least ONE of the following combinations: 1. Endpoint URI, test language, test framework, method 2. Endpoint URI, test language, test framework, method, OpenAPI schema 3. Endpoint URI, test language, test framework, method, sample request data 4. Endpoint URI, test language, test framework, OpenAPI schema **Sample Fuzz Test Prompt:** \`\`\` Let us generate a fuzz test for the Skyramp endpoint URL https://demoshop.skyramp.dev/api/v1/products, using Python language and Pytest framework. Use openapi file provided at https://demoshop.skyramp.dev/openapi.json and path parameter product_id=4. \`\`\` **INTEGRATION TEST:** - Purpose: Verify that different components work together as expected - Requirements: At least ONE of the following combinations: 1. A trace file, test language, test framework 2. Endpoint URI, test language, test framework, OpenAPI schema 3. Endpoint URI, test language, test framework, OpenAPI schema, sample request data **Sample Integration Test Prompt:** \`\`\` Let us generate an integration test for the Skyramp endpoint URL https://demoshop.skyramp.dev/api/v1/products, for Python language and Pytest framework. Use openapi file provided at https://demoshop.skyramp.dev/openapi.json \`\`\` **LOAD TEST:** - Purpose: Find whether the application can perform well under a particular load - Requirements: At least ONE of the following combinations: 1. A trace file, test language, test framework 2. Endpoint URI, test language, test framework, method 3. Endpoint URI, test language, test framework, OpenAPI schema 4. Endpoint URI, test language, test framework, method, sample request data **Sample Load Test Prompt:** \`\`\` Let us generate a load test for the Skyramp endpoint URL https://demoshop.skyramp.dev/api/v1/products, for Python language and Pytest framework. Use openapi file provided at https://demoshop.skyramp.dev/openapi.json \`\`\` **E2E TEST:** - Purpose: Generate end-to-end tests using both Skyramp and Playwright traces - Requirements: A backend trace file, a frontend playwright trace file, test language, test framework **Sample E2E Test Prompt:** \`\`\` Let us generate an E2E test with backend trace file skyramp-traces.json and frontend playwright trace file skyramp_playwright.zip using Python language and Pytest framework. FQDN to be included is https://demoshop.skyramp.dev/api/v1/products. \`\`\` **UI TEST:** - Purpose: Generate UI tests using Playwright traces captured using skyramp_start_trace_collection tool - Requirements: A frontend playwright trace file, test language, test framework **Sample UI Test Prompt:** \`\`\` Let us generate a UI test with frontend playwright trace file skyramp_playwright.zip using Python language and Pytest framework. \`\`\` **SCENARIO PARSING:** - Purpose: Parse natural language scenarios into structured JSON arrays of API requests - Requirements: A natural language scenario description, API schema (OpenAPI/Swagger file or URL) - Features: Automatically breaks down any user-provided scenario into sequential API calls with request chaining - Output: Returns a JSON array where each element represents an API request with method, endpoint, parameters, and dependencies **Usage:** Describe any multi-step workflow in natural language, and the tool will parse it against your API schema to create a structured JSON array of API requests. Use this JSON output with other test generation tools. - Default Language: Python - Default Framework: Pytest - Supported Languages: Python, Java, JavaScript, TypeScript - Supported Frameworks: Pytest, Robot, JUnit, Playwright **Example Scenario Parsing:** Prompt: Generate scenario for Skyramp Demo Shop API whose schema is https://demoshop.skyramp.dev/openapi.json 1. create a new product called Skyramp Tester which costs $999, for the other fields chose reasonable values 2. then create an order with 1x Skyramp Tester Trace File: [ { "Source": "172.20.0.1:56948", "Destination": "demoshop.skyramp.dev", "RequestBody": "{\"name\":\"Skyramp Tester\",\"description\":\"Test Generation\",\"image_url\":\"images.google.com/skyramp.jpg\",\"category\":\"Software\",\"in_stock\":true,\"price\":999}", "ResponseBody": "{\"name\":\"Skyramp Tester\",\"description\":\"Test Generation\",\"price\":999.0,\"image_url\":\"images.google.com/skyramp.jpg\",\"category\":\"Software\",\"in_stock\":true,\"product_id\":24,\"created_at\":\"2025-09-29T15:18:35.844599Z\",\"updated_at\":\"2025-09-29T15:18:35.844595Z\"}", "RequestHeaders": { "Content-Type": [ "application/json" ], "Authorization": [ "Bearer flat-tropical-vapor" ] }, "ResponseHeaders": { "Content-Type": [ "application/json" ] }, "Method": "POST", "Path": "/api/v1/products", "QueryParams": {}, "StatusCode": 201, "Port": 443, "Timestamp": "2025-09-29T15:18:36.178356292Z", "Scheme": "https" }, { "Source": "172.20.0.1:59186", "Destination": "demoshop.skyramp.dev", "RequestBody": "{\"customer_email\":\"kolja@skyramp.dev\",\"items\":[{\"product_id\":\"24\",\"quantity\":1}]}", "ResponseBody": "{\"customer_email\":\"kolja@skyramp.dev\",\"status\":\"pending\",\"total_amount\":999.0,\"order_id\":13,\"items\":[{\"quantity\":1,\"product_id\":24,\"order_item_id\":24,\"order_id\":13}],\"created_at\":\"2025-09-29T15:18:51.024822\",\"updated_at\":\"2025-09-29T15:18:51.024827\"}", "RequestHeaders": { "Content-Type": [ "application/json" ], "Authorization": [ "Bearer flat-tropical-vapor" ] }, "ResponseHeaders": { "Content-Type": [ "application/json" ] }, "Method": "POST", "Path": "/api/v1/orders", "QueryParams": {}, "StatusCode": 201, "Port": 443, "Timestamp": "2025-09-29T15:18:51.328564007Z", "Scheme": "https" } ] **IMPORTANT:** - WHEN GENERATING TESTS USING TRACE, EXCLUDE THE PATHS THAT ARE NOT API ENDPOINTS. - FOR SCENARIO PARSING, ENSURE THAT THE GENERATED REQUEST BODIES IN THE TRACE FILE MATCH THE API SCHEMA. - FOR SCENARIO PARSING, ENSURE THAT THE ID FIELDS ARE PROPERLY CHAINED BETWEEN THE REQUESTS AND ALWAYS USE product_id=24. - FOR SCENARIO PARSING, ALWAYS REQUIRE AN API SCHEMA FOR ACCURATE ENDPOINT MAPPING. - SCENARIO PARSING ONLY RETURNS JSON ARRAYS - USE OTHER TOOLS FOR ACTUAL TEST GENERATION. **CRITICAL: FOR A SINGLE SCENARIO CREATE A SINGLE SCENARIO FILE WITH EACH STEP AS A JSON OBJECT IN THE ARRAY.** **CRITICAL: SHOW STEPS TO START/STOP PLAYWRIGHT TRACE COLLECTION FOR UI TESTS. NEVER SHOW THE CLI COMMANDS.** `, }, }, ], })); }