Skip to main content
Glama

validate_card

Validate Adaptive Card JSON against the v1.6 schema, returning diagnostics with suggested fixes for errors and checking host compatibility.

Instructions

Validate an Adaptive Card JSON against the v1.6 schema. Returns diagnostics with suggested fixes for each error. Accepts card JSON or a cardId from a previous tool call.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cardYesThe Adaptive Card JSON object to validate, or a cardId string
hostNoCheck compatibility with this host app. Default: generic
strictModeNoWhen true, warnings are treated as errors. Default: false

Implementation Reference

  • The handler function 'handleValidateCard' for the 'validate_card' tool. It performs schema validation, card analysis, accessibility checks, and host compatibility checks, returning a combined validation result.
    export function handleValidateCard(input: ValidateCardInput): ValidationResult {
      const { card, host = "generic", strictMode = false } = input;
    
      // Schema validation
      const schemaResult = validateCard(card);
    
      // Card analysis
      const stats = analyzeCard(card);
    
      // Accessibility check
      const accessibility = checkAccessibility(card);
    
      // Host compatibility
      const hostCompatibility = checkHostCompatibility(card, host);
    
      // Structural best-practice checks
      const errors: ValidationError[] = [...schemaResult.errors];
    
      // Enrich schema errors with suggested fixes
      for (const error of errors) {
        error.suggestedFix = getSuggestedFix(error);
      }
    
      // Check duplicate IDs
      const dupeIds = findDuplicateIds(card);
      for (const id of dupeIds) {
        errors.push({
          path: `(id="${id}")`,
          message: `Duplicate element ID: "${id}"`,
          severity: "error",
          rule: "duplicate-id",
          suggestedFix: {
            description: `Rename one of the elements with id="${id}" to a unique value`,
            patch: { id: `${id}_2` },
          },
        });
      }
    
      // Nesting depth warning
      if (stats.nestingDepth > 5) {
        errors.push({
          path: "$.body",
          message: `Nesting depth is ${stats.nestingDepth} (recommended max: 5)`,
          severity: "warning",
          rule: "nesting-depth",
          suggestedFix: {
            description: "Use the transform_card tool with transform: 'flatten' to reduce nesting",
          },
        });
      }
    
      // Element count warning
      if (stats.elementCount > 50) {
        errors.push({
          path: "$.body",
          message: `Card has ${stats.elementCount} elements (recommended max: 50)`,
          severity: "warning",
          rule: "element-count",
          suggestedFix: {
            description: "Use optimize_card with goals: ['performance', 'compact'] to reduce element count",
          },
        });
      }
    
      // Best practice: Action.Submit deprecation
      if (stats.actionTypes.includes("Action.Submit")) {
        errors.push({
          path: "(actions)",
          message: "Consider using Action.Execute instead of Action.Submit for Universal Actions support",
          severity: "info",
          rule: "prefer-execute",
          suggestedFix: {
            description: "Use optimize_card with goals: ['modern'] to automatically replace Action.Submit with Action.Execute",
          },
        });
      }
    
      // Host compatibility as errors/warnings with suggested fixes
      for (const unsupported of hostCompatibility.unsupportedElements) {
        errors.push({
          path: unsupported.path,
          message: unsupported.reason,
          severity: strictMode ? "error" : "warning",
          rule: "host-compatibility",
          suggestedFix: {
            description: `Use transform_card with transform: 'apply-host-config' and targetHost: '${host}' to auto-adapt`,
          },
        });
      }
    
      // Accessibility issue suggestions
      for (const issue of accessibility.issues) {
        const existingError = errors.find((e) => e.message === issue);
        if (!existingError) {
          errors.push({
            path: extractPathFromIssue(issue),
            message: issue,
            severity: "info",
            rule: "accessibility",
            suggestedFix: {
              description: "Use optimize_card with goals: ['accessibility'] to auto-fix accessibility issues",
            },
          });
        }
      }
    
      const hasErrors = errors.some((e) => e.severity === "error");
      const hasWarnings = errors.some((e) => e.severity === "warning");
    
      return {
        valid: strictMode ? !hasErrors && !hasWarnings : !hasErrors,
        errors,
        accessibility,
        hostCompatibility,
        stats,
      };
    }
Behavior3/5

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

No annotations are provided, so the description carries the full burden. It discloses the tool's behavior by stating it validates against a specific schema (v1.6) and returns diagnostics with fixes, but it lacks details on error handling, performance, or rate limits. The description does not contradict any annotations.

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 front-loaded with the core purpose and outcome in the first sentence, followed by additional context in the second. Both sentences are essential, with zero waste, making it highly efficient and well-structured.

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

Completeness3/5

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

Given the complexity (validation tool with 3 parameters, no output schema, and no annotations), the description is adequate but has gaps. It explains the purpose and input flexibility but does not detail output format, error cases, or integration with sibling tools. It meets minimum viability but lacks completeness for optimal agent use.

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 thoroughly. The description adds marginal value by clarifying that the 'card' parameter can be 'JSON or a cardId from a previous tool call,' but this is somewhat redundant with the schema's description. Baseline 3 is appropriate as the schema does the heavy lifting.

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 the specific action ('validate'), the resource ('Adaptive Card JSON against the v1.6 schema'), and the outcome ('returns diagnostics with suggested fixes for each error'). It also distinguishes itself from siblings by focusing on validation rather than generation, optimization, or transformation.

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

Usage Guidelines3/5

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

The description implies usage by mentioning it 'accepts card JSON or a cardId from a previous tool call,' which suggests integration in a workflow. However, it does not explicitly state when to use this tool versus alternatives like 'generate_and_validate' or 'optimize_card,' nor does it provide exclusions or prerequisites.

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