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

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 {
  ToolAnnotations,
  ToolAnnotations$inboundSchema,
} from "./toolannotations.js";
import { ToolExecution, ToolExecution$inboundSchema } from "./toolexecution.js";

export type MCPToolMeta = {
  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 MCPToolMeta$inboundSchema: z.ZodType<MCPToolMeta, 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(z.lazy(() => MCPToolMeta$inboundSchema)).optional(),
    execution: z.nullable(ToolExecution$inboundSchema).optional(),
  }).catchall(z.any()).transform((v) => {
    return remap$(v, {
      "_meta": "meta",
    });
  });

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