Skip to content

Commit 58a1eae

Browse files
SSE Schema and Types (RooCodeInc#2441)
* Types and schemas for SSE connections * changeset
1 parent a295ac2 commit 58a1eae

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

.changeset/odd-feet-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"claude-dev": minor
3+
---
4+
5+
Added types and schemas for SSE transport MCP connections

src/services/mcp/McpHub.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,42 @@ export type McpConnection = {
3636
transport: StdioClientTransport
3737
}
3838

39+
export type McpTransportType = "stdio" | "sse"
40+
41+
export type McpServerConfig = {
42+
transportType: McpTransportType
43+
autoApprove?: string[]
44+
disabled?: boolean
45+
timeout?: number
46+
} & (
47+
| {
48+
// Stdio specific
49+
transportType: "stdio"
50+
command: string
51+
args?: string[]
52+
env?: Record<string, string>
53+
}
54+
| {
55+
// SSE specific
56+
transportType: "sse"
57+
url: string
58+
headers?: Record<string, string>
59+
withCredentials?: boolean
60+
}
61+
)
62+
3963
const AutoApproveSchema = z.array(z.string()).default([])
4064

65+
const SseConfigSchema = z.object({
66+
transportType: z.literal("sse"),
67+
url: z.string().url(),
68+
headers: z.record(z.string()).optional(),
69+
withCredentials: z.boolean().optional().default(false),
70+
autoApprove: AutoApproveSchema.optional(),
71+
disabled: z.boolean().optional(),
72+
timeout: z.number().min(MIN_MCP_TIMEOUT_SECONDS).optional().default(DEFAULT_MCP_TIMEOUT_SECONDS),
73+
})
74+
4175
const StdioConfigSchema = z.object({
4276
command: z.string(),
4377
args: z.array(z.string()).optional(),
@@ -47,8 +81,13 @@ const StdioConfigSchema = z.object({
4781
timeout: z.number().min(MIN_MCP_TIMEOUT_SECONDS).optional().default(DEFAULT_MCP_TIMEOUT_SECONDS),
4882
})
4983

84+
const ServerConfigSchema = z.discriminatedUnion("transportType", [
85+
StdioConfigSchema.extend({ transportType: z.literal("stdio") }),
86+
SseConfigSchema,
87+
])
88+
5089
const McpSettingsSchema = z.object({
51-
mcpServers: z.record(StdioConfigSchema),
90+
mcpServers: z.record(ServerConfigSchema),
5291
})
5392

5493
export class McpHub {

0 commit comments

Comments
 (0)