generate_and_validate
Generate Adaptive Cards from natural language descriptions and validate them for compatibility with Microsoft Teams, Outlook, and other platforms in one step.
Instructions
Generate an Adaptive Card and immediately validate + optionally optimize it in a single call. Reduces tool-call overhead for common workflows.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Natural language description of the card to generate | |
| data | No | Optional structured data to incorporate | |
| host | No | Target host app | |
| intent | No | Card intent | |
| version | No | Target version. Default: 1.6 | |
| optimizeGoals | No | If provided, also optimize the card after generation |
Implementation Reference
- packages/core/src/server.ts:576-626 (handler)The core handler function for the 'generate_and_validate' tool, orchestrating card generation, validation, optimization, and version transformation.
async function handleGenerateAndValidate( input: GenerateAndValidateInput, ): Promise<Record<string, unknown>> { const { content, data, host = "generic", intent, version = "1.6", optimizeGoals } = input; // Step 1: Generate const genResult = await handleGenerateCard({ content, data, host: host as HostApp, intent: intent as any, version, }); let card = genResult.card; let validation = genResult.validation; let designNotes = genResult.designNotes; const stepsCompleted = ["generate", "validate"]; // Step 2: Optimize if requested if (optimizeGoals && optimizeGoals.length > 0) { const optResult = handleOptimizeCard({ card, goals: optimizeGoals, host: host as HostApp, }); card = optResult.card; designNotes += ` | Optimized for: ${optimizeGoals.join(", ")}`; stepsCompleted.push("optimize"); } // Step 3: Auto-downgrade version if host requires it if (host !== "generic") { const hostInfo = getHostSupport(host as HostApp); const cardVersion = String(card.version || "1.6"); if (hostInfo && cardVersion > hostInfo.maxVersion) { const txResult = handleTransformCard({ card, transform: "downgrade-version", targetVersion: hostInfo.maxVersion, }); card = txResult.card; stepsCompleted.push("transform"); } } // Re-validate after all modifications validation = handleValidateCard({ card, host: host as HostApp }); const cardId = storeCard(card, { tool: "generate_and_validate" }); - packages/core/src/server.ts:278-280 (registration)Registration of the 'generate_and_validate' tool definition in the server.
name: "generate_and_validate", description: "Generate an Adaptive Card and immediately validate + optionally optimize it in a single call. Reduces tool-call overhead for common workflows.", - Type definition for the input schema of the 'generate_and_validate' tool.
export interface GenerateAndValidateInput { content: string; data?: Record<string, unknown> | string; host?: HostApp; intent?: CardIntent; version?: string;