Changesets · Branches · Tags · Compare
| Changeset | 74358319424eef8c5b2a3868ed7d7f58361df3a84522dcb5f9fd60dd14205a49 |
|---|---|
| Author | Patrick Erichsen <patrick.a.erichsen@gmail.com> · 2025-05-21 12:41 -07:00 |
| Committer | GitHub <noreply@github.com> · 2025-05-21 12:41 -07:00 |
| Parents | 7d19f8698b5d, 932977ebc545 |
7 files changed
modified core/config/workspace/workspaceBlocks.ts +0 −6
| @@ -53,16 +53,10 @@ | ||
| 53 | 53 | configYaml.mcpServers = [ |
| 54 | 54 | { |
| 55 | 55 | name: "New MCP server", |
| 56 | - type: "stdio", | |
| 57 | 56 | command: "npx", |
| 58 | 57 | args: ["-y", "<your-mcp-server>"], |
| 59 | 58 | env: {}, |
| 60 | 59 | }, |
| 61 | - { | |
| 62 | - name: "New MCP server", | |
| 63 | - type: "sse", | |
| 64 | - url: "https://example.org/sse" | |
| 65 | - }, | |
| 66 | 60 | ]; |
| 67 | 61 | break; |
| 68 | 62 | } |
deleted core/config/yaml/loadYaml.test.ts +0 −107
| @@ -1,107 +0,0 @@ | ||
| 1 | -import { MCPServer } from "@continuedev/config-yaml"; | |
| 2 | -import { convertYamlMcpToContinueMcp } from "./loadYaml"; | |
| 3 | - | |
| 4 | -describe("MCP Server Configuration Tests", () => { | |
| 5 | - test("should convert stdio MCP server correctly", () => { | |
| 6 | - const stdioServer: MCPServer = { | |
| 7 | - name: "Test Stdio Server", | |
| 8 | - type: "stdio", | |
| 9 | - command: "uvx", | |
| 10 | - args: ["mcp-server-sqlite", "--db-path", "/test.db"], | |
| 11 | - env: { TEST_ENV: "value" }, | |
| 12 | - connectionTimeout: 5000 | |
| 13 | - }; | |
| 14 | - | |
| 15 | - const result = convertYamlMcpToContinueMcp(stdioServer); | |
| 16 | - | |
| 17 | - expect(result).toEqual({ | |
| 18 | - transport: { | |
| 19 | - type: "stdio", | |
| 20 | - command: "uvx", | |
| 21 | - args: ["mcp-server-sqlite", "--db-path", "/test.db"], | |
| 22 | - env: { TEST_ENV: "value" } | |
| 23 | - }, | |
| 24 | - timeout: 5000 | |
| 25 | - }); | |
| 26 | - }); | |
| 27 | - | |
| 28 | - test("should convert SSE MCP server correctly", () => { | |
| 29 | - const sseServer: MCPServer = { | |
| 30 | - name: "Test SSE Server", | |
| 31 | - type: "sse", | |
| 32 | - url: "http://localhost:8150/cosmos/mcp/v1/sse", | |
| 33 | - connectionTimeout: 3000 | |
| 34 | - }; | |
| 35 | - | |
| 36 | - const result = convertYamlMcpToContinueMcp(sseServer); | |
| 37 | - | |
| 38 | - expect(result).toEqual({ | |
| 39 | - transport: { | |
| 40 | - type: "sse", | |
| 41 | - url: "http://localhost:8150/cosmos/mcp/v1/sse" | |
| 42 | - }, | |
| 43 | - timeout: 3000 | |
| 44 | - }); | |
| 45 | - }); | |
| 46 | - | |
| 47 | - test("should convert WebSocket MCP server correctly", () => { | |
| 48 | - const wsServer: MCPServer = { | |
| 49 | - name: "Test WebSocket Server", | |
| 50 | - type: "websocket", | |
| 51 | - url: "ws://localhost:8150/cosmos/mcp/v1/ws", | |
| 52 | - connectionTimeout: 10000 | |
| 53 | - }; | |
| 54 | - | |
| 55 | - const result = convertYamlMcpToContinueMcp(wsServer); | |
| 56 | - | |
| 57 | - expect(result).toEqual({ | |
| 58 | - transport: { | |
| 59 | - type: "websocket", | |
| 60 | - url: "ws://localhost:8150/cosmos/mcp/v1/ws" | |
| 61 | - }, | |
| 62 | - timeout: 10000 | |
| 63 | - }); | |
| 64 | - }); | |
| 65 | - | |
| 66 | - test("should handle legacy MCP server format for backward compatibility", () => { | |
| 67 | - // Test with old format that doesn't have a type field | |
| 68 | - const legacyServer = { | |
| 69 | - name: "Legacy Server", | |
| 70 | - command: "old-command", | |
| 71 | - args: ["--legacy"], | |
| 72 | - connectionTimeout: 2000 | |
| 73 | - } as any; | |
| 74 | - | |
| 75 | - const result = convertYamlMcpToContinueMcp(legacyServer); | |
| 76 | - | |
| 77 | - expect(result).toEqual({ | |
| 78 | - transport: { | |
| 79 | - type: "stdio", | |
| 80 | - command: "old-command", | |
| 81 | - args: ["--legacy"], | |
| 82 | - env: undefined | |
| 83 | - }, | |
| 84 | - timeout: 2000 | |
| 85 | - }); | |
| 86 | - }); | |
| 87 | - | |
| 88 | - test("should handle missing optional fields", () => { | |
| 89 | - const minimalServer: MCPServer = { | |
| 90 | - name: "Minimal Server", | |
| 91 | - type: "stdio", | |
| 92 | - command: "minimal" | |
| 93 | - }; | |
| 94 | - | |
| 95 | - const result = convertYamlMcpToContinueMcp(minimalServer); | |
| 96 | - | |
| 97 | - expect(result).toEqual({ | |
| 98 | - transport: { | |
| 99 | - type: "stdio", | |
| 100 | - command: "minimal", | |
| 101 | - args: [], | |
| 102 | - env: undefined | |
| 103 | - }, | |
| 104 | - timeout: undefined | |
| 105 | - }); | |
| 106 | - }); | |
| 107 | -}); | |
| No newline at the end of the file |
modified core/config/yaml/loadYaml.ts +10 −34
| @@ -62,42 +62,17 @@ | ||
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | -export function convertYamlMcpToContinueMcp( | |
| 65 | +function convertYamlMcpToContinueMcp( | |
| 66 | 66 | server: MCPServer, |
| 67 | 67 | ): ExperimentalMCPOptions { |
| 68 | - const transportConfig = (() => { | |
| 69 | - switch (server.type) { | |
| 70 | - case "stdio": | |
| 71 | - return { | |
| 72 | - type: "stdio" as const, | |
| 73 | - command: server.command, | |
| 74 | - args: server.args ?? [], | |
| 75 | - env: server.env, | |
| 76 | - }; | |
| 77 | - case "sse": | |
| 78 | - return { | |
| 79 | - type: "sse" as const, | |
| 80 | - url: server.url, | |
| 81 | - }; | |
| 82 | - case "websocket": | |
| 83 | - return { | |
| 84 | - type: "websocket" as const, | |
| 85 | - url: server.url, | |
| 86 | - }; | |
| 87 | - default: | |
| 88 | - // Default to stdio for backward compatibility | |
| 89 | - return { | |
| 90 | - type: "stdio" as const, | |
| 91 | - command: (server as any).command, | |
| 92 | - args: (server as any).args ?? [], | |
| 93 | - env: (server as any).env, | |
| 94 | - }; | |
| 95 | - } | |
| 96 | - })(); | |
| 97 | - | |
| 98 | 68 | return { |
| 99 | - transport: transportConfig, | |
| 100 | - timeout: server.connectionTimeout | |
| 69 | + transport: { | |
| 70 | + type: "stdio", | |
| 71 | + command: server.command, | |
| 72 | + args: server.args ?? [], | |
| 73 | + env: server.env, | |
| 74 | + }, | |
| 75 | + timeout: server.connectionTimeout, | |
| 101 | 76 | }; |
| 102 | 77 | } |
| 103 | 78 | |
| @@ -269,7 +244,7 @@ | ||
| 269 | 244 | |
| 270 | 245 | config.mcpServers?.forEach((mcpServer) => { |
| 271 | 246 | const mcpArgVariables = |
| 272 | - (mcpServer.type === "stdio" ? mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) : []) ?? []; | |
| 247 | + mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; | |
| 273 | 248 | |
| 274 | 249 | if (mcpArgVariables.length === 0) { |
| 275 | 250 | return; |
| @@ -481,6 +456,7 @@ | ||
| 481 | 456 | id: server.name, |
| 482 | 457 | name: server.name, |
| 483 | 458 | transport: { |
| 459 | + type: "stdio", | |
| 484 | 460 | args: [], |
| 485 | 461 | ...server, |
| 486 | 462 | }, |
modified docs/docs/customize/deep-dives/mcp.mdx +0 −10
| @@ -20,15 +20,11 @@ | ||
| 20 | 20 | ```yaml title="config.yaml" |
| 21 | 21 | mcpServers: |
| 22 | 22 | - name: My MCP Server |
| 23 | - type: stdio | |
| 24 | 23 | command: uvx |
| 25 | 24 | args: |
| 26 | 25 | - mcp-server-sqlite |
| 27 | 26 | - --db-path |
| 28 | 27 | - /Users/NAME/test.db |
| 29 | - - name: My MCP Server with SSE | |
| 30 | - type: sse | |
| 31 | - url: "https://example.com/mcp-server/sse" | |
| 32 | 28 | ``` |
| 33 | 29 | </TabItem> |
| 34 | 30 | <TabItem value="json" label="JSON"> |
| @@ -42,12 +38,6 @@ | ||
| 42 | 38 | "command": "uvx", |
| 43 | 39 | "args": ["mcp-server-sqlite", "--db-path", "/Users/NAME/test.db"] |
| 44 | 40 | } |
| 45 | - }, | |
| 46 | - { | |
| 47 | - "transport": { | |
| 48 | - "type": "sse", | |
| 49 | - "url": "https://example.com/mcp-server/sse" | |
| 50 | - } | |
| 51 | 41 | } |
| 52 | 42 | ] |
| 53 | 43 | } |
modified docs/docs/reference.md +1 −13
| @@ -379,33 +379,21 @@ | ||
| 379 | 379 | **Properties:** |
| 380 | 380 | |
| 381 | 381 | - `name` (**required**): The name of the MCP server. |
| 382 | -- `type"` (**required**): The type of the MCP server. Can be "stdio", "sse", or "websocket". | |
| 383 | - | |
| 384 | -**Stdio type** | |
| 385 | - | |
| 386 | 382 | - `command` (**required**): The command used to start the server. |
| 387 | 383 | - `args`: An optional array of arguments for the command. |
| 388 | 384 | - `env`: An optional map of environment variables for the server process. |
| 389 | 385 | - `connectionTimeout`: An optional connection timeout number to the server in milliseconds. |
| 390 | 386 | |
| 391 | -**SSE or Websocket type** | |
| 392 | - | |
| 393 | -- `url` (**required**): The URL of the MCP server. | |
| 394 | - | |
| 395 | 387 | **Example:** |
| 396 | 388 | |
| 397 | 389 | ```yaml title="config.yaml" |
| 398 | 390 | mcpServers: |
| 399 | - - name: My MCP Server with stdio | |
| 400 | - type: stdio | |
| 391 | + - name: My MCP Server | |
| 401 | 392 | command: uvx |
| 402 | 393 | args: |
| 403 | 394 | - mcp-server-sqlite |
| 404 | 395 | - --db-path |
| 405 | 396 | - /Users/NAME/test.db |
| 406 | - - name: My MCP Server with SSE | |
| 407 | - type: sse | |
| 408 | - url: "https://example.com/mcp-server/sse" | |
| 409 | 397 | ``` |
| 410 | 398 | |
| 411 | 399 | ### `data` |
modified packages/config-yaml/src/converter.ts +7 −41
| @@ -128,48 +128,14 @@ | ||
| 128 | 128 | |
| 129 | 129 | function convertMcp(mcp: any): NonNullable<ConfigYaml["mcpServers"]>[number] { |
| 130 | 130 | const { transport } = mcp; |
| 131 | - const { type } = transport; | |
| 132 | - | |
| 133 | - // Common properties for all server types | |
| 134 | - const baseServer: any = { | |
| 135 | - name: mcp.name, | |
| 136 | - type: type, | |
| 131 | + const { command, args, env, server_name } = transport; | |
| 132 | + | |
| 133 | + return { | |
| 134 | + command, | |
| 135 | + args, | |
| 136 | + env, | |
| 137 | + name: server_name || "MCP Server", | |
| 137 | 138 | }; |
| 138 | - | |
| 139 | - if (mcp.faviconUrl) { | |
| 140 | - baseServer.faviconUrl = mcp.faviconUrl | |
| 141 | - } | |
| 142 | - if (mcp.connectionTimeout) { | |
| 143 | - baseServer.connectionTimeout = mcp.connectionTimeout | |
| 144 | - } | |
| 145 | - | |
| 146 | - // Type-specific properties | |
| 147 | - switch (type) { | |
| 148 | - case "stdio": | |
| 149 | - const stdioServer = { | |
| 150 | - ...baseServer, | |
| 151 | - command: transport.command, | |
| 152 | - }; | |
| 153 | - | |
| 154 | - if (transport.args) { | |
| 155 | - stdioServer.args = transport.args | |
| 156 | - } | |
| 157 | - if (transport.env) { | |
| 158 | - stdioServer.env = transport.env | |
| 159 | - } | |
| 160 | - | |
| 161 | - return stdioServer; | |
| 162 | - | |
| 163 | - case "sse": | |
| 164 | - case "websocket": | |
| 165 | - return { | |
| 166 | - ...baseServer, | |
| 167 | - url: transport.url | |
| 168 | - }; | |
| 169 | - | |
| 170 | - default: | |
| 171 | - throw new Error(`Unknown MCP server type: ${type}`); | |
| 172 | - } | |
| 173 | 139 | } |
| 174 | 140 | |
| 175 | 141 | function convertDoc( |
modified packages/config-yaml/src/schemas/index.ts +11 −38
| @@ -9,31 +9,14 @@ | ||
| 9 | 9 | params: z.any().optional(), |
| 10 | 10 | }); |
| 11 | 11 | |
| 12 | -const mcpServerSchema = z.discriminatedUnion("type", [ | |
| 13 | - z.object({ | |
| 14 | - name: z.string(), | |
| 15 | - type: z.literal("stdio"), | |
| 16 | - command: z.string(), | |
| 17 | - faviconUrl: z.string().optional(), | |
| 18 | - args: z.array(z.string()).optional(), | |
| 19 | - env: z.record(z.string()).optional(), | |
| 20 | - connectionTimeout: z.number().gt(0).optional() | |
| 21 | - }), | |
| 22 | - z.object({ | |
| 23 | - name: z.string(), | |
| 24 | - type: z.literal("sse"), | |
| 25 | - url: z.string(), | |
| 26 | - faviconUrl: z.string().optional(), | |
| 27 | - connectionTimeout: z.number().gt(0).optional() | |
| 28 | - }), | |
| 29 | - z.object({ | |
| 30 | - name: z.string(), | |
| 31 | - type: z.literal("websocket"), | |
| 32 | - url: z.string(), | |
| 33 | - faviconUrl: z.string().optional(), | |
| 34 | - connectionTimeout: z.number().gt(0).optional() | |
| 35 | - }) | |
| 36 | -]); | |
| 12 | +const mcpServerSchema = z.object({ | |
| 13 | + name: z.string(), | |
| 14 | + command: z.string(), | |
| 15 | + faviconUrl: z.string().optional(), | |
| 16 | + args: z.array(z.string()).optional(), | |
| 17 | + env: z.record(z.string()).optional(), | |
| 18 | + connectionTimeout: z.number().gt(0).optional() | |
| 19 | +}); | |
| 37 | 20 | |
| 38 | 21 | export type MCPServer = z.infer<typeof mcpServerSchema>; |
| 39 | 22 | |
| @@ -78,17 +61,7 @@ | ||
| 78 | 61 | export const blockOrSchema = <T extends z.AnyZodObject>( |
| 79 | 62 | schema: T, |
| 80 | 63 | usesSchema: z.ZodTypeAny = defaultUsesSchema, |
| 81 | - isDiscriminatedUnion?: boolean, | |
| 82 | -) => { | |
| 83 | - if (isDiscriminatedUnion) { | |
| 84 | - return z.union([schema, z.object({ | |
| 85 | - uses: usesSchema, | |
| 86 | - with: z.record(z.string()).optional(), | |
| 87 | - override: z.any().optional(), | |
| 88 | - })]); | |
| 89 | - } | |
| 90 | - return z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); | |
| 91 | -}; | |
| 64 | +) => z.union([schema, blockItemWrapperSchema(schema, usesSchema)]); | |
| 92 | 65 | |
| 93 | 66 | export const commonMetadataSchema = z.object({ |
| 94 | 67 | tags: z.string().optional(), |
| @@ -125,7 +98,7 @@ | ||
| 125 | 98 | .optional(), |
| 126 | 99 | context: z.array(blockOrSchema(contextSchema)).optional(), |
| 127 | 100 | data: z.array(blockOrSchema(dataSchema)).optional(), |
| 128 | - mcpServers: z.array(blockOrSchema(mcpServerSchema as any, defaultUsesSchema, true)).optional(), | |
| 101 | + mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(), | |
| 129 | 102 | rules: z |
| 130 | 103 | .array( |
| 131 | 104 | z.union([ |
| @@ -250,4 +223,4 @@ | ||
| 250 | 223 | api_key: z.string().optional(), |
| 251 | 224 | }); |
| 252 | 225 | |
| 253 | -export type Config = z.infer<typeof configSchema>; | |
| No newline at the end of the file | ||
| 226 | +export type Config = z.infer<typeof configSchema>; |