Skip to main content
Glama

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
NameRequiredDescriptionDefault
contentYesNatural language description of the card to generate, or paste raw data/text.
dataNoOptional structured data (JSON object or CSV string) to incorporate into the card
hostNoTarget host app. Default: generic
themeNoTheme for styling hints
intentNoThe intent of the card — helps select the best layout pattern
versionNoTarget 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,
      };
    }

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/VikrantSingh01/adaptive-cards-mcp'

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