transform_card
Convert Adaptive Cards between versions, apply host-specific configurations, or flatten nested structures.
Instructions
Transform an Adaptive Card: upgrade/downgrade version, apply host-specific constraints, or flatten nesting.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| card | Yes | The Adaptive Card JSON object or cardId to transform | |
| transform | Yes | The type of transformation to apply | |
| targetVersion | No | Target version for upgrade/downgrade (e.g., "1.3", "1.5", "1.6") | |
| targetHost | No | Target host |
Implementation Reference
- Main handler function for the transform_card tool. Accepts a card and a transform type (upgrade-version, downgrade-version, apply-host-config, or flatten) and dispatches to the appropriate internal transformation function.
export function handleTransformCard(input: TransformCardInput): TransformCardOutput { const { card, transform, targetVersion, targetHost } = input; const result = JSON.parse(JSON.stringify(card)) as Record<string, unknown>; const changes: string[] = []; const warnings: string[] = []; switch (transform) { case "upgrade-version": upgradeVersion(result, targetVersion || "1.6", changes, warnings); break; case "downgrade-version": downgradeVersion(result, targetVersion || "1.3", changes, warnings); break; case "apply-host-config": applyHostConfig(result, targetHost || "teams", changes, warnings); break; case "flatten": flattenCard(result, changes, warnings); break; } return { card: result, changes, warnings }; } - Input type interface for transform_card: card (object), transform (union type), optional targetVersion, targetHost, hostConfig.
export interface TransformCardInput { card: Record<string, unknown>; transform: TransformType; targetVersion?: string; targetHost?: HostApp; hostConfig?: Record<string, unknown>; } - TransformType union type defining the four allowed transform values: upgrade-version, downgrade-version, apply-host-config, flatten.
export type TransformType = | "upgrade-version" | "downgrade-version" | "apply-host-config" | "flatten"; - Output type interface for transform_card: card (object), changes (string array), warnings (string array).
export interface TransformCardOutput { card: Record<string, unknown>; changes: string[]; warnings: string[]; } - packages/core/src/server.ts:230-253 (registration)Tool registration entry in the TOOLS array. Defines name 'transform_card', description, and JSON input schema with card (required), transform (enum of 4 values, required), targetVersion (optional string), targetHost (optional enum).
{ name: "transform_card", description: "Transform an Adaptive Card: upgrade/downgrade version, apply host-specific constraints, or flatten nesting.", inputSchema: { type: "object" as const, properties: { card: { description: "The Adaptive Card JSON object or cardId to transform", }, transform: { type: "string", enum: ["upgrade-version", "downgrade-version", "apply-host-config", "flatten"], description: "The type of transformation to apply", }, targetVersion: { type: "string", description: 'Target version for upgrade/downgrade (e.g., "1.3", "1.5", "1.6")', }, targetHost: { type: "string", enum: HOST_ENUM, description: "Target host" }, }, required: ["card", "transform"], }, }, - packages/core/src/server.ts:429-434 (registration)Server dispatch case for 'transform_card': calls handleTransformCard, stores the card, and returns result with cardId.
case "transform_card": { const txResult = handleTransformCard(parsed as any); const cardId = storeCard(txResult.card, { tool: "transform_card" }); result = { ...txResult, cardId }; break; }