Skip to main content
Glama

optimize_card

Optimizes Adaptive Cards for accessibility, performance, and compatibility with Microsoft Teams, Outlook, and other platforms.

Instructions

Optimize an existing Adaptive Card. Accepts card JSON or a cardId.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardYesThe Adaptive Card JSON object or cardId to optimize
goalsNoOptimization goals. Default: all
hostNoTarget host app

Implementation Reference

  • The handleOptimizeCard function is the core handler for the 'optimize_card' tool. It receives a card and a set of optimization goals, iterates through the requested goals, applies corresponding optimization transformations, and returns the optimized card along with a report of the changes and performance improvements.
    export function handleOptimizeCard(input: OptimizeCardInput): OptimizeCardOutput {
      const { card, goals = ["accessibility", "performance", "modern"], host } = input;
    
      // Capture before metrics
      const statsBefore = analyzeCard(card);
      const accessBefore = checkAccessibility(card);
    
      // Deep clone the card for mutation
      const optimized = JSON.parse(JSON.stringify(card)) as Record<string, unknown>;
      const changes: Change[] = [];
    
      // Apply each optimization goal in order
      for (const goal of goals) {
        switch (goal) {
          case "accessibility":
            optimizeAccessibility(optimized, changes);
            break;
          case "performance":
            optimizePerformance(optimized, changes);
            break;
          case "compact":
            optimizeCompact(optimized, changes);
            break;
          case "modern":
            optimizeModern(optimized, changes);
            break;
          case "readability":
            optimizeReadability(optimized, changes);
            break;
        }
      }
    
      // Capture after metrics
      const statsAfter = analyzeCard(optimized);
      const accessAfter = checkAccessibility(optimized);
    
      return {
        card: optimized,
        changes,
        improvement: {
          accessibilityBefore: accessBefore.score,
          accessibilityAfter: accessAfter.score,
          elementCountBefore: statsBefore.elementCount,
          elementCountAfter: statsAfter.elementCount,
          nestingDepthBefore: statsBefore.nestingDepth,
          nestingDepthAfter: statsAfter.nestingDepth,
        },
      };
    }

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