generate_card
Convert natural language descriptions or structured data into valid Adaptive Card JSON for Microsoft Teams, Outlook, and other platforms, returning a card ID for reference.
Instructions
Convert any content — natural language description, structured data, or a combination — into a valid Adaptive Card v1.6 JSON. Returns cardId for reference in subsequent tool calls.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| content | Yes | Natural language description of the card to generate, or paste raw data/text. | |
| data | No | Optional structured data (JSON object or CSV string) to incorporate into the card | |
| host | No | Target host app. Default: generic | |
| theme | No | Theme for styling hints | |
| intent | No | The intent of the card — helps select the best layout pattern | |
| version | No | Target Adaptive Card schema version. Default: "1.6" |
Implementation Reference
- The primary handler function 'handleGenerateCard' responsible for orchestrating the generation of Adaptive Cards, including choosing between LLM-based and deterministic approaches, validating the output, and generating supporting context references.
export async function handleGenerateCard( input: GenerateCardInput, ): Promise<GenerateCardOutput> { const { content, data, host = "generic", intent, version = "1.6" } = input; let card: Record<string, unknown>; let designNotes: string; // Try LLM generation first if available if (isLLMAvailable()) { try { const result = await generateCardWithLLM(input); card = result.card; designNotes = result.designNotes; } catch (err) { // Fallback to deterministic generation card = assembleCard({ content, data: data as unknown, intent, host, version, }); designNotes = `Deterministic generation (LLM fallback due to: ${err instanceof Error ? err.message : "unknown error"}). Pattern-matched card based on content analysis.`; } } else { // Deterministic generation card = assembleCard({ content, data: data as unknown, intent, host, version, }); designNotes = "Deterministic generation (no LLM API key). Card assembled from pattern matching and data analysis. Set ANTHROPIC_API_KEY or OPENAI_API_KEY for AI-powered generation."; } // Validate the generated card const validation = handleValidateCard({ card, host }); // Add reference context for MCP clients const examples = selectExamples(content, 3); const references: GenerateCardOutput["references"] = { examples: examples.map(ex => ({ name: ex.name, description: `Example: ${ex.tags.slice(0, 3).join(", ")}`, card: ex.content, })), }; if (host && host !== "generic") { const hostInfo = getHostSupport(host); references.hostConstraints = { maxVersion: hostInfo.maxVersion, unsupportedElements: hostInfo.unsupportedElements, maxActions: hostInfo.maxActions, notes: hostInfo.notes, }; } return { card, validation, designNotes, references, }; }