import {z} from 'zod' export type AIGatewayMCPServerRouteWithMatcher = {headers?: {[key: string]: unknown} | undefined, hosts?: Array | undefined, https_redirect_status_code?: number | undefined, methods?: Array | undefined, paths?: Array | undefined, preserve_host?: boolean | undefined, protocols?: Array | undefined, regex_priority?: number | undefined, request_buffering?: boolean | undefined, response_buffering?: boolean | undefined, strip_path?: boolean | undefined, tags?: Array | undefined}; export type AIGatewayUpstreamConfig = {auth?: ({type: 'aws', access_key_id?: string | undefined, secret_access_key?: string | undefined, session_token?: string | undefined, region?: string | undefined, assume_role_arn?: string | undefined, role_session_name?: string | undefined, sts_endpoint_url?: string | undefined}) | undefined}; export type AIGatewayMCPServerWithUpstreamNoProxyConfigNoServerConfig = {route?: AIGatewayMCPServerRouteWithMatcher | undefined, logging?: ({payloads?: boolean | undefined, audits?: boolean | undefined}) | undefined, max_request_body_size?: number | undefined, url: string, upstream?: AIGatewayUpstreamConfig | undefined}; export type AIGatewayMCPACLs = {allow?: Array | undefined, deny?: Array | undefined}; export type AIGatewayMCPToolAccess = {acls?: AIGatewayMCPACLs | undefined}; export type AIGatewayMCPToolAnnotations = {destructive_hint?: boolean | undefined, idempotent_hint?: boolean | undefined, open_world_hint?: boolean | undefined, read_only_hint?: boolean | undefined, title?: string | undefined}; export type AIGatewayMCPToolHeaders = {[key: string]: unknown}; export type AIGatewayMCPToolQuery = {[key: string]: unknown}; export type AIGatewayMCPToolRequestBody = {[key: string]: unknown}; export type AIGatewayMCPToolResponses = {[key: string]: unknown}; export type AIGatewayMCPToolParameter = {name: string, in: 'query' | 'path' | 'header' | 'body', description?: string | undefined, required?: boolean | undefined, schema?: {[key: string]: unknown} | undefined}; export type AIGatewayMCPToolParameters = Array; export type AIGatewayMCPConversionTool = {access?: AIGatewayMCPToolAccess | undefined, annotations?: AIGatewayMCPToolAnnotations | undefined, description: string, name: string, headers?: AIGatewayMCPToolHeaders | undefined, host?: (string | null) | undefined, method: 'DELETE' | 'GET' | 'PATCH' | 'POST' | 'PUT', path?: (string | null) | undefined, query?: AIGatewayMCPToolQuery | undefined, request_body?: AIGatewayMCPToolRequestBody | undefined, responses?: AIGatewayMCPToolResponses | undefined, scheme?: ('http' | 'https') | undefined, parameters?: AIGatewayMCPToolParameters | undefined}; export type AIGatewayEntityIdentifier = string; export type AIGatewayPolicyReferences = Array; export type PublicLabels = {[key: string]: string}; export type ManagedBy = {[key: string]: string}; export type AIGatewayRedisAWSAuthentication = {type: 'aws', access_key_id?: (string | null) | undefined, assume_role_arn?: (string | null) | undefined, cache_name?: (string | null) | undefined, is_serverless?: boolean | undefined, region?: (string | null) | undefined, role_session_name?: (string | null) | undefined, secret_access_key?: (string | null) | undefined}; export type AIGatewayRedisAzureAuthentication = {type: 'azure', client_id?: (string | null) | undefined, client_secret?: (string | null) | undefined, tenant_id?: (string | null) | undefined}; export type AIGatewayRedisGCPAuthentication = {type: 'gcp', service_account_json?: (string | null) | undefined}; export type AIGatewayRedisCloudConfiguration = {cloud_authentication?: (AIGatewayRedisAWSAuthentication | AIGatewayRedisAzureAuthentication | AIGatewayRedisGCPAuthentication) | undefined, cluster?: ({max_redirections?: number | undefined, nodes?: (Array<{ip?: string | undefined, port?: number | undefined}> | null) | undefined} | null) | undefined, connect_timeout?: number | undefined, connection_is_proxied?: boolean | undefined, database?: number | undefined, host?: string | undefined, keepalive?: ({backlog?: (number | null) | undefined, pool_size?: number | undefined} | null) | undefined, password?: (string | null) | undefined, port?: string | undefined, read_timeout?: number | undefined, send_timeout?: number | undefined, sentinel?: ({master?: (string | null) | undefined, nodes?: (Array<{host?: string | undefined, port?: number | undefined}> | null) | undefined, password?: (string | null) | undefined, role?: ('any' | 'master' | 'slave') | undefined, username?: (string | null) | undefined} | null) | undefined, server_name?: (string | null) | undefined, ssl?: boolean | undefined, ssl_verify?: boolean | undefined, username?: (string | null) | undefined}; export type AIGatewayMCPServerServerConfigBase = {forward_client_headers?: boolean | undefined, session?: ({client?: ({secrets?: (Array | null) | undefined} | null) | undefined, managed?: boolean | undefined, redis?: AIGatewayRedisCloudConfiguration | undefined, session_ttl?: number | undefined, strategy?: ('client' | 'redis') | undefined} | null) | undefined, timeout?: number | undefined}; export type AIGatewayMCPServerWithUpstreamNoProxyConfig = {route?: AIGatewayMCPServerRouteWithMatcher | undefined, logging?: ({payloads?: boolean | undefined, audits?: boolean | undefined}) | undefined, max_request_body_size?: number | undefined, server?: AIGatewayMCPServerServerConfigBase | undefined, url: string, upstream?: AIGatewayUpstreamConfig | undefined}; export type AIGatewayIdentityProviderReference = string; export type AIGatewayAuthStrategyReference = string; export type AIGatewayMCPServerProtectedResourceMetadata = {discovery_endpoint?: string | undefined, endpoint?: string | undefined, authorization_servers?: Array | undefined, resource?: string | undefined, scopes_supported?: Array | undefined}; export type AIGatewayMCPServerListenerAccess = {acl_attribute_type: 'consumer', acls?: AIGatewayMCPACLs | undefined, default_tool_acls?: AIGatewayMCPACLs | undefined, identity_providers?: Array | undefined, auth_strategies?: Array | undefined, metadata?: AIGatewayMCPServerProtectedResourceMetadata | undefined} | {acl_attribute_type: 'oauth_access_token', access_token_claim_field: string, acls?: AIGatewayMCPACLs | undefined, default_tool_acls?: AIGatewayMCPACLs | undefined, identity_providers?: Array | undefined, auth_strategies?: Array | undefined, metadata?: AIGatewayMCPServerProtectedResourceMetadata | undefined}; export type AIGatewayMCPServerNoUpstreamConfig = {route?: AIGatewayMCPServerRouteWithMatcher | undefined, logging?: ({payloads?: boolean | undefined, audits?: boolean | undefined}) | undefined, max_request_body_size?: number | undefined, server?: AIGatewayMCPServerServerConfigBase | undefined}; export type AIGatewayProxyConfig = {http_proxy?: ({host?: (string | null) | undefined, port?: (number | null) | undefined}) | undefined, https_proxy?: ({host?: (string | null) | undefined, port?: (number | null) | undefined}) | undefined, proxy_scheme?: 'http' | undefined, auth?: ({username?: (string | null) | undefined, password?: (string | null) | undefined}) | undefined, no_proxy?: string | undefined}; export type AIGatewayMCPServerWithUpstreamConfig = {route?: AIGatewayMCPServerRouteWithMatcher | undefined, logging?: ({payloads?: boolean | undefined, audits?: boolean | undefined}) | undefined, max_request_body_size?: number | undefined, server?: AIGatewayMCPServerServerConfigBase | undefined, url: string, upstream?: AIGatewayUpstreamConfig | undefined, proxy?: AIGatewayProxyConfig | undefined}; export type AIGatewayMCPPassthroughTool = {access: AIGatewayMCPToolAccess, name: string}; export type AIGatewayMCPServerUpstreamServerServerToolAuthConfig = {scope?: (string | null) | undefined, access_token_header?: string | undefined, id_token_header?: (string | null) | undefined, type: 'jwt'} | {scope?: (string | null) | undefined, access_token_header?: string | undefined, id_token_header?: (string | null) | undefined, type: 'credentials', token_endpoint: string, client_id: string, client_secret?: (string | null) | undefined}; export type AIGatewayMCPServerUpstreamServerServerConfig = {forward_client_headers?: boolean | undefined, session?: ({client?: ({secrets?: (Array | null) | undefined} | null) | undefined, managed?: boolean | undefined, redis?: AIGatewayRedisCloudConfiguration | undefined, session_ttl?: number | undefined, strategy?: ('client' | 'redis') | undefined} | null) | undefined, timeout?: number | undefined, preserve_upstream_tool_names?: boolean | undefined, tools_list_auth?: AIGatewayMCPServerUpstreamServerServerToolAuthConfig | undefined}; export type AIGatewayMCPServerUpstreamServerConfig = {route?: AIGatewayMCPServerRouteWithMatcher | undefined, logging?: ({payloads?: boolean | undefined, audits?: boolean | undefined}) | undefined, max_request_body_size?: number | undefined, server?: AIGatewayMCPServerUpstreamServerServerConfig | undefined, url: string, upstream?: AIGatewayUpstreamConfig | undefined, tools_cache_ttl_seconds: number}; export type AIGatewayMCPUpstreamTool = {access?: AIGatewayMCPToolAccess | undefined, annotations?: AIGatewayMCPToolAnnotations | undefined, description?: (string | null) | undefined, name: string, input_schema?: ({[key: string]: unknown} | null) | undefined, output_schema?: ({[key: string]: unknown} | null) | undefined}; export type UpdateAIGatewayMCPServerRequest = {type: 'conversion-only', config: AIGatewayMCPServerWithUpstreamNoProxyConfigNoServerConfig, tools: Array, display_name: string, name: AIGatewayEntityIdentifier, enabled?: boolean | undefined, policies?: AIGatewayPolicyReferences | undefined, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined} | {type: 'conversion-listener', config: AIGatewayMCPServerWithUpstreamNoProxyConfig, tools: Array, access?: AIGatewayMCPServerListenerAccess | undefined, display_name: string, name: AIGatewayEntityIdentifier, enabled?: boolean | undefined, policies?: AIGatewayPolicyReferences | undefined, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined} | {type: 'listener', config: AIGatewayMCPServerNoUpstreamConfig, sources: Array, access?: AIGatewayMCPServerListenerAccess | undefined, display_name: string, name: AIGatewayEntityIdentifier, enabled?: boolean | undefined, policies?: AIGatewayPolicyReferences | undefined, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined} | {type: 'passthrough-listener', config: AIGatewayMCPServerWithUpstreamConfig, tools?: Array | undefined, access?: AIGatewayMCPServerListenerAccess | undefined, display_name: string, name: AIGatewayEntityIdentifier, enabled?: boolean | undefined, policies?: AIGatewayPolicyReferences | undefined, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined} | {type: 'upstream-server', config: AIGatewayMCPServerUpstreamServerConfig, tools?: Array | undefined, display_name: string, name: AIGatewayEntityIdentifier, enabled?: boolean | undefined, policies?: AIGatewayPolicyReferences | undefined, labels?: PublicLabels | undefined, managed_by?: ManagedBy | undefined}; export type UpdateApiV1AiGatewaysGatewayIdMcpServersMcpServerIdOrNameArgs = {body: UpdateAIGatewayMCPServerRequest}; export type UpdateApiV1AiGatewaysGatewayIdMcpServersMcpServerIdOrNameOptions = {baseUrl?: string | undefined, personalAccessToken?: string | undefined, fetch?: typeof fetch | undefined}; export const uUID = z.string(); export const createdAt = z.string(); export const updatedAt = z.string(); export const aIGatewayMCPServerRouteWithMatcher = z.object({headers: z.record(z.string(), z.unknown()).optional(), hosts: z.array(z.string()).optional(), https_redirect_status_code: z.number().int().gte(100).lte(599).optional(), methods: z.array(z.string()).optional(), paths: z.array(z.string()).optional(), preserve_host: z.boolean().optional(), protocols: z.array(z.string()).optional(), regex_priority: z.number().int().gte(-2147483648).lte(2147483647).optional(), request_buffering: z.boolean().optional(), response_buffering: z.boolean().optional(), strip_path: z.boolean().optional(), tags: z.array(z.string()).optional()}); export const aIGatewayUpstreamConfig = z.object({auth: z.object({type: z.literal("aws"), access_key_id: z.string().optional(), secret_access_key: z.string().optional(), session_token: z.string().optional(), region: z.string().optional(), assume_role_arn: z.string().optional(), role_session_name: z.string().optional(), sts_endpoint_url: z.string().optional()}).optional()}); export const aIGatewayMCPServerWithUpstreamNoProxyConfigNoServerConfig = z.object({route: aIGatewayMCPServerRouteWithMatcher.optional(), logging: z.object({payloads: z.boolean().optional(), audits: z.boolean().optional()}).optional(), max_request_body_size: z.number().int().optional(), url: z.string(), upstream: aIGatewayUpstreamConfig.optional()}); export const aIGatewayMCPACLs = z.object({allow: z.array(z.string()).optional(), deny: z.array(z.string()).optional()}); export const aIGatewayMCPToolAccess = z.object({acls: aIGatewayMCPACLs.optional()}); export const aIGatewayMCPToolAnnotations = z.object({destructive_hint: z.boolean().optional(), idempotent_hint: z.boolean().optional(), open_world_hint: z.boolean().optional(), read_only_hint: z.boolean().optional(), title: z.string().optional()}); export const aIGatewayMCPToolHeaders = z.record(z.string(), z.unknown()); export const aIGatewayMCPToolQuery = z.record(z.string(), z.unknown()); export const aIGatewayMCPToolRequestBody = z.record(z.string(), z.unknown()); export const aIGatewayMCPToolResponses = z.record(z.string(), z.unknown()); export const aIGatewayMCPToolParameter = z.object({name: z.string(), in: z.enum(["query", "path", "header", "body"]), description: z.string().optional(), required: z.boolean().optional(), schema: z.record(z.string(), z.unknown()).optional()}); export const aIGatewayMCPToolParameters = z.array(aIGatewayMCPToolParameter); export const aIGatewayMCPConversionTool = z.object({access: aIGatewayMCPToolAccess.optional(), annotations: aIGatewayMCPToolAnnotations.optional(), description: z.string(), name: z.string(), headers: aIGatewayMCPToolHeaders.optional(), host: z.string().nullable().optional(), method: z.enum(["DELETE", "GET", "PATCH", "POST", "PUT"]), path: z.string().nullable().optional(), query: aIGatewayMCPToolQuery.optional(), request_body: aIGatewayMCPToolRequestBody.optional(), responses: aIGatewayMCPToolResponses.optional(), scheme: z.enum(["http", "https"]).optional(), parameters: aIGatewayMCPToolParameters.optional()}); export const aIGatewayEntityIdentifier = z.string().min(1).max(256); export const aIGatewayPolicyReferences = z.array(z.string()); export const publicLabels = z.record(z.string(), z.string().min(1).max(63)); export const managedBy = z.record(z.string(), z.string().min(1).max(63)); export const aIGatewayRedisAWSAuthentication = z.object({type: z.literal("aws"), access_key_id: z.string().nullable().optional(), assume_role_arn: z.string().nullable().optional(), cache_name: z.string().nullable().optional(), is_serverless: z.boolean().optional(), region: z.string().nullable().optional(), role_session_name: z.string().nullable().optional(), secret_access_key: z.string().nullable().optional()}); export const aIGatewayRedisAzureAuthentication = z.object({type: z.literal("azure"), client_id: z.string().nullable().optional(), client_secret: z.string().nullable().optional(), tenant_id: z.string().nullable().optional()}); export const aIGatewayRedisGCPAuthentication = z.object({type: z.literal("gcp"), service_account_json: z.string().nullable().optional()}); export const aIGatewayRedisCloudConfiguration = z.object({cloud_authentication: z.discriminatedUnion("type", [aIGatewayRedisAWSAuthentication, aIGatewayRedisAzureAuthentication, aIGatewayRedisGCPAuthentication]).optional(), cluster: z.object({max_redirections: z.number().int().gte(0).lte(2147483646).optional(), nodes: z.array(z.object({ip: z.string().optional(), port: z.number().int().gte(0).lte(65535).optional()})).nullable().optional()}).nullable().optional(), connect_timeout: z.number().int().gte(0).lte(2147483646).optional(), connection_is_proxied: z.boolean().optional(), database: z.number().int().gte(0).lte(2147483646).optional(), host: z.string().optional(), keepalive: z.object({backlog: z.number().int().gte(0).lte(2147483646).nullable().optional(), pool_size: z.number().int().gte(1).lte(2147483646).optional()}).nullable().optional(), password: z.string().nullable().optional(), port: z.string().optional(), read_timeout: z.number().int().gte(0).lte(2147483646).optional(), send_timeout: z.number().int().gte(0).lte(2147483646).optional(), sentinel: z.object({master: z.string().nullable().optional(), nodes: z.array(z.object({host: z.string().optional(), port: z.number().int().gte(0).lte(65535).optional()})).nullable().optional(), password: z.string().nullable().optional(), role: z.enum(["any", "master", "slave"]).optional(), username: z.string().nullable().optional()}).nullable().optional(), server_name: z.string().nullable().optional(), ssl: z.boolean().optional(), ssl_verify: z.boolean().optional(), username: z.string().nullable().optional()}); export const aIGatewayMCPServerServerConfigBase = z.object({forward_client_headers: z.boolean().optional(), session: z.object({client: z.object({secrets: z.array(z.string().min(8)).nullable().optional()}).nullable().optional(), managed: z.boolean().optional(), redis: aIGatewayRedisCloudConfiguration.optional(), session_ttl: z.number().int().gte(0).lte(2147483646).optional(), strategy: z.enum(["client", "redis"]).optional()}).nullable().optional(), timeout: z.number().int().gte(0).lte(2147483646).optional()}); export const aIGatewayMCPServerWithUpstreamNoProxyConfig = z.object({route: aIGatewayMCPServerRouteWithMatcher.optional(), logging: z.object({payloads: z.boolean().optional(), audits: z.boolean().optional()}).optional(), max_request_body_size: z.number().int().gte(0).lte(2147483646).optional(), server: aIGatewayMCPServerServerConfigBase.optional(), url: z.string(), upstream: aIGatewayUpstreamConfig.optional()}); export const aIGatewayIdentityProviderReference = z.string(); export const aIGatewayAuthStrategyReference = z.string(); export const aIGatewayMCPServerProtectedResourceMetadata = z.object({discovery_endpoint: z.string().optional(), endpoint: z.string().optional(), authorization_servers: z.array(z.string()).optional(), resource: z.string().optional(), scopes_supported: z.array(z.string()).optional()}); export const aIGatewayMCPServerListenerAccess = z.discriminatedUnion("acl_attribute_type", [z.object({acl_attribute_type: z.literal("consumer"), acls: aIGatewayMCPACLs.optional(), default_tool_acls: aIGatewayMCPACLs.optional(), identity_providers: z.array(aIGatewayIdentityProviderReference).optional(), auth_strategies: z.array(aIGatewayAuthStrategyReference).optional(), metadata: aIGatewayMCPServerProtectedResourceMetadata.optional()}), z.object({acl_attribute_type: z.literal("oauth_access_token"), access_token_claim_field: z.string(), acls: aIGatewayMCPACLs.optional(), default_tool_acls: aIGatewayMCPACLs.optional(), identity_providers: z.array(aIGatewayIdentityProviderReference).optional(), auth_strategies: z.array(aIGatewayAuthStrategyReference).optional(), metadata: aIGatewayMCPServerProtectedResourceMetadata.optional()})]); export const aIGatewayMCPServerNoUpstreamConfig = z.object({route: aIGatewayMCPServerRouteWithMatcher.optional(), logging: z.object({payloads: z.boolean().optional(), audits: z.boolean().optional()}).optional(), max_request_body_size: z.number().int().gte(0).lte(2147483646).optional(), server: aIGatewayMCPServerServerConfigBase.optional()}); export const aIGatewayProxyConfig = z.object({http_proxy: z.object({host: z.string().nullable().optional(), port: z.number().int().gte(0).lte(65535).nullable().optional()}).optional(), https_proxy: z.object({host: z.string().nullable().optional(), port: z.number().int().gte(0).lte(65535).nullable().optional()}).optional(), proxy_scheme: z.literal("http").optional(), auth: z.object({username: z.string().nullable().optional(), password: z.string().nullable().optional()}).optional(), no_proxy: z.string().optional()}); export const aIGatewayMCPServerWithUpstreamConfig = z.object({route: aIGatewayMCPServerRouteWithMatcher.optional(), logging: z.object({payloads: z.boolean().optional(), audits: z.boolean().optional()}).optional(), max_request_body_size: z.number().int().gte(0).lte(2147483646).optional(), server: aIGatewayMCPServerServerConfigBase.optional(), url: z.string(), upstream: aIGatewayUpstreamConfig.optional(), proxy: aIGatewayProxyConfig.optional()}); export const aIGatewayMCPPassthroughTool = z.object({access: aIGatewayMCPToolAccess, name: z.string()}); export const aIGatewayMCPServerUpstreamServerServerToolAuthConfig = z.discriminatedUnion("type", [z.object({scope: z.string().nullable().optional(), access_token_header: z.string().optional(), id_token_header: z.string().nullable().optional(), type: z.literal("jwt")}), z.object({scope: z.string().nullable().optional(), access_token_header: z.string().optional(), id_token_header: z.string().nullable().optional(), type: z.literal("credentials"), token_endpoint: z.string(), client_id: z.string(), client_secret: z.string().nullable().optional()})]); export const aIGatewayMCPServerUpstreamServerServerConfig = z.object({forward_client_headers: z.boolean().optional(), session: z.object({client: z.object({secrets: z.array(z.string().min(8)).nullable().optional()}).nullable().optional(), managed: z.boolean().optional(), redis: aIGatewayRedisCloudConfiguration.optional(), session_ttl: z.number().int().gte(0).lte(2147483646).optional(), strategy: z.enum(["client", "redis"]).optional()}).nullable().optional(), timeout: z.number().int().gte(0).lte(2147483646).optional(), preserve_upstream_tool_names: z.boolean().optional(), tools_list_auth: aIGatewayMCPServerUpstreamServerServerToolAuthConfig.optional()}); export const aIGatewayMCPServerUpstreamServerConfig = z.object({route: aIGatewayMCPServerRouteWithMatcher.optional(), logging: z.object({payloads: z.boolean().optional(), audits: z.boolean().optional()}).optional(), max_request_body_size: z.number().int().gte(0).lte(2147483646).optional(), server: aIGatewayMCPServerUpstreamServerServerConfig.optional(), url: z.string(), upstream: aIGatewayUpstreamConfig.optional(), tools_cache_ttl_seconds: z.number().int().gte(0)}); export const aIGatewayMCPUpstreamTool = z.object({access: aIGatewayMCPToolAccess.optional(), annotations: aIGatewayMCPToolAnnotations.optional(), description: z.string().nullable().optional(), name: z.string(), input_schema: z.record(z.string(), z.unknown()).nullable().optional(), output_schema: z.record(z.string(), z.unknown()).nullable().optional()}); export const aIGatewayMCPServer = z.discriminatedUnion("type", [z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("conversion-only"), config: aIGatewayMCPServerWithUpstreamNoProxyConfigNoServerConfig, tools: z.array(aIGatewayMCPConversionTool), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, enabled: z.boolean().optional(), policies: aIGatewayPolicyReferences.optional(), labels: publicLabels.optional(), managed_by: managedBy.optional()}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("conversion-listener"), config: aIGatewayMCPServerWithUpstreamNoProxyConfig, tools: z.array(aIGatewayMCPConversionTool), access: aIGatewayMCPServerListenerAccess.optional(), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, enabled: z.boolean().optional(), policies: aIGatewayPolicyReferences.optional(), labels: publicLabels.optional(), managed_by: managedBy.optional()}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("listener"), config: aIGatewayMCPServerNoUpstreamConfig, sources: z.array(aIGatewayEntityIdentifier), access: aIGatewayMCPServerListenerAccess.optional(), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, enabled: z.boolean().optional(), policies: aIGatewayPolicyReferences.optional(), labels: publicLabels.optional(), managed_by: managedBy.optional()}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("passthrough-listener"), config: aIGatewayMCPServerWithUpstreamConfig, tools: z.array(aIGatewayMCPPassthroughTool).optional(), access: aIGatewayMCPServerListenerAccess.optional(), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, enabled: z.boolean().optional(), policies: aIGatewayPolicyReferences.optional(), labels: publicLabels.optional(), managed_by: managedBy.optional()}), z.object({id: uUID, created_at: createdAt, updated_at: updatedAt, type: z.literal("upstream-server"), config: aIGatewayMCPServerUpstreamServerConfig, tools: z.array(aIGatewayMCPUpstreamTool).optional(), display_name: z.string().min(1).max(256), name: aIGatewayEntityIdentifier, enabled: z.boolean().optional(), policies: aIGatewayPolicyReferences.optional(), labels: publicLabels.optional(), managed_by: managedBy.optional()})]); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Update an MCP Server * * PUT /v1/ai-gateways/{gatewayId}/mcp-servers/{mcpServerIdOrName} * * Also accepts auth: systemAccountAccessToken, konnectAccessToken, serviceAccessToken */ export const updateApiV1AiGatewaysGatewayIdMcpServersMcpServerIdOrName = async (args: UpdateApiV1AiGatewaysGatewayIdMcpServersMcpServerIdOrNameArgs, options?: UpdateApiV1AiGatewaysGatewayIdMcpServersMcpServerIdOrNameOptions) => { const {baseUrl = "https://global.api.konghq.com", fetch: fetchFn = fetch, personalAccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (personalAccessToken !== undefined) headers.set('authorization', `Bearer ${personalAccessToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1/ai-gateways/${encodeURIComponent(String(args.gatewayId))}/mcp-servers/${encodeURIComponent(String(args.mcpServerIdOrName))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(aIGatewayMCPServer, await res.json()) };