Skip to main content
Glama

suggest_layout

Recommends optimal Adaptive Card layouts based on your content description, target platform, and interactivity needs to build effective cards.

Instructions

Recommend the best Adaptive Card layout pattern for a given description.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionYesDescribe the card you want to build
constraintsNo

Implementation Reference

  • The handler function 'handleSuggestLayout' which takes the description and constraints input, computes a scored pattern, builds a layout description, generates a rationale, and returns the best pattern along with alternatives.
    export function handleSuggestLayout(input: SuggestLayoutInput): SuggestLayoutOutput {
      const { description, constraints } = input;
    
      const scored = scorePatterns(description);
    
      if (scored.length === 0 || scored[0].score === 0) {
        // No strong match — return a generic suggestion
        return {
          suggestion: {
            pattern: "notification",
            elements: ["TextBlock", "ActionSet"],
            layout: "Simple vertical layout with a title, body text, and optional actions. Best for general-purpose content.",
            rationale:
              "No specific layout pattern strongly matched your description. The notification pattern is the most versatile starting point. Refine your description with keywords like 'table', 'form', 'dashboard', 'approval', 'list', 'profile', 'chart', or 'gallery' for more targeted suggestions.",
          },
          alternatives: buildAlternatives(scored.slice(0, 3), constraints),
        };
      }
    
      const best = scored[0];
      const pattern = best.pattern;
    
      // Check host compatibility if specified
      let hostWarning = "";
      if (constraints?.targetHost) {
        const support = getHostSupport(constraints.targetHost);
        const unsupportedInPattern = pattern.elements.filter((el) =>
          support.unsupportedElements.includes(el),
        );
        if (unsupportedInPattern.length > 0) {
          hostWarning = ` Note: ${unsupportedInPattern.join(", ")} not supported on ${constraints.targetHost}. Alternative elements will be needed.`;
        }
      }
    
      // Build layout description
      const layout = buildLayoutDescription(pattern.name, pattern.elements, pattern.dataShape);
    
      // Build rationale
      const rationale = buildRationale(pattern, description, constraints) + hostWarning;
    
      const suggestion: LayoutSuggestion = {
        pattern: pattern.name,
        elements: pattern.elements,
        layout,
        rationale,
        similarExample: pattern.example,
      };
    
      // Build alternatives from the next best matches (excluding the top pick)
      const altCandidates = scored
        .slice(1)
        .filter((s) => s.score > 0)
        .slice(0, 3);
    
      const alternatives = buildAlternatives(altCandidates, constraints);
    
      return { suggestion, alternatives };
    }

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