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

import * as z from "zod/v4";
import { safeParse } from "../../lib/schemas.js";
import * as openEnums from "../../types/enums.js";
import { OpenEnum } from "../../types/enums.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  MCPServerAuthenticationRequirement,
  MCPServerAuthenticationRequirement$inboundSchema,
} from "./mcpserverauthenticationrequirement.js";
import {
  MCPServerRemoteHeader,
  MCPServerRemoteHeader$inboundSchema,
} from "./mcpserverremoteheader.js";

/**
 * Transport type
 */
export const MCPServerRemoteType = {
  StreamableHttp: "streamable-http",
  Sse: "sse",
} as const;
/**
 * Transport type
 */
export type MCPServerRemoteType = OpenEnum<typeof MCPServerRemoteType>;

/**
 * Remote transport endpoint (SEP-2127).
 */
export type MCPServerRemote = {
  /**
   * Transport type
   */
  type: MCPServerRemoteType;
  /**
   * Transport endpoint URL
   */
  url: string;
  supportedProtocolVersions?: Array<string> | null | undefined;
  headers?: Array<MCPServerRemoteHeader> | null | undefined;
  authentication?: MCPServerAuthenticationRequirement | null | undefined;
};

/** @internal */
export const MCPServerRemoteType$inboundSchema: z.ZodType<
  MCPServerRemoteType,
  unknown
> = openEnums.inboundSchema(MCPServerRemoteType);

/** @internal */
export const MCPServerRemote$inboundSchema: z.ZodType<
  MCPServerRemote,
  unknown
> = z.object({
  type: MCPServerRemoteType$inboundSchema,
  url: z.string(),
  supportedProtocolVersions: z.nullable(z.array(z.string())).optional(),
  headers: z.nullable(z.array(MCPServerRemoteHeader$inboundSchema)).optional(),
  authentication: z.nullable(MCPServerAuthenticationRequirement$inboundSchema)
    .optional(),
});

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