Skip to main content
Glama
handlers-from-test-plan.ts2.56 kB
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { z } from "zod"; import { createTestCasesFromTestPlan } from "./api"; import type { ToolResponse } from "./handlers"; import { logger } from "./logger"; import { CreateFromTestPlanOptions } from "./types"; export interface FromTestPlanParams { testTargetId: string; inputText: string; imageUrls: string[]; tagNames: string[]; prerequisiteId?: string; environmentId?: string; executionUrl?: string; } export class FromTestPlanHandler { async execute( params: FromTestPlanParams, sessionId: string | undefined, ): Promise<ToolResponse> { logger.debug({ params }, "Creating test cases from test plan"); const options: CreateFromTestPlanOptions = { sessionId, testTargetId: params.testTargetId, inputText: params.inputText, imageUrls: params.imageUrls, tagNames: params.tagNames, prerequisiteId: params.prerequisiteId, environmentId: params.environmentId, executionUrl: params.executionUrl, }; const res = await createTestCasesFromTestPlan(options); logger.debug({ res }, "Created from test plan generation"); return { content: [ { type: "text", text: `Created from-test-plan generation for: ${params.testTargetId}`, }, { type: "text", text: JSON.stringify(res) }, ], }; } } export function registerFromTestPlanTool( server: McpServer, handler: FromTestPlanHandler, ): void { server.tool( "createFromTestPlan", `create test cases from a test plan for a given test target. Provide freeform text, related images and tag names to assign`, { testTargetId: z .string() .uuid() .describe("Unique identifier of the test target"), inputText: z.string().describe("Freeform input text from the test plan"), imageUrls: z .array(z.string().url()) .describe("Images referenced in the test plan"), tagNames: z .array(z.string()) .describe("Tags to assign to generated test cases"), prerequisiteId: z .string() .optional() .describe("Unique identifier of the prerequisite test case"), environmentId: z .string() .optional() .describe("Unique identifier of the environment"), executionUrl: z .string() .optional() .describe("URL to execute the test cases"), }, async (params, { sessionId }) => handler.execute(params, sessionId), ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/OctoMind-dev/octomind-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server