Compare commits

...
Author SHA1 Message Date
celestial-vault f7b6d378a1 changeset 2025-03-25 15:30:14 -07:00
celestial-vault 0be11cc5ca Types and schemas for SSE connections 2025-03-25 15:25:24 -07:00
2 changed files with 45 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"claude-dev": minor
---
Added types and schemas for SSE transport MCP connections
+40 -1
View File
@@ -36,8 +36,42 @@ export type McpConnection = {
transport: StdioClientTransport
}
export type McpTransportType = "stdio" | "sse"
export type McpServerConfig = {
transportType: McpTransportType
autoApprove?: string[]
disabled?: boolean
timeout?: number
} & (
| {
// Stdio specific
transportType: "stdio"
command: string
args?: string[]
env?: Record<string, string>
}
| {
// SSE specific
transportType: "sse"
url: string
headers?: Record<string, string>
withCredentials?: boolean
}
)
const AutoApproveSchema = z.array(z.string()).default([])
const SseConfigSchema = z.object({
transportType: z.literal("sse"),
url: z.string().url(),
headers: z.record(z.string()).optional(),
withCredentials: z.boolean().optional().default(false),
autoApprove: AutoApproveSchema.optional(),
disabled: z.boolean().optional(),
timeout: z.number().min(MIN_MCP_TIMEOUT_SECONDS).optional().default(DEFAULT_MCP_TIMEOUT_SECONDS),
})
const StdioConfigSchema = z.object({
command: z.string(),
args: z.array(z.string()).optional(),
@@ -47,8 +81,13 @@ const StdioConfigSchema = z.object({
timeout: z.number().min(MIN_MCP_TIMEOUT_SECONDS).optional().default(DEFAULT_MCP_TIMEOUT_SECONDS),
})
const ServerConfigSchema = z.discriminatedUnion("transportType", [
StdioConfigSchema.extend({ transportType: z.literal("stdio") }),
SseConfigSchema,
])
const McpSettingsSchema = z.object({
mcpServers: z.record(StdioConfigSchema),
mcpServers: z.record(ServerConfigSchema),
})
export class McpHub {