/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 9123ec3a1682
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import { MCPServerIcon, MCPServerIcon$inboundSchema } from "./mcpservericon.js";
import { MCPToolMeta, MCPToolMeta$inboundSchema } from "./mcptoolmeta.js";
import {
  ToolAnnotations,
  ToolAnnotations$inboundSchema,
} from "./toolannotations.js";
import { ToolExecution, ToolExecution$inboundSchema } from "./toolexecution.js";

export type MCPServerCardTool = {
  name: string;
  title?: string | null | undefined;
  description?: string | null | undefined;
  inputSchema: { [k: string]: any };
  outputSchema?: { [k: string]: any } | null | undefined;
  icons?: Array<MCPServerIcon> | null | undefined;
  annotations?: ToolAnnotations | null | undefined;
  meta?: MCPToolMeta | null | undefined;
  execution?: ToolExecution | null | undefined;
  [additionalProperties: string]: unknown;
};

/** @internal */
export const MCPServerCardTool$inboundSchema: z.ZodType<
  MCPServerCardTool,
  unknown
> = z.object({
  name: z.string(),
  title: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  inputSchema: z.record(z.string(), z.any()),
  outputSchema: z.nullable(z.record(z.string(), z.any())).optional(),
  icons: z.nullable(z.array(MCPServerIcon$inboundSchema)).optional(),
  annotations: z.nullable(ToolAnnotations$inboundSchema).optional(),
  _meta: z.nullable(MCPToolMeta$inboundSchema).optional(),
  execution: z.nullable(ToolExecution$inboundSchema).optional(),
}).catchall(z.any()).transform((v) => {
  return remap$(v, {
    "_meta": "meta",
  });
});

export function mcpServerCardToolFromJSON(
  jsonString: string,
): SafeParseResult<MCPServerCardTool, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => MCPServerCardTool$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'MCPServerCardTool' from JSON`,
  );
}
