@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
106 lines (84 loc) • 4.45 kB
JavaScript
import { z } from "zod";
import { logger } from "../../utils/logger.js";
function getTestbotRecommendationPrompt(prTitle, prDescription, summaryOutputFile) {
return `<TITLE>${prTitle}</TITLE>
<DESCRIPTION>${prDescription}</DESCRIPTION>
Use the MCP tools offered by Skyramp MCP server to analyze the pull request title and description to come up with a business justification
case for this code change. Based on your analysis of the business case, perform
1. Get recommendations for new contract, e2e, smoke, load tests that can be generated by Skyramp MCP tools
2. Use Skyramp MCP to execute the tests and validate the results.
3. Generate a CONCISE summary to '${summaryOutputFile}' following this format:
- Brief list of new test types added and for which endpoint.
- List each test executed with pass/fail status and brief details
- List any test failures or bugs discovered (if none, write 'None')
Keep the summary brief and scannable. Avoid repeating code diff details that are already visible in the PR.
Use the skyramp-mcp tools available to you for test analysis, generation, and execution.`;
}
function getTestbotMaintenancePrompt(diffFile, testDirectory, summaryOutputFile) {
return `Based on the git diff in ${diffFile} file, perform the following test maintenance tasks:
1. Check if there are any relevant Skyramp tests in the '${testDirectory}' directory that correspond to the code changes.
2. If there are relevant tests, use Skyramp MCP tools to analyze and modify them to ensure they pass with the new changes.
3. If there are no tests that can validate the changes, use Skyramp MCP to generate appropriate Skyramp tests for the new or modified code.
4. Use Skyramp MCP to execute the tests and validate the results.
5. Generate a CONCISE summary to '${summaryOutputFile}' following this format:
**Tests Modified:** [number] | **Tests Created:** [number] | **Tests Executed:** [number] | **Passed:** [number] | **Failed:** [number]
- Brief one-line summary of test changes (details are in the commit)
### 🧪 Test Results
- List each test executed with pass/fail status and brief details
### ⚠️ Issues Found
- List any test failures or bugs discovered (if none, write 'None')
Keep the summary brief and scannable. Avoid repeating code diff details that are already visible in the PR.
Use the skyramp-mcp tools available to you for test analysis, generation, and execution.`;
}
export function registerTestbotPrompt(server) {
logger.info("Registering testbot prompt");
server.registerPrompt("skyramp_testbot", {
description: "Run Skyramp TestBot to generate test recommendations and perform test maintenance for a pull request.",
argsSchema: {
prTitle: z
.string()
.describe("Pull request title"),
prDescription: z
.string()
.describe("Pull request description/body"),
diffFile: z
.string()
.describe("Path to the git diff file"),
testDirectory: z
.string()
.default("tests")
.describe("Directory containing Skyramp tests"),
recommendationSummaryOutputFile: z
.string()
.describe("File path where the agent should write the recommendation summary"),
maintenanceSummaryOutputFile: z
.string()
.describe("File path where the agent should write the maintenance summary"),
},
}, (args) => {
const recommendationPrompt = getTestbotRecommendationPrompt(args.prTitle, args.prDescription, args.recommendationSummaryOutputFile);
const maintenancePrompt = getTestbotMaintenancePrompt(args.diffFile, args.testDirectory, args.maintenanceSummaryOutputFile);
return {
messages: [
{
role: "user",
content: {
type: "text",
text: `
Follow these two phases in order.
${recommendationPrompt}
${maintenancePrompt}`,
},
},
],
};
});
}