Elffuss BraidHub

kikocis/continue public

main · 1.6 KiBRawPermalink
1import z from "zod";
2
3// This is the schema for an entry in e.g. Claude Desktop, Claude code mcp config
4const httpOrSseMcpJsonSchema = z.object({
5 type: z.union([z.literal("sse"), z.literal("http")]).optional(),
6 url: z.string(), // .url() fails with e.g. IP addresses
7 headers: z.record(z.string(), z.string()).optional(),
8});
9export type HttpMcpJsonConfig = z.infer<typeof httpOrSseMcpJsonSchema>;
10export type SseMcpJsonConfig = z.infer<typeof httpOrSseMcpJsonSchema>;
11
12const stdioMcpJsonSchema = z.object({
13 type: z.literal("stdio").optional(),
14 command: z.string(),
15 args: z.array(z.string()).optional(),
16 env: z.record(z.string(), z.string()).optional(),
17 envFile: z.string().optional(),
18});
19export type StdioMcpJsonConfig = z.infer<typeof stdioMcpJsonSchema>;
20
21export const mcpServersJsonSchema = z.union([
22 httpOrSseMcpJsonSchema,
23 stdioMcpJsonSchema,
24]);
25export type McpJsonConfig = z.infer<typeof mcpServersJsonSchema>;
26
27export const mcpServersRecordSchema = z.record(
28 z.string(),
29 mcpServersJsonSchema,
30);
31export type McpServersJsonConfigRecord = z.infer<typeof mcpServersRecordSchema>;
32
33export const claudeDesktopLikeConfigFileSchema = z.object({
34 mcpServers: mcpServersRecordSchema,
35});
36export type McpServersJsonConfigFile = z.infer<
37 typeof claudeDesktopLikeConfigFileSchema
38>;
39
40export const claudeCodeLikeConfigFileSchema = z.object({
41 mcpServers: mcpServersRecordSchema.optional(),
42 projects: z.record(
43 z.string(),
44 z.object({
45 mcpServers: mcpServersRecordSchema.optional(),
46 }),
47 ),
48});
49export type claudeCodeLikeConfigFileSchema = z.infer<
50 typeof claudeCodeLikeConfigFileSchema
51>;