Skip to main content
Glama

generate_and_validate

Generates an Adaptive Card from a natural language description, then validates it against the target host and optionally optimizes it—all in one call to reduce overhead.

Instructions

Generate an Adaptive Card and immediately validate + optionally optimize it in a single call. Reduces tool-call overhead for common workflows.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYesNatural language description of the card to generate
dataNoOptional structured data to incorporate
hostNoTarget host app
intentNoCard intent
versionNoTarget version. Default: 1.6
optimizeGoalsNoIf provided, also optimize the card after generation

Implementation Reference

  • The main handler function for the generate_and_validate tool. It calls handleGenerateCard, optionally optimizes via handleOptimizeCard, auto-downgrades version if needed, re-validates, and returns the result with cardId.
    async function handleGenerateAndValidate(
      input: GenerateAndValidateInput,
    ): Promise<Record<string, unknown>> {
      const { content, data, host = "generic", intent, version = "1.6", optimizeGoals } = input;
    
      // Step 1: Generate
      const genResult = await handleGenerateCard({
        content,
        data,
        host: host as HostApp,
        intent: intent as any,
        version,
      });
    
      let card = genResult.card;
      let validation = genResult.validation;
      let designNotes = genResult.designNotes;
      const stepsCompleted = ["generate", "validate"];
    
      // Step 2: Optimize if requested
      if (optimizeGoals && optimizeGoals.length > 0) {
        const optResult = handleOptimizeCard({
          card,
          goals: optimizeGoals,
          host: host as HostApp,
        });
        card = optResult.card;
        designNotes += ` | Optimized for: ${optimizeGoals.join(", ")}`;
        stepsCompleted.push("optimize");
      }
    
      // Step 3: Auto-downgrade version if host requires it
      if (host !== "generic") {
        const hostInfo = getHostSupport(host as HostApp);
        const cardVersion = String(card.version || "1.6");
        if (hostInfo && cardVersion > hostInfo.maxVersion) {
          const txResult = handleTransformCard({
            card,
            transform: "downgrade-version",
            targetVersion: hostInfo.maxVersion,
          });
          card = txResult.card;
          stepsCompleted.push("transform");
        }
      }
    
      // Re-validate after all modifications
      validation = handleValidateCard({ card, host: host as HostApp });
    
      const cardId = storeCard(card, { tool: "generate_and_validate" });
    
      return {
        card,
        cardId,
        validation,
        stepsCompleted,
        designNotes,
      };
    }
  • Input schema definition for the generate_and_validate tool, specifying content (required), data, host, intent, version, and optimizeGoals.
    {
      name: "generate_and_validate",
      description:
        "Generate an Adaptive Card and immediately validate + optionally optimize it in a single call. Reduces tool-call overhead for common workflows.",
      inputSchema: {
        type: "object" as const,
        properties: {
          content: {
            type: "string",
            description: "Natural language description of the card to generate",
          },
          data: {
            description: "Optional structured data to incorporate",
          },
          host: { type: "string", enum: HOST_ENUM, description: "Target host app" },
          intent: {
            type: "string",
            enum: [
              "display", "approval", "form", "notification", "dashboard",
              "report", "status", "profile", "list", "gallery",
            ],
            description: "Card intent",
          },
          version: { type: "string", description: "Target version. Default: 1.6" },
          optimizeGoals: {
            type: "array",
            items: {
              type: "string",
              enum: ["accessibility", "performance", "compact", "modern", "readability"],
            },
            description: "If provided, also optimize the card after generation",
          },
        },
        required: ["content"],
      },
  • TypeScript interface for GenerateAndValidateInput, defining the types for content, data, host, intent, version, and optimizeGoals.
    export interface GenerateAndValidateInput {
      content: string;
      data?: Record<string, unknown> | string;
      host?: HostApp;
      intent?: CardIntent;
      version?: string;
      optimizeGoals?: OptimizationGoal[];
    }
  • Switch-case in the tool dispatcher that routes 'generate_and_validate' tool calls to the handleGenerateAndValidate handler.
    case "generate_and_validate": {
      result = await handleGenerateAndValidate(parsed as unknown as GenerateAndValidateInput);
      break;
  • Rate limiter configuration mapping tool names to bucket config; generate_and_validate uses the same LLM_TOOL_CONFIG as other LLM tools.
    const toolConfigs = new Map<string, BucketConfig>([
      ["generate_card", LLM_TOOL_CONFIG],
      ["data_to_card", LLM_TOOL_CONFIG],
      ["generate_and_validate", LLM_TOOL_CONFIG],
      ["card_workflow", LLM_TOOL_CONFIG],
    ]);
Behavior2/5

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

With no annotations, the description carries full burden but lacks disclosure of what happens on validation failure, side effects, or state changes. 'Immediately validate' is vague, and there is no mention of permissions or return behavior, leaving important behavioral traits ambiguous.

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 two sentences, front-loaded with primary purpose. Every sentence adds value with no redundancy, achieving high efficiency.

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?

The tool combines generation, validation, and optional optimization but provides no details about return values, validation results, or optimization output. Without an output schema, the description leaves critical contextual gaps for an AI agent.

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 coverage is 100% with all parameters described. The description adds the overall workflow context but does not significantly enhance parameter meaning beyond the schema. Baseline 3 is appropriate.

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

Purpose5/5

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

The description clearly states it generates, validates, and optionally optimizes an Adaptive Card in one call. It effectively distinguishes from siblings like generate_card, validate_card, and optimize_card by combining these steps, which is a specific verb+resource combo.

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

Usage Guidelines4/5

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

The description implies use when you want to generate and validate (and optionally optimize) together, reducing overhead. It provides clear context for the combined workflow but does not explicitly state when to use separate tools or exclude cases.

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