From 331da0f802b1d732e3484223550a62e79b508baa Mon Sep 17 00:00:00 2001 From: Adil Riazudeen Date: Thu, 22 May 2025 01:25:32 -0700 Subject: [PATCH] fix: revert ServerConfigSchema to union. (#3716) This type was changed from a union to a discriminated union based on transportType. It seems like this is an internal implementation detail that end users shouldn't really care about. This change reverts that type back to a union. Co-authored-by: Adil Riazudeen --- .changeset/eleven-dragons-sell.md | 5 +++++ src/services/mcp/McpHub.ts | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) create mode 100644 .changeset/eleven-dragons-sell.md diff --git a/.changeset/eleven-dragons-sell.md b/.changeset/eleven-dragons-sell.md new file mode 100644 index 00000000..b05bd612 --- /dev/null +++ b/.changeset/eleven-dragons-sell.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +no longer requires `transportType` property to be set in MCP Server configuration. diff --git a/src/services/mcp/McpHub.ts b/src/services/mcp/McpHub.ts index 9c81e957..b7923a07 100644 --- a/src/services/mcp/McpHub.ts +++ b/src/services/mcp/McpHub.ts @@ -55,23 +55,30 @@ const BaseConfigSchema = z.object({ }) const SseConfigSchema = BaseConfigSchema.extend({ - transportType: z.literal("sse"), url: z.string().url(), -}) +}).transform((config) => ({ + ...config, + transportType: "sse" as const, +})) const StdioConfigSchema = BaseConfigSchema.extend({ - transportType: z.literal("stdio"), command: z.string(), args: z.array(z.string()).optional(), env: z.record(z.string()).optional(), -}) +}).transform((config) => ({ + ...config, + transportType: "stdio" as const, +})) const StreamableHTTPConfigSchema = BaseConfigSchema.extend({ transportType: z.literal("http"), url: z.string().url(), -}) +}).transform((config) => ({ + ...config, + transportType: "http" as const, +})) -const ServerConfigSchema = z.discriminatedUnion("transportType", [StdioConfigSchema, SseConfigSchema, StreamableHTTPConfigSchema]) +const ServerConfigSchema = z.union([StdioConfigSchema, SseConfigSchema, StreamableHTTPConfigSchema]) const McpSettingsSchema = z.object({ mcpServers: z.record(ServerConfigSchema),