@skyramp/mcp
Version:
Skyramp MCP (Model Context Protocol) Server - AI-powered test generation and execution
109 lines (104 loc) • 4.75 kB
JavaScript
import { z } from "zod";
import { SkyrampClient } from "@skyramp/skyramp";
import openProxyTerminalTracked from "../utils/proxy-terminal.js";
import { TELEMETRY_entrypoint_FIELD_NAME } from "../utils/utils.js";
import { logger } from "../utils/logger.js";
export function registerTraceTool(server) {
server.registerTool("skyramp_start_trace_collection", {
description: `Start trace collection using Skyramp's comprehensive tracing capabilities.
Trace collection monitors your application in real-time to capture user interactions, API calls, service communications, and data flows. This captured data is then used to generate comprehensive integration, load, and E2E tests that reflect real-world usage patterns.
COLLECTION TYPES:
• UI-Only Tracing: Captures frontend user interactions for UI test generation
• Backend-Only Tracing: Records API calls and service communications for integration tests
• Full-Stack Tracing: Combines UI and backend tracing for comprehensive E2E test generation
WORKFLOW:
1. Start trace collection with desired configuration
2. Interact with your application (UI clicks, API calls, workflows)
3. Stop trace collection to save captured data
4. Use traces to generate realistic test scenarios
For detailed documentation visit: https://www.skyramp.dev/docs/load-test/advanced-generation#start-trace-collection`,
inputSchema: {
playwright: z
.boolean()
.describe("Whether to enable Playwright for trace collection. Set to true for UI interactions, false for API-only tracing")
.default(true),
runtime: z
.string()
.default("docker")
.describe("Runtime environment for trace collection. Currently only 'docker' is supported and is used as the default."),
include: z
.array(z.string())
.default([])
.describe("List of service names or patterns to include in trace collection"),
exclude: z
.array(z.string())
.default([])
.describe("List of service names or patterns to exclude from trace collection"),
noProxy: z
.array(z.string())
.default([])
.describe("List of hosts or patterns that should bypass proxy during tracing"),
dockerNetwork: z
.string()
.default("")
.describe("Docker network name to use for containerized trace collection"),
dockerWorkerPort: z
.number()
.default(35142)
.describe("Port number for the Docker worker service during trace collection"),
prompt: z
.string()
.describe("The prompt user provided to start trace collection"),
},
annotations: {
keywords: ["start trace", "trace collection", "trace generation"],
},
}, async (params) => {
logger.info("Starting trace collection", {
playwright: params.playwright,
runtime: params.runtime,
include: params.include,
exclude: params.exclude,
noProxy: params.noProxy,
dockerNetwork: params.dockerNetwork,
dockerWorkerPort: params.dockerWorkerPort,
prompt: params.prompt,
});
const client = new SkyrampClient();
const generateOptions = {
testType: "trace",
runtime: params.runtime ?? "docker",
dockerNetwork: params.dockerNetwork ?? "skyramp",
dockerWorkerPort: (params.dockerWorkerPort ?? 35142).toString(),
generateInclude: params.include,
generateExclude: params.exclude,
generateNoProxy: params.noProxy,
unblock: true,
playwright: params.playwright,
entrypoint: TELEMETRY_entrypoint_FIELD_NAME,
};
try {
const result = await client.generateRestTest(generateOptions);
await openProxyTerminalTracked();
return {
content: [
{
type: "text",
text: `Trace collection started: ${result}. Please let me know when you are ready to stop the trace collection.`,
},
],
};
}
catch (error) {
return {
content: [
{
type: "text",
text: `Trace generation failed: ${error.message}`,
},
],
isError: true,
};
}
});
}