@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
39 lines (36 loc) • 1.58 kB
JavaScript
import { z } from "zod";
import { baseTestSchema } from "../types/TestTypes.js";
import { TestGenerationService, } from "../services/TestGenerationService.js";
const contractTestSchema = {
...baseTestSchema,
assertOptions: z
.string()
.optional()
.describe("Custom assertion options for contract validation"),
responseData: z
.string()
.optional()
.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 ContractTestService extends TestGenerationService {
getTestType() {
return "contract";
}
buildGenerationOptions(params) {
return {
...super.buildBaseGenerationOptions(params),
assertOptions: params.assertOptions,
};
}
}
export function registerContractTestTool(server) {
server.registerTool("skyramp_contract_test_generation", {
description: `Generate a contract test using Skyramp's deterministic test generation platform.
Contract tests ensure your API implementation matches its OpenAPI/Swagger specification exactly. They validate request/response schemas, status codes, headers, and data types to prevent contract violations and API breaking changes.
For detailed documentation visit: https://www.skyramp.dev/docs/contract-test`,
inputSchema: contractTestSchema,
}, async (params) => {
const service = new ContractTestService();
return await service.generateTest(params);
});
}