import {z} from 'zod' export type UpdateApiApiMcpToolGroupsIdArgs = {id: number, body: {name?: string | undefined, description?: (string | null) | undefined, enabled?: (boolean | null) | undefined, tools?: (Array<{mcp_client_id: string, tool_names?: Array | undefined}>) | undefined, virtual_key_ids?: Array | undefined, team_ids?: Array | undefined, customer_ids?: Array | undefined, user_ids?: Array | undefined, provider_names?: Array | undefined, api_key_ids?: Array | undefined}}; export type UpdateApiApiMcpToolGroupsIdOptions = {baseUrl?: string | undefined, ManagementBearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; export const updateApiApiMcpToolGroupsIdResponse = z.object({mcp_tool_group: z.object({id: z.number().int().optional(), name: z.string().max(255).optional(), description: z.string().nullable().optional(), enabled: z.boolean().optional(), tools: z.array(z.object({mcp_client_id: z.string(), tool_names: z.array(z.string()).optional()})).optional(), virtual_key_ids: z.array(z.string()).optional(), team_ids: z.array(z.string()).optional(), customer_ids: z.array(z.string()).optional(), user_ids: z.array(z.string()).optional(), provider_names: z.array(z.string()).optional(), api_key_ids: z.array(z.number().int()).optional(), created_at: z.string().optional(), updated_at: z.string().optional()}).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 MCP Tool Group * * PUT /api/mcp/tool-groups/{id} */ export const updateApiApiMcpToolGroupsId = async (args: UpdateApiApiMcpToolGroupsIdArgs, options?: UpdateApiApiMcpToolGroupsIdOptions) => { const {baseUrl = "http://localhost:8080", fetch: fetchFn = fetch, ManagementBearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ManagementBearerAuth !== undefined) headers.set('authorization', `Bearer ${ManagementBearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/mcp/tool-groups/${encodeURIComponent(String(args.id))}${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(updateApiApiMcpToolGroupsIdResponse, await res.json()) };