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,
        },
      };
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries full burden but offers minimal behavioral insight. It doesn't disclose whether optimization is destructive (e.g., alters original structure irreversibly), requires specific permissions, has rate limits, or what the output looks like (e.g., returns optimized JSON or a success message). For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with zero waste—it directly states the tool's function and input options. It's appropriately sized and front-loaded, making it easy to scan and understand quickly without unnecessary elaboration.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of a mutation tool with 3 parameters, no annotations, and no output schema, the description is incomplete. It lacks details on behavioral traits (e.g., side effects, error handling), output format, and usage context relative to siblings. This leaves significant gaps for an agent to invoke the tool correctly in a multi-tool environment.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents all parameters ('card', 'goals', 'host') with details like enums and defaults. The description adds marginal value by implying 'card' can be JSON or an ID, but doesn't provide additional context beyond what's in the schema, such as examples or edge cases for the 'card' parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('optimize') and target resource ('an existing Adaptive Card'), distinguishing it from siblings like 'generate_card' or 'validate_card'. However, it doesn't specify what optimization entails (e.g., restructuring, minifying, or improving compatibility), leaving some ambiguity about the exact transformation performed.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives like 'suggest_layout' or 'transform_card'. The description mentions it accepts 'card JSON or a cardId', but doesn't clarify prerequisites (e.g., whether the card must be valid first) or differentiate its optimization focus from other card-modification tools in the sibling list.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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