UNPKG

mcp-simple-gateway

Version:
52 lines (51 loc) 2.1 kB
// Generated by ts-to-zod import { z } from 'zod'; import { TransportType } from './../../types/config.js'; export const transportTypeSchema = z.nativeEnum(TransportType); export const commonProxyOptionsSchema = z.object({ authTokens: z.array(z.string()).optional(), }); export const mcpStdioServerConfigSchema = z.object({ type: z.literal(TransportType.STDIO).optional(), command: z.string(), args: z.array(z.string()), env: z.record(z.string()).optional(), cwd: z.string().optional(), }); export const mcpSSEServerConfigSchema = z.object({ type: z.literal(TransportType.SSE).optional(), url: z.string(), headers: z.record(z.string()).optional(), }); export const mcpStreamableHTTPServerConfigSchema = z.object({ type: z.literal(TransportType.STREAMABLE_HTTP), url: z.string(), headers: z.record(z.string()).optional(), }); export const mcpServerConfigSchema = z.union([ mcpStdioServerConfigSchema, mcpSSEServerConfigSchema, mcpStreamableHTTPServerConfigSchema, ]); export const mcpServerProxyBaseConfigSchema = z.object({ proxyOptions: commonProxyOptionsSchema.optional(), }); export const mcpStdioServerProxyConfigSchema = mcpServerProxyBaseConfigSchema.and(mcpStdioServerConfigSchema); export const mcpSSEServerProxyConfigSchema = mcpServerProxyBaseConfigSchema.and(mcpSSEServerConfigSchema); export const mcpStreamableHTTPServerProxyConfigSchema = mcpServerProxyBaseConfigSchema.and(mcpStreamableHTTPServerConfigSchema); export const mcpServerProxyConfigSchema = z.union([ mcpStdioServerProxyConfigSchema, mcpSSEServerProxyConfigSchema, mcpStreamableHTTPServerProxyConfigSchema, ]); const levelWithSilentOrStringSchema = z.any(); const corsOptionsSchema = z.any(); export const proxyServerConfigSchema = commonProxyOptionsSchema.extend({ logLevel: levelWithSilentOrStringSchema.optional(), logPretty: z.boolean().optional(), cors: corsOptionsSchema.optional(), }); export const configSchema = z.object({ proxyServer: proxyServerConfigSchema, mcpServers: z.record(mcpServerProxyConfigSchema), });