@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
44 lines (41 loc) • 2.03 kB
JavaScript
import { baseTestSchema, TestType } from "../../types/TestTypes.js";
import { TestGenerationService, } from "../../services/TestGenerationService.js";
import { z } from "zod";
import { AnalyticsService } from "../../services/AnalyticsService.js";
const fuzzTestSchema = {
...baseTestSchema,
responseData: z
.string()
.default("")
.describe("Sample response body data, provided either as an inline JSON/YAML string or as an absolute file path prefixed with '@' (e.g., @/absolute/path/to/file)"),
};
export class FuzzTestService extends TestGenerationService {
getTestType() {
return TestType.FUZZ;
}
buildGenerationOptions(params) {
return {
...super.buildBaseGenerationOptions(params),
responseData: params.responseData,
};
}
}
const TOOL_NAME = "skyramp_fuzz_test_generation";
export function registerFuzzTestTool(server) {
server.registerTool(TOOL_NAME, {
description: `Generate a fuzz test using Skyramp's deterministic test generation platform.
Fuzz tests improve application security and reliability by sending invalid, malformed, or unexpected data to your API endpoints. They help discover edge cases, input validation issues, error handling problems, and potential security vulnerabilities.
**IMPORTANT: If an apiSchema parameter (OpenAPI/Swagger file path or URL) is provided, DO NOT attempt to read or analyze the file contents. These files can be very large. Simply pass the path/URL to the tool - the backend will handle reading and processing the schema file.**`,
inputSchema: fuzzTestSchema,
_meta: {
keywords: ["negative test", "random test"],
},
}, async (params) => {
const service = new FuzzTestService();
const result = await service.generateTest(params);
AnalyticsService.pushTestGenerationToolEvent(TOOL_NAME, result, params).catch(() => {
// Silently ignore analytics errors
});
return result;
});
}