Changesets · Branches · Tags · Compare
| Changeset | 2fb75447cc67c7e1b6b80d71ba005d23c9695f2765596a3d8ecb7c02914dd26d |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-09-26 14:27 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-09-26 14:27 -07:00 |
| Parents | afa71ef33564, 4d8ba150996e |
33 files changed
modified core/config/load.ts +23 −10
| @@ -6,6 +6,7 @@ | ||
| 6 | 6 | import { |
| 7 | 7 | ConfigResult, |
| 8 | 8 | ConfigValidationError, |
| 9 | + mergeConfigYamlRequestOptions, | |
| 9 | 10 | ModelRole, |
| 10 | 11 | } from "@continuedev/config-yaml"; |
| 11 | 12 | import * as JSONC from "comment-json"; |
| @@ -25,6 +26,7 @@ | ||
| 25 | 26 | IdeType, |
| 26 | 27 | ILLM, |
| 27 | 28 | ILLMLogger, |
| 29 | + InternalMcpOptions, | |
| 28 | 30 | LLMOptions, |
| 29 | 31 | ModelDescription, |
| 30 | 32 | RerankerDescription, |
| @@ -57,8 +59,9 @@ | ||
| 57 | 59 | } from "../util/paths"; |
| 58 | 60 | import { localPathToUri } from "../util/pathToUri"; |
| 59 | 61 | |
| 60 | -import { PolicySingleton } from "../control-plane/PolicySingleton"; | |
| 62 | +import { loadJsonMcpConfigs } from "../context/mcp/json/loadJsonMcpConfigs"; | |
| 61 | 63 | import CustomContextProviderClass from "../context/providers/CustomContextProvider"; |
| 64 | +import { PolicySingleton } from "../control-plane/PolicySingleton"; | |
| 62 | 65 | import { getBaseToolDefinitions } from "../tools"; |
| 63 | 66 | import { resolveRelativePathInDir } from "../util/ideUtils"; |
| 64 | 67 | import { getWorkspaceRcConfigs } from "./json/loadRcConfigs"; |
| @@ -550,17 +553,27 @@ | ||
| 550 | 553 | if (orgPolicy?.policy?.allowMcpServers === false) { |
| 551 | 554 | await mcpManager.shutdown(); |
| 552 | 555 | } else { |
| 553 | - mcpManager.setConnections( | |
| 554 | - (config.experimental?.modelContextProtocolServers ?? []).map( | |
| 555 | - (server, index) => ({ | |
| 556 | - id: `continue-mcp-server-${index + 1}`, | |
| 557 | - name: `MCP Server`, | |
| 558 | - ...server, | |
| 559 | - requestOptions: config.requestOptions, | |
| 560 | - }), | |
| 556 | + const mcpOptions: InternalMcpOptions[] = ( | |
| 557 | + config.experimental?.modelContextProtocolServers ?? [] | |
| 558 | + ).map((server, index) => ({ | |
| 559 | + id: `continue-mcp-server-${index + 1}`, | |
| 560 | + name: `MCP Server`, | |
| 561 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 562 | + server.transport.type !== "stdio" | |
| 563 | + ? server.transport.requestOptions | |
| 564 | + : undefined, | |
| 565 | + config.requestOptions, | |
| 561 | 566 | ), |
| 562 | - false, | |
| 567 | + ...server.transport, | |
| 568 | + })); | |
| 569 | + const { errors: jsonMcpErrors, mcpServers } = await loadJsonMcpConfigs( | |
| 570 | + ide, | |
| 571 | + true, | |
| 572 | + config.requestOptions, | |
| 563 | 573 | ); |
| 574 | + errors.push(...jsonMcpErrors); | |
| 575 | + mcpOptions.push(...mcpServers); | |
| 576 | + mcpManager.setConnections(mcpOptions, false); | |
| 564 | 577 | } |
| 565 | 578 | |
| 566 | 579 | // Handle experimental modelRole config values for apply and edit |
modified core/config/loadLocalAssistants.ts +28 −3
| @@ -1,3 +1,4 @@ | ||
| 1 | +import { BLOCK_TYPES } from "@continuedev/config-yaml"; | |
| 1 | 2 | import ignore from "ignore"; |
| 2 | 3 | import * as URI from "uri-js"; |
| 3 | 4 | import { IDE } from ".."; |
| @@ -6,12 +7,32 @@ | ||
| 6 | 7 | DEFAULT_IGNORE_FILETYPES, |
| 7 | 8 | } from "../indexing/ignore"; |
| 8 | 9 | import { walkDir } from "../indexing/walkDir"; |
| 10 | +import { RULES_MARKDOWN_FILENAME } from "../llm/rules/constants"; | |
| 9 | 11 | import { getGlobalFolderWithName } from "../util/paths"; |
| 10 | 12 | import { localPathToUri } from "../util/pathToUri"; |
| 11 | -import { joinPathsToUri } from "../util/uri"; | |
| 13 | +import { getUriPathBasename, joinPathsToUri } from "../util/uri"; | |
| 14 | +import { SYSTEM_PROMPT_DOT_FILE } from "./getWorkspaceContinueRuleDotFiles"; | |
| 15 | +export function isContinueConfigRelatedUri(uri: string): boolean { | |
| 16 | + return ( | |
| 17 | + uri.endsWith(".continuerc.json") || | |
| 18 | + uri.endsWith(".prompt") || | |
| 19 | + uri.endsWith("AGENTS.md") || | |
| 20 | + uri.endsWith("AGENT.md") || | |
| 21 | + uri.endsWith("CLAUDE.md") || | |
| 22 | + uri.endsWith(SYSTEM_PROMPT_DOT_FILE) || | |
| 23 | + (uri.includes(".continue") && | |
| 24 | + (uri.endsWith(".yaml") || | |
| 25 | + uri.endsWith(".yml") || | |
| 26 | + uri.endsWith(".json"))) || | |
| 27 | + [...BLOCK_TYPES, "agents", "assistants"].some((blockType) => | |
| 28 | + uri.includes(`.continue/${blockType}`), | |
| 29 | + ) | |
| 30 | + ); | |
| 31 | +} | |
| 12 | 32 | |
| 13 | -export function isLocalDefinitionFile(uri: string): boolean { | |
| 14 | - if (!uri.endsWith(".yaml") && !uri.endsWith(".yml") && !uri.endsWith(".md")) { | |
| 33 | +export function isContinueAgentConfigFile(uri: string): boolean { | |
| 34 | + const isYaml = uri.endsWith(".yaml") || uri.endsWith(".yml"); | |
| 35 | + if (!isYaml) { | |
| 15 | 36 | return false; |
| 16 | 37 | } |
| 17 | 38 | |
| @@ -22,6 +43,10 @@ | ||
| 22 | 43 | ); |
| 23 | 44 | } |
| 24 | 45 | |
| 46 | +export function isColocatedRulesFile(uri: string): boolean { | |
| 47 | + return getUriPathBasename(uri) === RULES_MARKDOWN_FILENAME; | |
| 48 | +} | |
| 49 | + | |
| 25 | 50 | async function getDefinitionFilesInDir( |
| 26 | 51 | ide: IDE, |
| 27 | 52 | dir: string, |
modified core/config/yaml/loadYaml.ts +36 −30
| @@ -15,7 +15,14 @@ | ||
| 15 | 15 | } from "@continuedev/config-yaml"; |
| 16 | 16 | import { dirname } from "node:path"; |
| 17 | 17 | |
| 18 | -import { ContinueConfig, IDE, IdeInfo, IdeSettings, ILLMLogger } from "../.."; | |
| 18 | +import { | |
| 19 | + ContinueConfig, | |
| 20 | + IDE, | |
| 21 | + IdeInfo, | |
| 22 | + IdeSettings, | |
| 23 | + ILLMLogger, | |
| 24 | + InternalMcpOptions, | |
| 25 | +} from "../.."; | |
| 19 | 26 | import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton"; |
| 20 | 27 | import { ControlPlaneClient } from "../../control-plane/client"; |
| 21 | 28 | import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider"; |
| @@ -25,6 +32,7 @@ | ||
| 25 | 32 | |
| 26 | 33 | import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand"; |
| 27 | 34 | import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand"; |
| 35 | +import { loadJsonMcpConfigs } from "../../context/mcp/json/loadJsonMcpConfigs"; | |
| 28 | 36 | import { getControlPlaneEnvSync } from "../../control-plane/env"; |
| 29 | 37 | import { PolicySingleton } from "../../control-plane/PolicySingleton"; |
| 30 | 38 | import { getBaseToolDefinitions } from "../../tools"; |
| @@ -34,7 +42,10 @@ | ||
| 34 | 42 | import { unrollLocalYamlBlocks } from "./loadLocalYamlBlocks"; |
| 35 | 43 | import { LocalPlatformClient } from "./LocalPlatformClient"; |
| 36 | 44 | import { llmsFromModelConfig } from "./models"; |
| 37 | -import { convertYamlRuleToContinueRule } from "./yamlToContinueConfig"; | |
| 45 | +import { | |
| 46 | + convertYamlMcpConfigToInternalMcpOptions, | |
| 47 | + convertYamlRuleToContinueRule, | |
| 48 | +} from "./yamlToContinueConfig"; | |
| 38 | 49 | |
| 39 | 50 | async function loadConfigYaml(options: { |
| 40 | 51 | overrideConfigYaml: AssistantUnrolled | undefined; |
| @@ -227,17 +238,19 @@ | ||
| 227 | 238 | })); |
| 228 | 239 | |
| 229 | 240 | config.mcpServers?.forEach((mcpServer) => { |
| 230 | - const mcpArgVariables = | |
| 231 | - mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; | |
| 232 | - | |
| 233 | - if (mcpArgVariables.length === 0) { | |
| 234 | - return; | |
| 235 | - } | |
| 241 | + if ("args" in mcpServer) { | |
| 242 | + const mcpArgVariables = | |
| 243 | + mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; | |
| 244 | + | |
| 245 | + if (mcpArgVariables.length === 0) { | |
| 246 | + return; | |
| 247 | + } | |
| 236 | 248 | |
| 237 | - localErrors.push({ | |
| 238 | - fatal: false, | |
| 239 | - message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}. Please refer to https://docs.continue.dev/hub/secrets/secret-types for managing hub secrets.`, | |
| 240 | - }); | |
| 249 | + localErrors.push({ | |
| 250 | + fatal: false, | |
| 251 | + message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}. Please refer to https://docs.continue.dev/hub/secrets/secret-types for managing hub secrets.`, | |
| 252 | + }); | |
| 253 | + } | |
| 241 | 254 | }); |
| 242 | 255 | |
| 243 | 256 | // Prompt files - |
| @@ -381,25 +394,18 @@ | ||
| 381 | 394 | if (orgPolicy?.policy?.allowMcpServers === false) { |
| 382 | 395 | await mcpManager.shutdown(); |
| 383 | 396 | } else { |
| 384 | - mcpManager.setConnections( | |
| 385 | - (config.mcpServers ?? []).map((server) => ({ | |
| 386 | - id: server.name, | |
| 387 | - name: server.name, | |
| 388 | - sourceFile: server.sourceFile, | |
| 389 | - transport: { | |
| 390 | - type: "stdio", | |
| 391 | - args: [], | |
| 392 | - requestOptions: mergeConfigYamlRequestOptions( | |
| 393 | - server.requestOptions, | |
| 394 | - config.requestOptions, | |
| 395 | - ), | |
| 396 | - ...(server as any), // TODO: fix the types on mcpServers in config-yaml | |
| 397 | - }, | |
| 398 | - timeout: server.connectionTimeout, | |
| 399 | - })), | |
| 400 | - false, | |
| 401 | - { ide }, | |
| 397 | + const mcpOptions: InternalMcpOptions[] = (config.mcpServers ?? []).map( | |
| 398 | + (server) => | |
| 399 | + convertYamlMcpConfigToInternalMcpOptions(server, config.requestOptions), | |
| 400 | + ); | |
| 401 | + const { errors: jsonMcpErrors, mcpServers } = await loadJsonMcpConfigs( | |
| 402 | + ide, | |
| 403 | + true, | |
| 404 | + config.requestOptions, | |
| 402 | 405 | ); |
| 406 | + localErrors.push(...jsonMcpErrors); | |
| 407 | + mcpOptions.push(...mcpServers); | |
| 408 | + mcpManager.setConnections(mcpOptions, false, { ide }); | |
| 403 | 409 | } |
| 404 | 410 | |
| 405 | 411 | return { config: continueConfig, errors: localErrors }; |
modified core/config/yaml/yamlToContinueConfig.ts +51 −14
| @@ -1,5 +1,16 @@ | ||
| 1 | -import { MCPServer, Rule } from "@continuedev/config-yaml"; | |
| 2 | -import { ExperimentalMCPOptions, RuleWithSource } from "../.."; | |
| 1 | +import { | |
| 2 | + MCPServer, | |
| 3 | + mergeConfigYamlRequestOptions, | |
| 4 | + RequestOptions, | |
| 5 | + Rule, | |
| 6 | +} from "@continuedev/config-yaml"; | |
| 7 | +import { | |
| 8 | + InternalMcpOptions, | |
| 9 | + InternalSseMcpOptions, | |
| 10 | + InternalStdioMcpOptions, | |
| 11 | + InternalStreamableHttpMcpOptions, | |
| 12 | + RuleWithSource, | |
| 13 | +} from "../.."; | |
| 3 | 14 | |
| 4 | 15 | export function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource { |
| 5 | 16 | if (typeof rule === "string") { |
| @@ -21,17 +32,43 @@ | ||
| 21 | 32 | } |
| 22 | 33 | } |
| 23 | 34 | |
| 24 | -export function convertYamlMcpToContinueMcp( | |
| 25 | - server: MCPServer, | |
| 26 | -): ExperimentalMCPOptions { | |
| 27 | - return { | |
| 28 | - transport: { | |
| 29 | - type: "stdio", | |
| 30 | - command: server.command, | |
| 31 | - args: server.args ?? [], | |
| 32 | - env: server.env, | |
| 33 | - cwd: server.cwd, | |
| 34 | - } as any, // TODO: Fix the mcpServers types in config-yaml (discriminated union) | |
| 35 | - timeout: server.connectionTimeout, | |
| 35 | +export function convertYamlMcpConfigToInternalMcpOptions( | |
| 36 | + config: MCPServer, | |
| 37 | + globalRequestOptions?: RequestOptions, | |
| 38 | +): InternalMcpOptions { | |
| 39 | + const { connectionTimeout, faviconUrl, name, sourceFile } = config; | |
| 40 | + const shared = { | |
| 41 | + id: name, | |
| 42 | + name, | |
| 43 | + faviconUrl: faviconUrl, | |
| 44 | + timeout: connectionTimeout, | |
| 45 | + sourceFile, | |
| 36 | 46 | }; |
| 47 | + // Stdio | |
| 48 | + if ("command" in config) { | |
| 49 | + const { args, command, cwd, env, type } = config; | |
| 50 | + const stdioOptions: InternalStdioMcpOptions = { | |
| 51 | + type, | |
| 52 | + command, | |
| 53 | + args, | |
| 54 | + cwd, | |
| 55 | + env, | |
| 56 | + ...shared, | |
| 57 | + }; | |
| 58 | + return stdioOptions; | |
| 59 | + } | |
| 60 | + // HTTP/SSE | |
| 61 | + const { type, url, requestOptions } = config; | |
| 62 | + const httpSseConfig: | |
| 63 | + | InternalStreamableHttpMcpOptions | |
| 64 | + | InternalSseMcpOptions = { | |
| 65 | + type, | |
| 66 | + url, | |
| 67 | + requestOptions: mergeConfigYamlRequestOptions( | |
| 68 | + requestOptions, | |
| 69 | + globalRequestOptions, | |
| 70 | + ), | |
| 71 | + ...shared, | |
| 72 | + }; | |
| 73 | + return httpSseConfig; | |
| 37 | 74 | } |
modified core/context/mcp/MCPConnection.ts +162 −111
| @@ -10,8 +10,12 @@ | ||
| 10 | 10 | import { Agent as HttpsAgent } from "https"; |
| 11 | 11 | import { |
| 12 | 12 | IDE, |
| 13 | + InternalMcpOptions, | |
| 14 | + InternalSseMcpOptions, | |
| 15 | + InternalStdioMcpOptions, | |
| 16 | + InternalStreamableHttpMcpOptions, | |
| 17 | + InternalWebsocketMcpOptions, | |
| 13 | 18 | MCPConnectionStatus, |
| 14 | - MCPOptions, | |
| 15 | 19 | MCPPrompt, |
| 16 | 20 | MCPResource, |
| 17 | 21 | MCPResourceTemplate, |
| @@ -65,7 +69,7 @@ | ||
| 65 | 69 | }; |
| 66 | 70 | |
| 67 | 71 | constructor( |
| 68 | - public options: MCPOptions, | |
| 72 | + public options: InternalMcpOptions, | |
| 69 | 73 | public extras?: MCPExtras, |
| 70 | 74 | ) { |
| 71 | 75 | // Don't construct transport in constructor to avoid blocking |
| @@ -132,20 +136,20 @@ | ||
| 132 | 136 | this.abortController = new AbortController(); |
| 133 | 137 | |
| 134 | 138 | // currently support oauth for sse transports only |
| 135 | - if (this.options.transport.type === "sse") { | |
| 136 | - if (!this.options.transport.requestOptions) { | |
| 137 | - this.options.transport.requestOptions = { | |
| 139 | + if (this.options.type === "sse") { | |
| 140 | + if (!this.options.requestOptions) { | |
| 141 | + this.options.requestOptions = { | |
| 138 | 142 | headers: {}, |
| 139 | 143 | }; |
| 140 | 144 | } |
| 141 | 145 | const accessToken = await getOauthToken( |
| 142 | - this.options.transport.url, | |
| 146 | + this.options.url, | |
| 143 | 147 | this.extras?.ide!, |
| 144 | 148 | ); |
| 145 | 149 | if (accessToken) { |
| 146 | 150 | this.isProtectedResource = true; |
| 147 | - this.options.transport.requestOptions.headers = { | |
| 148 | - ...this.options.transport.requestOptions.headers, | |
| 151 | + this.options.requestOptions.headers = { | |
| 152 | + ...this.options.requestOptions.headers, | |
| 149 | 153 | Authorization: `Bearer ${accessToken}`, |
| 150 | 154 | }; |
| 151 | 155 | } |
| @@ -178,22 +182,71 @@ | ||
| 178 | 182 | }); |
| 179 | 183 | }), |
| 180 | 184 | (async () => { |
| 181 | - this.transport = await this.constructTransportAsync(this.options); | |
| 182 | - | |
| 183 | - try { | |
| 184 | - await this.client.connect(this.transport); | |
| 185 | - } catch (error) { | |
| 186 | - // Allow the case where for whatever reason is already connected | |
| 187 | - if ( | |
| 188 | - error instanceof Error && | |
| 189 | - error.message.startsWith( | |
| 190 | - "StdioClientTransport already started", | |
| 191 | - ) | |
| 192 | - ) { | |
| 193 | - await this.client.close(); | |
| 194 | - await this.client.connect(this.transport); | |
| 185 | + if ("command" in this.options) { | |
| 186 | + // STDIO: no need to check type, just if command is present | |
| 187 | + const transport = await this.constructStdioTransport( | |
| 188 | + this.options, | |
| 189 | + ); | |
| 190 | + try { | |
| 191 | + await this.client.connect(transport, {}); | |
| 192 | + this.transport = transport; | |
| 193 | + } catch (error) { | |
| 194 | + // Allow the case where for whatever reason is already connected | |
| 195 | + if ( | |
| 196 | + error instanceof Error && | |
| 197 | + error.message.startsWith( | |
| 198 | + "StdioClientTransport already started", | |
| 199 | + ) | |
| 200 | + ) { | |
| 201 | + await this.client.close(); | |
| 202 | + await this.client.connect(transport); | |
| 203 | + this.transport = transport; | |
| 204 | + } else { | |
| 205 | + throw error; | |
| 206 | + } | |
| 207 | + } | |
| 208 | + } else { | |
| 209 | + // SSE/HTTP: if type isn't explicit: try http and fall back to sse | |
| 210 | + if (this.options.type === "sse") { | |
| 211 | + const transport = this.constructSseTransport(this.options); | |
| 212 | + await this.client.connect(transport, {}); | |
| 213 | + this.transport = transport; | |
| 214 | + } else if (this.options.type === "streamable-http") { | |
| 215 | + const transport = this.constructHttpTransport(this.options); | |
| 216 | + await this.client.connect(transport, {}); | |
| 217 | + this.transport = transport; | |
| 218 | + } else if (this.options.type === "websocket") { | |
| 219 | + const transport = this.constructWebsocketTransport( | |
| 220 | + this.options, | |
| 221 | + ); | |
| 222 | + await this.client.connect(transport, {}); | |
| 223 | + this.transport = transport; | |
| 224 | + } else if (this.options.type) { | |
| 225 | + throw new Error( | |
| 226 | + `Unsupported transport type: ${this.options.type}`, | |
| 227 | + ); | |
| 195 | 228 | } else { |
| 196 | - throw error; | |
| 229 | + try { | |
| 230 | + const transport = this.constructHttpTransport({ | |
| 231 | + ...this.options, | |
| 232 | + type: "streamable-http", | |
| 233 | + }); | |
| 234 | + await this.client.connect(transport, {}); | |
| 235 | + this.transport = transport; | |
| 236 | + } catch (e) { | |
| 237 | + try { | |
| 238 | + const transport = this.constructSseTransport({ | |
| 239 | + ...this.options, | |
| 240 | + type: "sse", | |
| 241 | + }); | |
| 242 | + await this.client.connect(transport, {}); | |
| 243 | + this.transport = transport; | |
| 244 | + } catch (e) { | |
| 245 | + throw new Error( | |
| 246 | + `MCP config with URL and no type specified failed both SSE and HTTP connection: ${e instanceof Error ? e.message : String(e)}`, | |
| 247 | + ); | |
| 248 | + } | |
| 249 | + } | |
| 197 | 250 | } |
| 198 | 251 | } |
| 199 | 252 | |
| @@ -202,7 +255,6 @@ | ||
| 202 | 255 | // this.client.setNotificationHandler(, notification => { |
| 203 | 256 | // console.log(notification) |
| 204 | 257 | // }) |
| 205 | - | |
| 206 | 258 | const capabilities = this.client.getServerCapabilities(); |
| 207 | 259 | |
| 208 | 260 | // Resources <—> Context Provider |
| @@ -305,7 +357,7 @@ | ||
| 305 | 357 | |
| 306 | 358 | // Include stdio output if available for stdio transport |
| 307 | 359 | if ( |
| 308 | - this.options.transport.type === "stdio" && | |
| 360 | + this.options.type === "stdio" && | |
| 309 | 361 | (this.stdioOutput.stdout || this.stdioOutput.stderr) |
| 310 | 362 | ) { |
| 311 | 363 | errorMessage += "\n\nProcess output:"; |
| @@ -356,98 +408,97 @@ | ||
| 356 | 408 | }; |
| 357 | 409 | } |
| 358 | 410 | |
| 359 | - private async constructTransportAsync( | |
| 360 | - options: MCPOptions, | |
| 361 | - ): Promise<Transport> { | |
| 362 | - switch (options.transport.type) { | |
| 363 | - case "stdio": | |
| 364 | - const env: Record<string, string> = options.transport.env | |
| 365 | - ? { ...options.transport.env } | |
| 366 | - : {}; | |
| 367 | - | |
| 368 | - if (process.env.PATH !== undefined) { | |
| 369 | - // Set the initial PATH from process.env | |
| 370 | - env.PATH = process.env.PATH; | |
| 371 | - | |
| 372 | - // For non-Windows platforms, try to get the PATH from user shell | |
| 373 | - if (process.platform !== "win32") { | |
| 374 | - try { | |
| 375 | - const shellEnvPath = await getEnvPathFromUserShell(); | |
| 376 | - if (shellEnvPath && shellEnvPath !== process.env.PATH) { | |
| 377 | - env.PATH = shellEnvPath; | |
| 378 | - } | |
| 379 | - } catch (err) { | |
| 380 | - console.error("Error getting PATH:", err); | |
| 381 | - } | |
| 382 | - } | |
| 383 | - } | |
| 411 | + private constructWebsocketTransport( | |
| 412 | + options: InternalWebsocketMcpOptions, | |
| 413 | + ): WebSocketClientTransport { | |
| 414 | + return new WebSocketClientTransport(new URL(options.url)); | |
| 415 | + } | |
| 384 | 416 | |
| 385 | - // Resolve the command and args for the current platform | |
| 386 | - const { command, args } = this.resolveCommandForPlatform( | |
| 387 | - options.transport.command, | |
| 388 | - options.transport.args || [], | |
| 389 | - ); | |
| 417 | + private constructSseTransport( | |
| 418 | + options: InternalSseMcpOptions, | |
| 419 | + ): SSEClientTransport { | |
| 420 | + const sseAgent = | |
| 421 | + options.requestOptions?.verifySsl === false | |
| 422 | + ? new HttpsAgent({ rejectUnauthorized: false }) | |
| 423 | + : undefined; | |
| 424 | + | |
| 425 | + return new SSEClientTransport(new URL(options.url), { | |
| 426 | + eventSourceInit: { | |
| 427 | + fetch: (input, init) => | |
| 428 | + fetch(input, { | |
| 429 | + ...init, | |
| 430 | + headers: { | |
| 431 | + ...init?.headers, | |
| 432 | + ...options.requestOptions?.headers, | |
| 433 | + }, | |
| 434 | + ...(sseAgent && { agent: sseAgent }), | |
| 435 | + }), | |
| 436 | + }, | |
| 437 | + requestInit: { | |
| 438 | + headers: options.requestOptions?.headers, | |
| 439 | + ...(sseAgent && { agent: sseAgent }), | |
| 440 | + }, | |
| 441 | + }); | |
| 442 | + } | |
| 390 | 443 | |
| 391 | - const transport = new StdioClientTransport({ | |
| 392 | - command, | |
| 393 | - args, | |
| 394 | - env, | |
| 395 | - cwd: options.transport.cwd, | |
| 396 | - stderr: "pipe", | |
| 397 | - }); | |
| 444 | + private constructHttpTransport( | |
| 445 | + options: InternalStreamableHttpMcpOptions, | |
| 446 | + ): StreamableHTTPClientTransport { | |
| 447 | + const { url, requestOptions } = options; | |
| 448 | + const streamableAgent = | |
| 449 | + requestOptions?.verifySsl === false | |
| 450 | + ? new HttpsAgent({ rejectUnauthorized: false }) | |
| 451 | + : undefined; | |
| 452 | + | |
| 453 | + return new StreamableHTTPClientTransport(new URL(url), { | |
| 454 | + requestInit: { | |
| 455 | + headers: requestOptions?.headers, | |
| 456 | + ...(streamableAgent && { agent: streamableAgent }), | |
| 457 | + }, | |
| 458 | + }); | |
| 459 | + } | |
| 398 | 460 | |
| 399 | - // Capture stdio output for better error reporting | |
| 461 | + private async constructStdioTransport( | |
| 462 | + options: InternalStdioMcpOptions, | |
| 463 | + ): Promise<StdioClientTransport> { | |
| 464 | + const env: Record<string, string> = options.env ? { ...options.env } : {}; | |
| 400 | 465 | |
| 401 | - transport.stderr?.on("data", (data: Buffer) => { | |
| 402 | - this.stdioOutput.stderr += data.toString(); | |
| 403 | - }); | |
| 466 | + if (process.env.PATH !== undefined) { | |
| 467 | + // Set the initial PATH from process.env | |
| 468 | + env.PATH = process.env.PATH; | |
| 404 | 469 | |
| 405 | - return transport; | |
| 406 | - case "websocket": | |
| 407 | - return new WebSocketClientTransport(new URL(options.transport.url)); | |
| 408 | - case "sse": | |
| 409 | - const sseAgent = | |
| 410 | - options.transport.requestOptions?.verifySsl === false | |
| 411 | - ? new HttpsAgent({ rejectUnauthorized: false }) | |
| 412 | - : undefined; | |
| 413 | - | |
| 414 | - return new SSEClientTransport(new URL(options.transport.url), { | |
| 415 | - eventSourceInit: { | |
| 416 | - fetch: (input, init) => | |
| 417 | - fetch(input, { | |
| 418 | - ...init, | |
| 419 | - headers: { | |
| 420 | - ...init?.headers, | |
| 421 | - ...(options.transport.requestOptions?.headers as | |
| 422 | - | Record<string, string> | |
| 423 | - | undefined), | |
| 424 | - }, | |
| 425 | - ...(sseAgent && { agent: sseAgent }), | |
| 426 | - }), | |
| 427 | - }, | |
| 428 | - requestInit: { | |
| 429 | - headers: options.transport.requestOptions?.headers, | |
| 430 | - ...(sseAgent && { agent: sseAgent }), | |
| 431 | - }, | |
| 432 | - }); | |
| 433 | - case "streamable-http": | |
| 434 | - const { url, requestOptions } = options.transport; | |
| 435 | - const streamableAgent = | |
| 436 | - requestOptions?.verifySsl === false | |
| 437 | - ? new HttpsAgent({ rejectUnauthorized: false }) | |
| 438 | - : undefined; | |
| 439 | - | |
| 440 | - return new StreamableHTTPClientTransport(new URL(url), { | |
| 441 | - requestInit: { | |
| 442 | - headers: requestOptions?.headers, | |
| 443 | - ...(streamableAgent && { agent: streamableAgent }), | |
| 444 | - }, | |
| 445 | - }); | |
| 446 | - default: | |
| 447 | - throw new Error( | |
| 448 | - `Unsupported transport type: ${(options.transport as any).type}`, | |
| 449 | - ); | |
| 470 | + // For non-Windows platforms, try to get the PATH from user shell | |
| 471 | + if (process.platform !== "win32") { | |
| 472 | + try { | |
| 473 | + const shellEnvPath = await getEnvPathFromUserShell(); | |
| 474 | + if (shellEnvPath && shellEnvPath !== process.env.PATH) { | |
| 475 | + env.PATH = shellEnvPath; | |
| 476 | + } | |
| 477 | + } catch (err) { | |
| 478 | + console.error("Error getting PATH:", err); | |
| 479 | + } | |
| 480 | + } | |
| 450 | 481 | } |
| 482 | + | |
| 483 | + const { command, args } = this.resolveCommandForPlatform( | |
| 484 | + options.command, | |
| 485 | + options.args || [], | |
| 486 | + ); | |
| 487 | + | |
| 488 | + const transport = new StdioClientTransport({ | |
| 489 | + command, | |
| 490 | + args, | |
| 491 | + env, | |
| 492 | + cwd: options.cwd, | |
| 493 | + stderr: "pipe", | |
| 494 | + }); | |
| 495 | + | |
| 496 | + // Capture stdio output for better error reporting | |
| 497 | + transport.stderr?.on("data", (data: Buffer) => { | |
| 498 | + this.stdioOutput.stderr += data.toString(); | |
| 499 | + }); | |
| 500 | + | |
| 501 | + return transport; | |
| 451 | 502 | } |
| 452 | 503 | } |
| 453 | 504 |
modified core/context/mcp/MCPConnection.vitest.ts +51 −65
| @@ -1,5 +1,10 @@ | ||
| 1 | 1 | import { Client } from "@modelcontextprotocol/sdk/client/index.js"; |
| 2 | 2 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 3 | +import { | |
| 4 | + InternalSseMcpOptions, | |
| 5 | + InternalStdioMcpOptions, | |
| 6 | + InternalWebsocketMcpOptions, | |
| 7 | +} from "../.."; | |
| 3 | 8 | import MCPConnection from "./MCPConnection"; |
| 4 | 9 | |
| 5 | 10 | // Mock the shell path utility |
| @@ -16,15 +21,13 @@ | ||
| 16 | 21 | |
| 17 | 22 | describe("constructor", () => { |
| 18 | 23 | it("should create instance with stdio transport", () => { |
| 19 | - const options = { | |
| 24 | + const options: InternalStdioMcpOptions = { | |
| 20 | 25 | name: "test-mcp", |
| 21 | 26 | id: "test-id", |
| 22 | - transport: { | |
| 23 | - type: "stdio" as const, | |
| 24 | - command: "test-cmd", | |
| 25 | - args: ["--test"], | |
| 26 | - env: { TEST: "true" }, | |
| 27 | - }, | |
| 27 | + type: "stdio", | |
| 28 | + command: "test-cmd", | |
| 29 | + args: ["--test"], | |
| 30 | + env: { TEST: "true" }, | |
| 28 | 31 | }; |
| 29 | 32 | |
| 30 | 33 | const conn = new MCPConnection(options); |
| @@ -33,34 +36,30 @@ | ||
| 33 | 36 | }); |
| 34 | 37 | |
| 35 | 38 | it("should create instance with stdio transport including cwd", () => { |
| 36 | - const options = { | |
| 39 | + const options: InternalStdioMcpOptions = { | |
| 37 | 40 | name: "test-mcp", |
| 38 | 41 | id: "test-id", |
| 39 | - transport: { | |
| 40 | - type: "stdio" as const, | |
| 41 | - command: "test-cmd", | |
| 42 | - args: ["--test"], | |
| 43 | - env: { TEST: "true" }, | |
| 44 | - cwd: "/path/to/working/directory", | |
| 45 | - }, | |
| 42 | + type: "stdio", | |
| 43 | + command: "test-cmd", | |
| 44 | + args: ["--test"], | |
| 45 | + env: { TEST: "true" }, | |
| 46 | + cwd: "/path/to/working/directory", | |
| 46 | 47 | }; |
| 47 | 48 | |
| 48 | 49 | const conn = new MCPConnection(options); |
| 49 | 50 | expect(conn).toBeInstanceOf(MCPConnection); |
| 50 | 51 | expect(conn.status).toBe("not-connected"); |
| 51 | - if (conn.options.transport.type === "stdio") { | |
| 52 | - expect(conn.options.transport.cwd).toBe("/path/to/working/directory"); | |
| 52 | + if (conn.options.type === "stdio") { | |
| 53 | + expect(conn.options.cwd).toBe("/path/to/working/directory"); | |
| 53 | 54 | } |
| 54 | 55 | }); |
| 55 | 56 | |
| 56 | 57 | it("should create instance with websocket transport", () => { |
| 57 | - const options = { | |
| 58 | + const options: InternalWebsocketMcpOptions = { | |
| 58 | 59 | name: "test-mcp", |
| 59 | 60 | id: "test-id", |
| 60 | - transport: { | |
| 61 | - type: "websocket" as const, | |
| 62 | - url: "ws://test.com", | |
| 63 | - }, | |
| 61 | + type: "websocket", | |
| 62 | + url: "ws://test.com", | |
| 64 | 63 | }; |
| 65 | 64 | |
| 66 | 65 | const conn = new MCPConnection(options); |
| @@ -69,13 +68,11 @@ | ||
| 69 | 68 | }); |
| 70 | 69 | |
| 71 | 70 | it("should create instance with SSE transport", () => { |
| 72 | - const options = { | |
| 71 | + const options: InternalSseMcpOptions = { | |
| 73 | 72 | name: "test-mcp", |
| 74 | 73 | id: "test-id", |
| 75 | - transport: { | |
| 76 | - type: "sse" as const, | |
| 77 | - url: "http://test.com/events", | |
| 78 | - }, | |
| 74 | + type: "sse", | |
| 75 | + url: "http://test.com/events", | |
| 79 | 76 | }; |
| 80 | 77 | |
| 81 | 78 | const conn = new MCPConnection(options); |
| @@ -84,17 +81,15 @@ | ||
| 84 | 81 | }); |
| 85 | 82 | |
| 86 | 83 | it("should create instance with SSE transport and custom headers", () => { |
| 87 | - const options = { | |
| 84 | + const options: InternalSseMcpOptions = { | |
| 88 | 85 | name: "test-mcp", |
| 89 | 86 | id: "test-id", |
| 90 | - transport: { | |
| 91 | - type: "sse" as const, | |
| 92 | - url: "http://test.com/events", | |
| 93 | - requestOptions: { | |
| 94 | - headers: { | |
| 95 | - Authorization: "Bearer token123", | |
| 96 | - "X-Custom-Header": "custom-value", | |
| 97 | - }, | |
| 87 | + type: "sse", | |
| 88 | + url: "http://test.com/events", | |
| 89 | + requestOptions: { | |
| 90 | + headers: { | |
| 91 | + Authorization: "Bearer token123", | |
| 92 | + "X-Custom-Header": "custom-value", | |
| 98 | 93 | }, |
| 99 | 94 | }, |
| 100 | 95 | }; |
| @@ -108,9 +103,8 @@ | ||
| 108 | 103 | const options = { |
| 109 | 104 | name: "test-mcp", |
| 110 | 105 | id: "test-id", |
| 111 | - transport: { | |
| 112 | - type: "invalid", | |
| 113 | - } as any, | |
| 106 | + type: "invalid" as any, | |
| 107 | + url: "", | |
| 114 | 108 | }; |
| 115 | 109 | |
| 116 | 110 | const conn = new MCPConnection(options); |
| @@ -126,14 +120,12 @@ | ||
| 126 | 120 | |
| 127 | 121 | describe("getStatus", () => { |
| 128 | 122 | it("should return current status", () => { |
| 129 | - const options = { | |
| 123 | + const options: InternalStdioMcpOptions = { | |
| 130 | 124 | name: "test-mcp", |
| 131 | 125 | id: "test-id", |
| 132 | - transport: { | |
| 133 | - type: "stdio" as const, | |
| 134 | - command: "test", | |
| 135 | - args: [], | |
| 136 | - }, | |
| 126 | + type: "stdio", | |
| 127 | + command: "test", | |
| 128 | + args: [], | |
| 137 | 129 | }; |
| 138 | 130 | |
| 139 | 131 | const conn = new MCPConnection(options); |
| @@ -154,14 +146,12 @@ | ||
| 154 | 146 | }); |
| 155 | 147 | |
| 156 | 148 | describe("connectClient", () => { |
| 157 | - const options = { | |
| 149 | + const options: InternalStdioMcpOptions = { | |
| 158 | 150 | name: "test-mcp", |
| 159 | 151 | id: "test-id", |
| 160 | - transport: { | |
| 161 | - type: "stdio" as const, | |
| 162 | - command: "test-cmd", | |
| 163 | - args: [], | |
| 164 | - }, | |
| 152 | + type: "stdio", | |
| 153 | + command: "test-cmd", | |
| 154 | + args: [], | |
| 165 | 155 | }; |
| 166 | 156 | |
| 167 | 157 | it("should connect successfully", async () => { |
| @@ -282,17 +272,15 @@ | ||
| 282 | 272 | vi.restoreAllMocks(); |
| 283 | 273 | |
| 284 | 274 | // Use a command that will definitely fail and produce stderr output |
| 285 | - const failingOptions = { | |
| 275 | + const failingOptions: InternalStdioMcpOptions = { | |
| 286 | 276 | name: "failing-mcp", |
| 287 | 277 | id: "failing-id", |
| 288 | - transport: { | |
| 289 | - type: "stdio" as const, | |
| 290 | - command: "node", | |
| 291 | - args: [ | |
| 292 | - "-e", | |
| 293 | - "console.error('Custom error message from stderr'); process.exit(1);", | |
| 294 | - ], | |
| 295 | - }, | |
| 278 | + type: "stdio", | |
| 279 | + command: "node", | |
| 280 | + args: [ | |
| 281 | + "-e", | |
| 282 | + "console.error('Custom error message from stderr'); process.exit(1);", | |
| 283 | + ], | |
| 296 | 284 | timeout: 5000, // Give enough time for the command to run and fail |
| 297 | 285 | }; |
| 298 | 286 | |
| @@ -315,11 +303,9 @@ | ||
| 315 | 303 | const conn = new MCPConnection({ |
| 316 | 304 | id: "filesystem", |
| 317 | 305 | name: "Filesystem", |
| 318 | - transport: { | |
| 319 | - type: "stdio" as const, | |
| 320 | - command: "npx", | |
| 321 | - args: ["-y", "@modelcontextprotocol/server-filesystem", "."], | |
| 322 | - }, | |
| 306 | + type: "stdio", | |
| 307 | + command: "npx", | |
| 308 | + args: ["-y", "@modelcontextprotocol/server-filesystem", "."], | |
| 323 | 309 | }); |
| 324 | 310 | |
| 325 | 311 | try { |
modified core/context/mcp/MCPManagerSingleton.ts +20 −27
| @@ -1,11 +1,6 @@ | ||
| 1 | 1 | import { Client } from "@modelcontextprotocol/sdk/client/index.js"; |
| 2 | 2 | |
| 3 | -import { | |
| 4 | - MCPOptions, | |
| 5 | - MCPServerStatus, | |
| 6 | - StdioOptions, | |
| 7 | - TransportOptions, | |
| 8 | -} from "../.."; | |
| 3 | +import { InternalMcpOptions, MCPServerStatus } from "../.."; | |
| 9 | 4 | import MCPConnection, { MCPExtras } from "./MCPConnection"; |
| 10 | 5 | |
| 11 | 6 | export class MCPManagerSingleton { |
| @@ -38,7 +33,7 @@ | ||
| 38 | 33 | return this.disconnectedServers; |
| 39 | 34 | } |
| 40 | 35 | |
| 41 | - createConnection(id: string, options: MCPOptions): MCPConnection { | |
| 36 | + createConnection(id: string, options: InternalMcpOptions): MCPConnection { | |
| 42 | 37 | if (this.connections.has(id)) { |
| 43 | 38 | return this.connections.get(id)!; |
| 44 | 39 | } else { |
| @@ -77,7 +72,7 @@ | ||
| 77 | 72 | } |
| 78 | 73 | |
| 79 | 74 | setConnections( |
| 80 | - servers: MCPOptions[], | |
| 75 | + servers: InternalMcpOptions[], | |
| 81 | 76 | forceRefresh: boolean, |
| 82 | 77 | extras?: MCPExtras, |
| 83 | 78 | ) { |
| @@ -89,11 +84,7 @@ | ||
| 89 | 84 | !servers.find( |
| 90 | 85 | // Refresh the connection if TransportOptions changed |
| 91 | 86 | (s) => |
| 92 | - s.id === id && | |
| 93 | - this.compareTransportOptions( | |
| 94 | - connection.options.transport, | |
| 95 | - s.transport, | |
| 96 | - ), | |
| 87 | + s.id === id && this.compareTransportOptions(connection.options, s), | |
| 97 | 88 | ) |
| 98 | 89 | ) { |
| 99 | 90 | refresh = true; |
| @@ -124,33 +115,35 @@ | ||
| 124 | 115 | } |
| 125 | 116 | |
| 126 | 117 | private compareTransportOptions( |
| 127 | - a: TransportOptions, | |
| 128 | - b: TransportOptions, | |
| 118 | + a: InternalMcpOptions, | |
| 119 | + b: InternalMcpOptions, | |
| 129 | 120 | ): boolean { |
| 130 | 121 | if (a.type !== b.type) { |
| 131 | 122 | return false; |
| 132 | 123 | } |
| 133 | - if (a.type === "stdio" && b.type === "stdio") { | |
| 124 | + if ("command" in a && "command" in b) { | |
| 134 | 125 | return ( |
| 135 | 126 | a.command === b.command && |
| 136 | 127 | JSON.stringify(a.args) === JSON.stringify(b.args) && |
| 137 | - this.compareEnv(a, b) | |
| 128 | + this.compareEnv(a.env, b.env) | |
| 138 | 129 | ); |
| 139 | - } else if (a.type !== "stdio" && b.type !== "stdio") { | |
| 130 | + } else if ("url" in a && "url" in b) { | |
| 140 | 131 | return a.url === b.url; |
| 141 | 132 | } |
| 142 | 133 | return false; |
| 143 | 134 | } |
| 144 | 135 | |
| 145 | - private compareEnv(a: StdioOptions, b: StdioOptions): boolean { | |
| 146 | - const aEnv = a.env ?? {}; | |
| 147 | - const bEnv = b.env ?? {}; | |
| 148 | - const aKeys = Object.keys(aEnv); | |
| 149 | - const bKeys = Object.keys(bEnv); | |
| 136 | + private compareEnv( | |
| 137 | + aEnv: Record<string, string> | undefined, | |
| 138 | + bEnv: Record<string, string> | undefined, | |
| 139 | + ): boolean { | |
| 140 | + const a = aEnv ?? {}; | |
| 141 | + const b = bEnv ?? {}; | |
| 142 | + const aKeys = Object.keys(a); | |
| 143 | + const bKeys = Object.keys(b); | |
| 150 | 144 | |
| 151 | 145 | return ( |
| 152 | - aKeys.length === bKeys.length && | |
| 153 | - aKeys.every((key) => aEnv[key] === bEnv[key]) | |
| 146 | + aKeys.length === bKeys.length && aKeys.every((key) => a[key] === b[key]) | |
| 154 | 147 | ); |
| 155 | 148 | } |
| 156 | 149 | |
| @@ -204,8 +197,8 @@ | ||
| 204 | 197 | })); |
| 205 | 198 | } |
| 206 | 199 | |
| 207 | - setStatus(server: MCPServerStatus, status: MCPServerStatus["status"]) { | |
| 208 | - this.connections.get(server.id)!.status = status; | |
| 200 | + setStatus(serverId: string, status: MCPServerStatus["status"]) { | |
| 201 | + this.connections.get(serverId)!.status = status; | |
| 209 | 202 | } |
| 210 | 203 | |
| 211 | 204 | async getPrompt( |
modified core/context/mcp/MCPManagerSingleton.vitest.ts +7 −9
| @@ -1,11 +1,11 @@ | ||
| 1 | 1 | import { beforeEach, describe, expect, it, vi } from "vitest"; |
| 2 | -import { MCPOptions } from "../.."; | |
| 2 | +import { InternalMcpOptions } from "../.."; | |
| 3 | 3 | import MCPConnection from "./MCPConnection"; |
| 4 | 4 | import { MCPManagerSingleton } from "./MCPManagerSingleton"; |
| 5 | 5 | |
| 6 | 6 | // Create test versions with stubbed behavior |
| 7 | 7 | class TestMCPConnection extends MCPConnection { |
| 8 | - constructor(options: MCPOptions) { | |
| 8 | + constructor(options: InternalMcpOptions) { | |
| 9 | 9 | super(options); |
| 10 | 10 | |
| 11 | 11 | // Override with test implementations |
| @@ -28,14 +28,12 @@ | ||
| 28 | 28 | |
| 29 | 29 | describe("MCPManagerSingleton", () => { |
| 30 | 30 | let manager: MCPManagerSingleton; |
| 31 | - const testOptions: MCPOptions = { | |
| 31 | + const testOptions: InternalMcpOptions = { | |
| 32 | 32 | name: "test-mcp", |
| 33 | 33 | id: "test-id", |
| 34 | - transport: { | |
| 35 | - type: "stdio", | |
| 36 | - command: "test-command", | |
| 37 | - args: [], | |
| 38 | - }, | |
| 34 | + type: "stdio", | |
| 35 | + command: "test-command", | |
| 36 | + args: [], | |
| 39 | 37 | }; |
| 40 | 38 | |
| 41 | 39 | beforeEach(() => { |
| @@ -53,7 +51,7 @@ | ||
| 53 | 51 | // Override createConnection to use our TestMCPConnection |
| 54 | 52 | manager.createConnection = function ( |
| 55 | 53 | id: string, |
| 56 | - options: MCPOptions, | |
| 54 | + options: InternalMcpOptions, | |
| 57 | 55 | ): MCPConnection { |
| 58 | 56 | if (this.connections.has(id)) { |
| 59 | 57 | return this.connections.get(id)!; |
modified core/context/mcp/MCPOauth.ts +19 −27
| @@ -8,7 +8,7 @@ | ||
| 8 | 8 | OAuthTokens, |
| 9 | 9 | OAuthTokensSchema, |
| 10 | 10 | } from "@modelcontextprotocol/sdk/shared/auth.js"; |
| 11 | -import { IDE, MCPServerStatus, SSEOptions } from "../.."; | |
| 11 | +import { IDE } from "../.."; | |
| 12 | 12 | |
| 13 | 13 | import http from "http"; |
| 14 | 14 | import url from "url"; |
| @@ -16,14 +16,12 @@ | ||
| 16 | 16 | import { GlobalContext, GlobalContextType } from "../../util/GlobalContext"; |
| 17 | 17 | |
| 18 | 18 | // Use a Map to support concurrent authentications for different servers |
| 19 | -const authenticatingContexts = new Map< | |
| 20 | - string, | |
| 21 | - { | |
| 22 | - authenticatingServer: MCPServerStatus; | |
| 23 | - ide: IDE; | |
| 24 | - state?: string; | |
| 25 | - } | |
| 26 | ->(); | |
| 19 | +interface MCPOauthContext { | |
| 20 | + serverId: string; | |
| 21 | + ide: IDE; | |
| 22 | + state?: string; | |
| 23 | +} | |
| 24 | +const authenticatingContexts = new Map<string, MCPOauthContext>(); | |
| 27 | 25 | |
| 28 | 26 | // Map state parameters to server URLs for OAuth callback matching |
| 29 | 27 | const stateToServerUrl = new Map<string, string>(); |
| @@ -242,9 +240,8 @@ | ||
| 242 | 240 | * checks if the authentication is already done for the current server |
| 243 | 241 | * if not, starts the authentication process by opening a webpage url |
| 244 | 242 | */ |
| 245 | -export async function performAuth(mcpServer: MCPServerStatus, ide: IDE) { | |
| 246 | - const mcpServerUrl = (mcpServer.transport as SSEOptions).url; | |
| 247 | - const authProvider = new MCPConnectionOauthProvider(mcpServerUrl, ide); | |
| 243 | +export async function performAuth(serverId: string, url: string, ide: IDE) { | |
| 244 | + const authProvider = new MCPConnectionOauthProvider(url, ide); | |
| 248 | 245 | // Ensure redirect URL is ready before starting auth |
| 249 | 246 | await authProvider.ensureRedirectUrl(); |
| 250 | 247 | |
| @@ -252,22 +249,22 @@ | ||
| 252 | 249 | const state = uuidv4(); |
| 253 | 250 | |
| 254 | 251 | // Store context for this specific server with state |
| 255 | - authenticatingContexts.set(mcpServerUrl, { | |
| 256 | - authenticatingServer: mcpServer, | |
| 252 | + authenticatingContexts.set(url, { | |
| 253 | + serverId, | |
| 257 | 254 | ide, |
| 258 | 255 | state, |
| 259 | 256 | }); |
| 260 | 257 | |
| 261 | 258 | // Map state to server URL for callback matching |
| 262 | - stateToServerUrl.set(state, mcpServerUrl); | |
| 259 | + stateToServerUrl.set(state, url); | |
| 263 | 260 | |
| 264 | 261 | try { |
| 265 | 262 | return await auth(authProvider, { |
| 266 | - serverUrl: mcpServerUrl, | |
| 263 | + serverUrl: url, | |
| 267 | 264 | }); |
| 268 | 265 | } catch (error) { |
| 269 | 266 | // Clean up on error |
| 270 | - authenticatingContexts.delete(mcpServerUrl); | |
| 267 | + authenticatingContexts.delete(url); | |
| 271 | 268 | stateToServerUrl.delete(state); |
| 272 | 269 | throw error; |
| 273 | 270 | } |
| @@ -278,9 +275,7 @@ | ||
| 278 | 275 | */ |
| 279 | 276 | async function handleMCPOauthCode(authorizationCode: string, state?: string) { |
| 280 | 277 | let serverUrl: string | undefined; |
| 281 | - let context: | |
| 282 | - | { authenticatingServer: MCPServerStatus; ide: IDE; state?: string } | |
| 283 | - | undefined; | |
| 278 | + let context: MCPOauthContext | undefined; | |
| 284 | 279 | |
| 285 | 280 | if (state) { |
| 286 | 281 | // Use state parameter to find the correct server |
| @@ -301,7 +296,7 @@ | ||
| 301 | 296 | return; |
| 302 | 297 | } |
| 303 | 298 | |
| 304 | - const { ide, authenticatingServer } = context; | |
| 299 | + const { ide, serverId } = context; | |
| 305 | 300 | |
| 306 | 301 | try { |
| 307 | 302 | if (!serverUrl) { |
| @@ -331,9 +326,7 @@ | ||
| 331 | 326 | |
| 332 | 327 | if (authStatus === "AUTHORIZED") { |
| 333 | 328 | const { MCPManagerSingleton } = await import("./MCPManagerSingleton"); // put dynamic import to avoid cyclic imports |
| 334 | - await MCPManagerSingleton.getInstance().refreshConnection( | |
| 335 | - authenticatingServer.id, | |
| 336 | - ); | |
| 329 | + await MCPManagerSingleton.getInstance().refreshConnection(serverId); | |
| 337 | 330 | } |
| 338 | 331 | } catch (error) { |
| 339 | 332 | const errorMessage = error instanceof Error ? error.message : String(error); |
| @@ -350,8 +343,7 @@ | ||
| 350 | 343 | } |
| 351 | 344 | } |
| 352 | 345 | |
| 353 | -export function removeMCPAuth(mcpServer: MCPServerStatus, ide: IDE) { | |
| 354 | - const mcpServerUrl = (mcpServer.transport as SSEOptions).url; | |
| 355 | - const authProvider = new MCPConnectionOauthProvider(mcpServerUrl, ide); | |
| 346 | +export function removeMCPAuth(url: string, ide: IDE) { | |
| 347 | + const authProvider = new MCPConnectionOauthProvider(url, ide); | |
| 356 | 348 | authProvider.clear(); |
| 357 | 349 | } |
modified core/context/mcp/MCPOauth.vitest.ts +30 −63
| @@ -21,7 +21,8 @@ | ||
| 21 | 21 | describe("MCPOauth", () => { |
| 22 | 22 | let globalContextFilePath: string; |
| 23 | 23 | let mockIde: any; |
| 24 | - let mockMcpServer: any; | |
| 24 | + let mockMcpServerId: string; | |
| 25 | + let mockMcpServerUrl: string; | |
| 25 | 26 | |
| 26 | 27 | beforeEach(() => { |
| 27 | 28 | // file is present in the core/test directory |
| @@ -36,13 +37,8 @@ | ||
| 36 | 37 | getExternalUri: vi.fn((uri) => Promise.resolve(uri)), |
| 37 | 38 | }; |
| 38 | 39 | |
| 39 | - mockMcpServer = { | |
| 40 | - id: "test-server", | |
| 41 | - transport: { | |
| 42 | - type: "sse", | |
| 43 | - url: "https://test-server.com", | |
| 44 | - }, | |
| 45 | - }; | |
| 40 | + mockMcpServerId = "test-server"; | |
| 41 | + mockMcpServerUrl = "https://test-server.com"; | |
| 46 | 42 | |
| 47 | 43 | vi.clearAllMocks(); |
| 48 | 44 | }); |
| @@ -107,7 +103,11 @@ | ||
| 107 | 103 | const mockAuth = vi.mocked(auth); |
| 108 | 104 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 109 | 105 | |
| 110 | - const result = await performAuth(mockMcpServer, mockIde); | |
| 106 | + const result = await performAuth( | |
| 107 | + mockMcpServerId, | |
| 108 | + mockMcpServerUrl, | |
| 109 | + mockIde, | |
| 110 | + ); | |
| 111 | 111 | |
| 112 | 112 | expect(mockAuth).toHaveBeenCalledWith( |
| 113 | 113 | expect.any(Object), // MCPConnectionOauthProvider instance |
| @@ -142,7 +142,7 @@ | ||
| 142 | 142 | }, |
| 143 | 143 | }); |
| 144 | 144 | |
| 145 | - removeMCPAuth(mockMcpServer, mockIde); | |
| 145 | + removeMCPAuth(mockMcpServerUrl, mockIde); | |
| 146 | 146 | |
| 147 | 147 | const updatedStorage = globalContext.get("mcpOauthStorage"); |
| 148 | 148 | expect(updatedStorage).toEqual({ |
| @@ -166,7 +166,7 @@ | ||
| 166 | 166 | }, |
| 167 | 167 | }); |
| 168 | 168 | |
| 169 | - removeMCPAuth(mockMcpServer, mockIde); | |
| 169 | + removeMCPAuth(mockMcpServerUrl, mockIde); | |
| 170 | 170 | |
| 171 | 171 | const updatedStorage = globalContext.get("mcpOauthStorage"); |
| 172 | 172 | expect(updatedStorage).toEqual({ |
| @@ -193,7 +193,7 @@ | ||
| 193 | 193 | const mockAuth = vi.mocked(auth); |
| 194 | 194 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 195 | 195 | |
| 196 | - await performAuth(mockMcpServer, vscodeIde); | |
| 196 | + await performAuth(mockMcpServerId, mockMcpServerUrl, vscodeIde); | |
| 197 | 197 | |
| 198 | 198 | expect(vscodeIde.getExternalUri).toHaveBeenCalledWith( |
| 199 | 199 | "http://localhost:3000", |
| @@ -210,7 +210,11 @@ | ||
| 210 | 210 | const mockAuth = vi.mocked(auth); |
| 211 | 211 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 212 | 212 | |
| 213 | - await performAuth(mockMcpServer, ideWithoutExternalUri as any); | |
| 213 | + await performAuth( | |
| 214 | + mockMcpServerId, | |
| 215 | + mockMcpServerUrl, | |
| 216 | + ideWithoutExternalUri as any, | |
| 217 | + ); | |
| 214 | 218 | |
| 215 | 219 | // Should still work without getExternalUri |
| 216 | 220 | expect(mockAuth).toHaveBeenCalled(); |
| @@ -227,7 +231,7 @@ | ||
| 227 | 231 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 228 | 232 | |
| 229 | 233 | // Should not throw, should fallback to localhost |
| 230 | - await performAuth(mockMcpServer, errorIde); | |
| 234 | + await performAuth(mockMcpServerId, mockMcpServerUrl, errorIde); | |
| 231 | 235 | |
| 232 | 236 | expect(mockAuth).toHaveBeenCalled(); |
| 233 | 237 | }); |
| @@ -235,41 +239,14 @@ | ||
| 235 | 239 | |
| 236 | 240 | describe("concurrent authentication", () => { |
| 237 | 241 | test("should handle multiple concurrent auth flows", async () => { |
| 238 | - const server1 = { | |
| 239 | - id: "server-1", | |
| 240 | - transport: { type: "sse" as const, url: "https://server1.com" }, | |
| 241 | - status: "connected" as const, | |
| 242 | - errors: [], | |
| 243 | - infos: [], | |
| 244 | - isProtectedResource: false, | |
| 245 | - prompts: [], | |
| 246 | - tools: [], | |
| 247 | - resources: [], | |
| 248 | - resourceTemplates: [], | |
| 249 | - name: "server-1", | |
| 250 | - }; | |
| 251 | - const server2 = { | |
| 252 | - id: "server-2", | |
| 253 | - transport: { type: "sse" as const, url: "https://server2.com" }, | |
| 254 | - status: "connected" as const, | |
| 255 | - errors: [], | |
| 256 | - infos: [], | |
| 257 | - isProtectedResource: false, | |
| 258 | - prompts: [], | |
| 259 | - tools: [], | |
| 260 | - resources: [], | |
| 261 | - resourceTemplates: [], | |
| 262 | - name: "server-2", | |
| 263 | - }; | |
| 264 | - | |
| 265 | 242 | const { auth } = await import("@modelcontextprotocol/sdk/client/auth.js"); |
| 266 | 243 | const mockAuth = vi.mocked(auth); |
| 267 | 244 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 268 | 245 | |
| 269 | 246 | // Start two auth flows concurrently |
| 270 | 247 | const [result1, result2] = await Promise.all([ |
| 271 | - performAuth(server1, mockIde), | |
| 272 | - performAuth(server2, mockIde), | |
| 248 | + performAuth("server-1-id", "https://server1.com", mockIde), | |
| 249 | + performAuth("server-2-id", "https://server2.com", mockIde), | |
| 273 | 250 | ]); |
| 274 | 251 | |
| 275 | 252 | expect(result1).toBe("AUTHORIZED"); |
| @@ -285,15 +262,15 @@ | ||
| 285 | 262 | |
| 286 | 263 | // First successful call to set up the context |
| 287 | 264 | mockAuth.mockResolvedValueOnce("AUTHORIZED"); |
| 288 | - await performAuth(mockMcpServer, mockIde); | |
| 265 | + await performAuth(mockMcpServerId, mockMcpServerUrl, mockIde); | |
| 289 | 266 | |
| 290 | 267 | // Reset mock for the failure test |
| 291 | 268 | mockAuth.mockRejectedValueOnce(new Error("Auth failed")); |
| 292 | 269 | |
| 293 | 270 | // Second call that should fail and clean up |
| 294 | - await expect(performAuth(mockMcpServer, mockIde)).rejects.toThrow( | |
| 295 | - "Auth failed", | |
| 296 | - ); | |
| 271 | + await expect( | |
| 272 | + performAuth(mockMcpServerId, mockMcpServerUrl, mockIde), | |
| 273 | + ).rejects.toThrow("Auth failed"); | |
| 297 | 274 | |
| 298 | 275 | // Verify auth was called twice |
| 299 | 276 | expect(mockAuth).toHaveBeenCalledTimes(2); |
| @@ -301,30 +278,20 @@ | ||
| 301 | 278 | // The context cleanup happens internally in performAuth's catch block |
| 302 | 279 | // We can verify it indirectly by checking that a subsequent auth call works |
| 303 | 280 | mockAuth.mockResolvedValueOnce("AUTHORIZED"); |
| 304 | - const result = await performAuth(mockMcpServer, mockIde); | |
| 281 | + const result = await performAuth( | |
| 282 | + mockMcpServerId, | |
| 283 | + mockMcpServerUrl, | |
| 284 | + mockIde, | |
| 285 | + ); | |
| 305 | 286 | expect(result).toBe("AUTHORIZED"); |
| 306 | 287 | }); |
| 307 | 288 | |
| 308 | 289 | test("should handle missing server URL", async () => { |
| 309 | - const invalidServer = { | |
| 310 | - id: "invalid", | |
| 311 | - transport: { type: "sse" as const, url: "" }, | |
| 312 | - status: "connected" as const, | |
| 313 | - errors: [], | |
| 314 | - infos: [], | |
| 315 | - isProtectedResource: false, | |
| 316 | - prompts: [], | |
| 317 | - tools: [], | |
| 318 | - resources: [], | |
| 319 | - resourceTemplates: [], | |
| 320 | - name: "invalid", | |
| 321 | - }; | |
| 322 | - | |
| 323 | 290 | const { auth } = await import("@modelcontextprotocol/sdk/client/auth.js"); |
| 324 | 291 | const mockAuth = vi.mocked(auth); |
| 325 | 292 | mockAuth.mockResolvedValue("AUTHORIZED"); |
| 326 | 293 | |
| 327 | - await performAuth(invalidServer, mockIde); | |
| 294 | + await performAuth("invalid-id", "", mockIde); | |
| 328 | 295 | |
| 329 | 296 | // Should still attempt auth with empty URL |
| 330 | 297 | expect(mockAuth).toHaveBeenCalled(); |
added core/context/mcp/json/loadJsonMcpConfigs.ts +204 −0
| @@ -0,0 +1,204 @@ | ||
| 1 | +import { | |
| 2 | + claudeCodeLikeConfigFileSchema, | |
| 3 | + claudeDesktopLikeConfigFileSchema, | |
| 4 | + ConfigValidationError, | |
| 5 | + convertJsonMcpConfigToYamlMcpConfig, | |
| 6 | + McpJsonConfig, | |
| 7 | + mcpServersJsonSchema, | |
| 8 | + RequestOptions, | |
| 9 | +} from "@continuedev/config-yaml"; | |
| 10 | +import * as JSONC from "comment-json"; | |
| 11 | +import ignore from "ignore"; | |
| 12 | +import { IDE, InternalMcpOptions } from "../../.."; | |
| 13 | +import { convertYamlMcpConfigToInternalMcpOptions } from "../../../config/yaml/yamlToContinueConfig"; | |
| 14 | +import { | |
| 15 | + DEFAULT_IGNORE_DIRS, | |
| 16 | + DEFAULT_IGNORE_FILETYPES, | |
| 17 | +} from "../../../indexing/ignore"; | |
| 18 | +import { walkDir } from "../../../indexing/walkDir"; | |
| 19 | +import { deduplicateArray } from "../../../util"; | |
| 20 | +import { getGlobalFolderWithName } from "../../../util/paths"; | |
| 21 | +import { localPathToUri } from "../../../util/pathToUri"; | |
| 22 | +import { getUriPathBasename, joinPathsToUri } from "../../../util/uri"; | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * Loads MCP configs from JSON files in ~/.continue/mcpServers and workspace .continue/mcpServers | |
| 26 | + */ | |
| 27 | +export async function loadJsonMcpConfigs( | |
| 28 | + ide: IDE, | |
| 29 | + includeGlobal: boolean, | |
| 30 | + globalRequestOptions: RequestOptions | undefined = undefined, | |
| 31 | +): Promise<{ | |
| 32 | + mcpServers: InternalMcpOptions[]; | |
| 33 | + errors: ConfigValidationError[]; | |
| 34 | +}> { | |
| 35 | + const errors: ConfigValidationError[] = []; | |
| 36 | + | |
| 37 | + // Get dirs | |
| 38 | + const workspaceDirs = await ide.getWorkspaceDirs(); | |
| 39 | + const mcpDirs = workspaceDirs.map((dir) => | |
| 40 | + joinPathsToUri(dir, ".continue", "mcpServers"), | |
| 41 | + ); | |
| 42 | + if (includeGlobal) { | |
| 43 | + mcpDirs.push(localPathToUri(getGlobalFolderWithName("mcpServers"))); | |
| 44 | + } | |
| 45 | + | |
| 46 | + // Get json files and their contents | |
| 47 | + const overrideDefaultIgnores = ignore() | |
| 48 | + .add( | |
| 49 | + DEFAULT_IGNORE_FILETYPES.filter( | |
| 50 | + (val) => !["config.json", "settings.json"].includes(val), | |
| 51 | + ), | |
| 52 | + ) | |
| 53 | + .add(DEFAULT_IGNORE_DIRS); | |
| 54 | + | |
| 55 | + const jsonFiles: { uri: string; content: string }[] = []; | |
| 56 | + | |
| 57 | + await Promise.all( | |
| 58 | + mcpDirs.map(async (dir) => { | |
| 59 | + const exists = await ide.fileExists(dir); | |
| 60 | + if (!exists) { | |
| 61 | + return; | |
| 62 | + } | |
| 63 | + try { | |
| 64 | + const uris = await walkDir(dir, ide, { | |
| 65 | + overrideDefaultIgnores, | |
| 66 | + source: "get mcp json files", | |
| 67 | + }); | |
| 68 | + const jsonUris = uris.filter((uri) => uri.endsWith(".json")); | |
| 69 | + await Promise.all( | |
| 70 | + jsonUris.map(async (uri) => { | |
| 71 | + try { | |
| 72 | + const content = await ide.readFile(uri); | |
| 73 | + jsonFiles.push({ uri, content }); | |
| 74 | + } catch (e) { | |
| 75 | + errors.push({ | |
| 76 | + fatal: false, | |
| 77 | + message: `Failed to read MCP server JSON file at ${uri}: ${e instanceof Error ? e.message : String(e)}`, | |
| 78 | + }); | |
| 79 | + } | |
| 80 | + }), | |
| 81 | + ); | |
| 82 | + } catch (e) { | |
| 83 | + errors.push({ | |
| 84 | + fatal: false, | |
| 85 | + message: `Failed to check for MCP JSON files in ${dir}: ${e instanceof Error ? e.message : String(e)}`, | |
| 86 | + }); | |
| 87 | + } | |
| 88 | + }), | |
| 89 | + ); | |
| 90 | + | |
| 91 | + const validJsonConfigs: { | |
| 92 | + name: string; | |
| 93 | + mcpJson: McpJsonConfig; | |
| 94 | + uri: string; | |
| 95 | + }[] = []; | |
| 96 | + for (const { content, uri } of jsonFiles) { | |
| 97 | + try { | |
| 98 | + const json = JSONC.parse(content); | |
| 99 | + // Try parsing as a file with mcpServers and multiple servers (claude code/desktop-esque format) | |
| 100 | + const claudeCodeFileParsed = | |
| 101 | + claudeCodeLikeConfigFileSchema.safeParse(json); | |
| 102 | + if (claudeCodeFileParsed.success) { | |
| 103 | + if (claudeCodeFileParsed.data.mcpServers) { | |
| 104 | + validJsonConfigs.push( | |
| 105 | + ...Object.entries(claudeCodeFileParsed.data.mcpServers).map( | |
| 106 | + ([name, mcpJson]) => ({ | |
| 107 | + name, | |
| 108 | + mcpJson, | |
| 109 | + uri, | |
| 110 | + }), | |
| 111 | + ), | |
| 112 | + ); | |
| 113 | + } | |
| 114 | + const projectServers = Object.values( | |
| 115 | + claudeCodeFileParsed.data.projects, | |
| 116 | + ).map((v) => v.mcpServers); | |
| 117 | + for (const mcpServers of projectServers) { | |
| 118 | + if (mcpServers) { | |
| 119 | + validJsonConfigs.push( | |
| 120 | + ...Object.entries(mcpServers).map(([name, mcpJson]) => ({ | |
| 121 | + name, | |
| 122 | + mcpJson, | |
| 123 | + uri, | |
| 124 | + })), | |
| 125 | + ); | |
| 126 | + } | |
| 127 | + } | |
| 128 | + } else { | |
| 129 | + const claudeDesktopFileParsed = | |
| 130 | + claudeDesktopLikeConfigFileSchema.safeParse(json); | |
| 131 | + if (claudeDesktopFileParsed.success) { | |
| 132 | + validJsonConfigs.push( | |
| 133 | + ...Object.entries(claudeDesktopFileParsed.data.mcpServers).map( | |
| 134 | + ([name, mcpJson]) => ({ | |
| 135 | + name, | |
| 136 | + mcpJson, | |
| 137 | + uri, | |
| 138 | + }), | |
| 139 | + ), | |
| 140 | + ); | |
| 141 | + } else { | |
| 142 | + // Try parsing as single JSON file | |
| 143 | + const singleConfigParsed = mcpServersJsonSchema.safeParse(json); | |
| 144 | + if (singleConfigParsed.success) { | |
| 145 | + validJsonConfigs.push({ | |
| 146 | + mcpJson: singleConfigParsed.data, | |
| 147 | + name: getUriPathBasename(uri).replace(".json", ""), | |
| 148 | + uri, | |
| 149 | + }); | |
| 150 | + } else { | |
| 151 | + errors.push({ | |
| 152 | + fatal: false, | |
| 153 | + message: `MCP JSON file at ${uri} doesn't match a supported MCP JSON configuration format`, | |
| 154 | + }); | |
| 155 | + } | |
| 156 | + } | |
| 157 | + } | |
| 158 | + } catch (e) { | |
| 159 | + errors.push({ | |
| 160 | + fatal: false, | |
| 161 | + message: `Error parsing MCP JSON file at ${uri}: ${e instanceof Error ? e.message : String(e)}`, | |
| 162 | + }); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + | |
| 166 | + // De-duplicate | |
| 167 | + const deduplicatedJsonConfigs = deduplicateArray( | |
| 168 | + validJsonConfigs, | |
| 169 | + (a, b) => a.name === b.name, | |
| 170 | + ); | |
| 171 | + | |
| 172 | + // Two levels of conversion for now. | |
| 173 | + const yamlConfigs = deduplicatedJsonConfigs.map((c) => { | |
| 174 | + const { warnings, yamlConfig } = convertJsonMcpConfigToYamlMcpConfig( | |
| 175 | + c.name, | |
| 176 | + c.mcpJson, | |
| 177 | + ); | |
| 178 | + return { | |
| 179 | + warnings, | |
| 180 | + yamlConfig: { | |
| 181 | + ...yamlConfig, | |
| 182 | + sourceFile: c.uri, | |
| 183 | + }, | |
| 184 | + }; | |
| 185 | + }); | |
| 186 | + | |
| 187 | + const mcpServers = yamlConfigs.map((c) => { | |
| 188 | + errors.push( | |
| 189 | + ...c.warnings.map((warning) => ({ | |
| 190 | + fatal: false, | |
| 191 | + message: warning, | |
| 192 | + })), | |
| 193 | + ); | |
| 194 | + return convertYamlMcpConfigToInternalMcpOptions( | |
| 195 | + c.yamlConfig, | |
| 196 | + globalRequestOptions, | |
| 197 | + ); | |
| 198 | + }); | |
| 199 | + // Parse and convert files | |
| 200 | + return { | |
| 201 | + mcpServers, | |
| 202 | + errors, | |
| 203 | + }; | |
| 204 | +} |
modified core/core.ts +84 −71
| @@ -8,7 +8,6 @@ | ||
| 8 | 8 | prevFilepaths, |
| 9 | 9 | } from "./autocomplete/util/openedFilesLruCache"; |
| 10 | 10 | import { ConfigHandler } from "./config/ConfigHandler"; |
| 11 | -import { SYSTEM_PROMPT_DOT_FILE } from "./config/getWorkspaceContinueRuleDotFiles"; | |
| 12 | 11 | import { addModel, deleteModel } from "./config/util"; |
| 13 | 12 | import { getAuthUrlForTokenPage } from "./control-plane/auth/index"; |
| 14 | 13 | import { getControlPlaneEnv } from "./control-plane/env"; |
| @@ -49,11 +48,15 @@ | ||
| 49 | 48 | type IDE, |
| 50 | 49 | } from "."; |
| 51 | 50 | |
| 52 | -import { BLOCK_TYPES, ConfigYaml } from "@continuedev/config-yaml"; | |
| 51 | +import { ConfigYaml } from "@continuedev/config-yaml"; | |
| 53 | 52 | import { getDiffFn, GitDiffCache } from "./autocomplete/snippets/gitDiffCache"; |
| 54 | 53 | import { stringifyMcpPrompt } from "./commands/slash/mcpSlashCommand"; |
| 55 | 54 | import { createNewAssistantFile } from "./config/createNewAssistantFile"; |
| 56 | -import { isLocalDefinitionFile } from "./config/loadLocalAssistants"; | |
| 55 | +import { | |
| 56 | + isColocatedRulesFile, | |
| 57 | + isContinueAgentConfigFile, | |
| 58 | + isContinueConfigRelatedUri, | |
| 59 | +} from "./config/loadLocalAssistants"; | |
| 57 | 60 | import { CodebaseRulesCache } from "./config/markdown/loadCodebaseRules"; |
| 58 | 61 | import { |
| 59 | 62 | setupLocalConfig, |
| @@ -69,7 +72,6 @@ | ||
| 69 | 72 | import { shouldIgnore } from "./indexing/shouldIgnore"; |
| 70 | 73 | import { walkDirCache } from "./indexing/walkDir"; |
| 71 | 74 | import { LLMLogger } from "./llm/logger"; |
| 72 | -import { RULES_MARKDOWN_FILENAME } from "./llm/rules/constants"; | |
| 73 | 75 | import { llmStreamChat } from "./llm/streamChat"; |
| 74 | 76 | import { BeforeAfterDiff } from "./nextEdit/context/diffFormatting"; |
| 75 | 77 | import { processSmallEdit } from "./nextEdit/context/processSmallEdit"; |
| @@ -80,17 +82,6 @@ | ||
| 80 | 82 | import type { IMessenger, Message } from "./protocol/messenger"; |
| 81 | 83 | import { shareSession } from "./util/historyUtils"; |
| 82 | 84 | import { Logger } from "./util/Logger.js"; |
| 83 | -import { getUriPathBasename } from "./util/uri"; | |
| 84 | - | |
| 85 | -const hasRulesFiles = (uris: string[]): boolean => { | |
| 86 | - for (const uri of uris) { | |
| 87 | - const filename = getUriPathBasename(uri); | |
| 88 | - if (filename === RULES_MARKDOWN_FILENAME) { | |
| 89 | - return true; | |
| 90 | - } | |
| 91 | - } | |
| 92 | - return false; | |
| 93 | -}; | |
| 94 | 85 | |
| 95 | 86 | export class Core { |
| 96 | 87 | configHandler: ConfigHandler; |
| @@ -522,15 +513,26 @@ | ||
| 522 | 513 | }); |
| 523 | 514 | on("mcp/startAuthentication", async (msg) => { |
| 524 | 515 | await new Promise((resolve) => setTimeout(resolve, 5000)); |
| 525 | - MCPManagerSingleton.getInstance().setStatus(msg.data, "authenticating"); | |
| 526 | - const status = await performAuth(msg.data, this.ide); | |
| 516 | + MCPManagerSingleton.getInstance().setStatus( | |
| 517 | + msg.data.serverId, | |
| 518 | + "authenticating", | |
| 519 | + ); | |
| 520 | + const status = await performAuth( | |
| 521 | + msg.data.serverId, | |
| 522 | + msg.data.serverUrl, | |
| 523 | + this.ide, | |
| 524 | + ); | |
| 527 | 525 | if (status === "AUTHORIZED") { |
| 528 | - await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); | |
| 526 | + await MCPManagerSingleton.getInstance().refreshConnection( | |
| 527 | + msg.data.serverId, | |
| 528 | + ); | |
| 529 | 529 | } |
| 530 | 530 | }); |
| 531 | 531 | on("mcp/removeAuthentication", async (msg) => { |
| 532 | - removeMCPAuth(msg.data, this.ide); | |
| 533 | - await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id); | |
| 532 | + removeMCPAuth(msg.data.serverUrl, this.ide); | |
| 533 | + await MCPManagerSingleton.getInstance().refreshConnection( | |
| 534 | + msg.data.serverId, | |
| 535 | + ); | |
| 534 | 536 | }); |
| 535 | 537 | |
| 536 | 538 | // Context providers |
| @@ -864,40 +866,65 @@ | ||
| 864 | 866 | }; |
| 865 | 867 | |
| 866 | 868 | on("files/created", async ({ data }) => { |
| 867 | - if (data?.uris?.length) { | |
| 868 | - walkDirCache.invalidate(); | |
| 869 | - void refreshIfNotIgnored(data.uris); | |
| 870 | - | |
| 871 | - if (hasRulesFiles(data.uris)) { | |
| 872 | - const rulesCache = CodebaseRulesCache.getInstance(); | |
| 873 | - await Promise.all( | |
| 874 | - data.uris.map((uri) => rulesCache.update(this.ide, uri)), | |
| 875 | - ); | |
| 876 | - await this.configHandler.reloadConfig("Rules file created"); | |
| 877 | - } | |
| 878 | - // If it's a local assistant being created, we want to reload all assistants so it shows up in the list | |
| 879 | - let localAssistantCreated = false; | |
| 880 | - for (const uri of data.uris) { | |
| 881 | - if (isLocalDefinitionFile(uri)) { | |
| 882 | - localAssistantCreated = true; | |
| 883 | - } | |
| 884 | - } | |
| 885 | - if (localAssistantCreated) { | |
| 886 | - await this.configHandler.refreshAll("Local assistant file created"); | |
| 887 | - } | |
| 869 | + if (!data?.uris?.length) { | |
| 870 | + return; | |
| 871 | + } | |
| 872 | + | |
| 873 | + walkDirCache.invalidate(); | |
| 874 | + void refreshIfNotIgnored(data.uris); | |
| 875 | + | |
| 876 | + const colocatedRulesUris = data.uris.filter(isColocatedRulesFile); | |
| 877 | + const nonColocatedRuleUris = data.uris.filter( | |
| 878 | + (uri) => !isColocatedRulesFile(uri), | |
| 879 | + ); | |
| 880 | + if (colocatedRulesUris) { | |
| 881 | + const rulesCache = CodebaseRulesCache.getInstance(); | |
| 882 | + void Promise.all( | |
| 883 | + colocatedRulesUris.map((uri) => rulesCache.update(this.ide, uri)), | |
| 884 | + ).then(() => { | |
| 885 | + void this.configHandler.reloadConfig("Codebase rule file created"); | |
| 886 | + }); | |
| 887 | + } | |
| 888 | + | |
| 889 | + // If it's a local agent being created, we want to reload all agent so it shows up in the list | |
| 890 | + if (nonColocatedRuleUris.some(isContinueAgentConfigFile)) { | |
| 891 | + await this.configHandler.refreshAll("Local assistant file created"); | |
| 892 | + } else if (nonColocatedRuleUris.some(isContinueConfigRelatedUri)) { | |
| 893 | + await this.configHandler.reloadConfig( | |
| 894 | + ".continue config-related file created", | |
| 895 | + ); | |
| 888 | 896 | } |
| 889 | 897 | }); |
| 890 | 898 | |
| 891 | 899 | on("files/deleted", async ({ data }) => { |
| 892 | - if (data?.uris?.length) { | |
| 893 | - walkDirCache.invalidate(); | |
| 894 | - void refreshIfNotIgnored(data.uris); | |
| 895 | - | |
| 896 | - if (hasRulesFiles(data.uris)) { | |
| 897 | - const rulesCache = CodebaseRulesCache.getInstance(); | |
| 898 | - data.uris.forEach((uri) => rulesCache.remove(uri)); | |
| 899 | - await this.configHandler.reloadConfig("Codebase rule file deleted"); | |
| 900 | - } | |
| 900 | + if (!data?.uris?.length) { | |
| 901 | + return; | |
| 902 | + } | |
| 903 | + | |
| 904 | + walkDirCache.invalidate(); | |
| 905 | + void refreshIfNotIgnored(data.uris); | |
| 906 | + | |
| 907 | + const colocatedRulesUris = data.uris.filter(isColocatedRulesFile); | |
| 908 | + const nonColocatedRuleUris = data.uris.filter( | |
| 909 | + (uri) => !isColocatedRulesFile(uri), | |
| 910 | + ); | |
| 911 | + | |
| 912 | + if (colocatedRulesUris) { | |
| 913 | + const rulesCache = CodebaseRulesCache.getInstance(); | |
| 914 | + void Promise.all( | |
| 915 | + colocatedRulesUris.map((uri) => rulesCache.remove(uri)), | |
| 916 | + ).then(() => { | |
| 917 | + void this.configHandler.reloadConfig("Codebase rule file deleted"); | |
| 918 | + }); | |
| 919 | + } | |
| 920 | + | |
| 921 | + // If it's a local agent being deleted, we want to reload all agent so it disappears from the list | |
| 922 | + if (nonColocatedRuleUris.some(isContinueAgentConfigFile)) { | |
| 923 | + await this.configHandler.refreshAll("Local assistant file deleted"); | |
| 924 | + } else if (nonColocatedRuleUris.some(isContinueConfigRelatedUri)) { | |
| 925 | + await this.configHandler.reloadConfig( | |
| 926 | + ".continue config-related file deleted", | |
| 927 | + ); | |
| 901 | 928 | } |
| 902 | 929 | }); |
| 903 | 930 | |
| @@ -1226,10 +1253,9 @@ | ||
| 1226 | 1253 | const diffCache = GitDiffCache.getInstance(getDiffFn(this.ide)); |
| 1227 | 1254 | diffCache.invalidate(); |
| 1228 | 1255 | walkDirCache.invalidate(); // safe approach for now - TODO - only invalidate on relevant changes |
| 1256 | + const currentProfileUri = | |
| 1257 | + this.configHandler.currentProfile?.profileDescription.uri ?? ""; | |
| 1229 | 1258 | for (const uri of data.uris) { |
| 1230 | - const currentProfileUri = | |
| 1231 | - this.configHandler.currentProfile?.profileDescription.uri ?? ""; | |
| 1232 | - | |
| 1233 | 1259 | if (URI.equal(uri, currentProfileUri)) { |
| 1234 | 1260 | // Trigger a toast notification to provide UI feedback that config has been updated |
| 1235 | 1261 | const showToast = |
| @@ -1249,24 +1275,7 @@ | ||
| 1249 | 1275 | ); |
| 1250 | 1276 | continue; |
| 1251 | 1277 | } |
| 1252 | - | |
| 1253 | - if ( | |
| 1254 | - uri.endsWith(".continuerc.json") || | |
| 1255 | - uri.endsWith(".prompt") || | |
| 1256 | - uri.endsWith("AGENTS.md") || | |
| 1257 | - uri.endsWith("AGENT.md") || | |
| 1258 | - uri.endsWith("CLAUDE.md") || | |
| 1259 | - uri.endsWith(SYSTEM_PROMPT_DOT_FILE) || | |
| 1260 | - (uri.includes(".continue") && | |
| 1261 | - (uri.endsWith(".yaml") || uri.endsWith("yml"))) || | |
| 1262 | - BLOCK_TYPES.some((blockType) => | |
| 1263 | - uri.includes(`.continue/${blockType}`), | |
| 1264 | - ) | |
| 1265 | - ) { | |
| 1266 | - await this.configHandler.reloadConfig( | |
| 1267 | - "Config-related file updated: continuerc, prompt, local block, etc", | |
| 1268 | - ); | |
| 1269 | - } else if (uri.endsWith(RULES_MARKDOWN_FILENAME)) { | |
| 1278 | + if (isColocatedRulesFile(uri)) { | |
| 1270 | 1279 | try { |
| 1271 | 1280 | const codebaseRulesCache = CodebaseRulesCache.getInstance(); |
| 1272 | 1281 | void codebaseRulesCache.update(this.ide, uri).then(() => { |
| @@ -1275,6 +1284,10 @@ | ||
| 1275 | 1284 | } catch (e) { |
| 1276 | 1285 | Logger.error(`Failed to update codebase rule: ${e}`); |
| 1277 | 1286 | } |
| 1287 | + } else if (isContinueConfigRelatedUri(uri)) { | |
| 1288 | + await this.configHandler.reloadConfig( | |
| 1289 | + "Local config-related file updated", | |
| 1290 | + ); | |
| 1278 | 1291 | } else if ( |
| 1279 | 1292 | uri.endsWith(".continueignore") || |
| 1280 | 1293 | uri.endsWith(".gitignore") |
modified core/index.d.ts +40 −13
| @@ -1246,7 +1246,6 @@ | ||
| 1246 | 1246 | args: string[]; |
| 1247 | 1247 | env?: Record<string, string>; |
| 1248 | 1248 | cwd?: string; |
| 1249 | - requestOptions?: RequestOptions; | |
| 1250 | 1249 | } |
| 1251 | 1250 | |
| 1252 | 1251 | export interface WebSocketOptions { |
| @@ -1273,15 +1272,6 @@ | ||
| 1273 | 1272 | | SSEOptions |
| 1274 | 1273 | | StreamableHTTPOptions; |
| 1275 | 1274 | |
| 1276 | -export interface MCPOptions { | |
| 1277 | - name: string; | |
| 1278 | - id: string; | |
| 1279 | - transport: TransportOptions; | |
| 1280 | - faviconUrl?: string; | |
| 1281 | - timeout?: number; | |
| 1282 | - requestOptions?: RequestOptions; | |
| 1283 | -} | |
| 1284 | - | |
| 1285 | 1275 | export type MCPConnectionStatus = |
| 1286 | 1276 | | "connecting" |
| 1287 | 1277 | | "connected" |
| @@ -1329,18 +1319,55 @@ | ||
| 1329 | 1319 | }; |
| 1330 | 1320 | } |
| 1331 | 1321 | |
| 1332 | -export interface MCPServerStatus extends MCPOptions { | |
| 1322 | +type BaseInternalMCPOptions = { | |
| 1323 | + id: string; | |
| 1324 | + name: string; | |
| 1325 | + faviconUrl?: string; | |
| 1326 | + timeout?: number; | |
| 1327 | + requestOptions?: RequestOptions; | |
| 1328 | + sourceFile?: string; | |
| 1329 | +}; | |
| 1330 | + | |
| 1331 | +export type InternalStdioMcpOptions = BaseInternalMCPOptions & { | |
| 1332 | + type?: "stdio"; | |
| 1333 | + command: string; | |
| 1334 | + args?: string[]; | |
| 1335 | + env?: Record<string, string>; | |
| 1336 | + cwd?: string; | |
| 1337 | +}; | |
| 1338 | + | |
| 1339 | +export type InternalStreamableHttpMcpOptions = BaseInternalMCPOptions & { | |
| 1340 | + type?: "streamable-http"; | |
| 1341 | + url: string; | |
| 1342 | +}; | |
| 1343 | + | |
| 1344 | +export type InternalSseMcpOptions = BaseInternalMCPOptions & { | |
| 1345 | + type?: "sse"; | |
| 1346 | + url: string; | |
| 1347 | +}; | |
| 1348 | + | |
| 1349 | +export type InternalWebsocketMcpOptions = BaseInternalMCPOptions & { | |
| 1350 | + type: "websocket"; // websocket requires explicit type | |
| 1351 | + url: string; | |
| 1352 | +}; | |
| 1353 | + | |
| 1354 | +export type InternalMcpOptions = | |
| 1355 | + | InternalStdioMcpOptions | |
| 1356 | + | InternalStreamableHttpMcpOptions | |
| 1357 | + | InternalSseMcpOptions | |
| 1358 | + | InternalWebsocketMcpOptions; | |
| 1359 | + | |
| 1360 | +export type MCPServerStatus = InternalMcpOptions & { | |
| 1333 | 1361 | status: MCPConnectionStatus; |
| 1334 | 1362 | errors: string[]; |
| 1335 | 1363 | infos: string[]; |
| 1336 | 1364 | isProtectedResource: boolean; |
| 1337 | - | |
| 1338 | 1365 | prompts: MCPPrompt[]; |
| 1339 | 1366 | tools: MCPTool[]; |
| 1340 | 1367 | resources: MCPResource[]; |
| 1341 | 1368 | resourceTemplates: MCPResourceTemplate[]; |
| 1342 | 1369 | sourceFile?: string; |
| 1343 | -} | |
| 1370 | +}; | |
| 1344 | 1371 | |
| 1345 | 1372 | export interface ContinueUIConfig { |
| 1346 | 1373 | codeBlockToolbarPosition?: "top" | "bottom"; |
modified core/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified core/protocol/core.ts +15 −5
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | import { GlobalContextModelSelections } from "../util/GlobalContext"; |
| 15 | 15 | |
| 16 | 16 | import { |
| 17 | + BaseSessionMetadata, | |
| 17 | 18 | BrowserSerializedContinueConfig, |
| 18 | 19 | ChatMessage, |
| 19 | 20 | CompiledMessagesResult, |
| @@ -27,7 +28,6 @@ | ||
| 27 | 28 | FileSymbolMap, |
| 28 | 29 | IdeSettings, |
| 29 | 30 | LLMFullCompletionOptions, |
| 30 | - MCPServerStatus, | |
| 31 | 31 | MessageOption, |
| 32 | 32 | ModelDescription, |
| 33 | 33 | PromptLog, |
| @@ -35,7 +35,6 @@ | ||
| 35 | 35 | RangeInFileWithNextEditInfo, |
| 36 | 36 | SerializedContinueConfig, |
| 37 | 37 | Session, |
| 38 | - BaseSessionMetadata, | |
| 39 | 38 | SiteIndexingConfig, |
| 40 | 39 | SlashCommandDescWithSource, |
| 41 | 40 | StreamDiffLinesPayload, |
| @@ -161,9 +160,20 @@ | ||
| 161 | 160 | description: string | undefined; |
| 162 | 161 | }, |
| 163 | 162 | ]; |
| 164 | - "mcp/startAuthentication": [MCPServerStatus, void]; | |
| 165 | - "mcp/removeAuthentication": [MCPServerStatus, void]; | |
| 166 | - | |
| 163 | + "mcp/startAuthentication": [ | |
| 164 | + { | |
| 165 | + serverId: string; | |
| 166 | + serverUrl: string; | |
| 167 | + }, | |
| 168 | + void, | |
| 169 | + ]; | |
| 170 | + "mcp/removeAuthentication": [ | |
| 171 | + { | |
| 172 | + serverId: string; | |
| 173 | + serverUrl: string; | |
| 174 | + }, | |
| 175 | + void, | |
| 176 | + ]; | |
| 167 | 177 | "context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap]; |
| 168 | 178 | "context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]]; |
| 169 | 179 | "autocomplete/complete": [AutocompleteInput, string[]]; |
modified core/tools/mcpToolName.vitest.ts +2 −4
| @@ -12,10 +12,8 @@ | ||
| 12 | 12 | resourceTemplates: [], |
| 13 | 13 | status: "connected", |
| 14 | 14 | id: "", |
| 15 | - transport: { | |
| 16 | - type: "sse", | |
| 17 | - url: "", | |
| 18 | - }, | |
| 15 | + type: "sse", | |
| 16 | + url: "", | |
| 19 | 17 | isProtectedResource: false, |
| 20 | 18 | }); |
| 21 | 19 |
modified docs/reference.mdx +1 −1
| @@ -297,8 +297,8 @@ | ||
| 297 | 297 | - `args`: An optional array of arguments for the command. |
| 298 | 298 | - `env`: An optional map of environment variables for the server process. |
| 299 | 299 | - `cwd`: An optional working directory to run the command in. Can be absolute or relative path. |
| 300 | -- `connectionTimeout`: An optional connection timeout number to the server in milliseconds. | |
| 301 | 300 | - `requestOptions`: Optional request options for `sse` and `streamable-http` servers. Same format as [model requestOptions](#models). |
| 301 | +- `connectionTimeout`: Optional timeout for _initial_ connection to MCP server | |
| 302 | 302 | |
| 303 | 303 | **Example:** |
| 304 | 304 |
modified extensions/cli/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified extensions/cli/src/services/MCPService.ts +96 −67
| @@ -3,7 +3,11 @@ | ||
| 3 | 3 | import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"; |
| 4 | 4 | import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"; |
| 5 | 5 | import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"; |
| 6 | -import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js"; | |
| 6 | +import { | |
| 7 | + HttpMcpServer, | |
| 8 | + SseMcpServer, | |
| 9 | + StdioMcpServer, | |
| 10 | +} from "node_modules/@continuedev/config-yaml/dist/schemas/mcp/index.js"; | |
| 7 | 11 | |
| 8 | 12 | import { getErrorString } from "../util/error.js"; |
| 9 | 13 | import { logger } from "../util/logger.js"; |
| @@ -217,19 +221,7 @@ | ||
| 217 | 221 | this.updateState(); |
| 218 | 222 | |
| 219 | 223 | try { |
| 220 | - const client = new Client( | |
| 221 | - { name: "continue-cli-client", version: "1.0.0" }, | |
| 222 | - { capabilities: {} }, | |
| 223 | - ); | |
| 224 | - | |
| 225 | - const transport = await this.constructTransport(serverConfig); | |
| 226 | - | |
| 227 | - logger.debug("Connecting to MCP server", { | |
| 228 | - name: serverName, | |
| 229 | - command: serverConfig.command, | |
| 230 | - }); | |
| 231 | - | |
| 232 | - await client.connect(transport, {}); | |
| 224 | + const client = await this.getConnectedClient(serverConfig); | |
| 233 | 225 | |
| 234 | 226 | connection.client = client; |
| 235 | 227 | connection.status = "connected"; |
| @@ -349,66 +341,103 @@ | ||
| 349 | 341 | } |
| 350 | 342 | |
| 351 | 343 | /** |
| 352 | - * Construct transport based on server configuration | |
| 344 | + * Construct transport based on server configuration and connect client | |
| 353 | 345 | */ |
| 354 | - private async constructTransport( | |
| 346 | + private async getConnectedClient( | |
| 355 | 347 | serverConfig: MCPServerConfig, |
| 356 | - ): Promise<Transport> { | |
| 357 | - const transportType = serverConfig.type || "stdio"; | |
| 358 | - | |
| 359 | - switch (transportType) { | |
| 360 | - case "stdio": | |
| 361 | - if (!serverConfig.command) { | |
| 362 | - throw new Error( | |
| 363 | - "MCP server command is not specified for stdio transport", | |
| 364 | - ); | |
| 365 | - } | |
| 366 | - | |
| 367 | - const env: Record<string, string> = serverConfig.env || {}; | |
| 368 | - if (process.env.PATH !== undefined) { | |
| 369 | - env.PATH = process.env.PATH; | |
| 370 | - } | |
| 371 | - | |
| 372 | - return new StdioClientTransport({ | |
| 373 | - command: serverConfig.command, | |
| 374 | - args: serverConfig.args || [], | |
| 375 | - env, | |
| 376 | - cwd: serverConfig.cwd, | |
| 377 | - stderr: "ignore", | |
| 378 | - }); | |
| 348 | + ): Promise<Client> { | |
| 349 | + const client = new Client( | |
| 350 | + { name: "continue-cli-client", version: "1.0.0" }, | |
| 351 | + { capabilities: {} }, | |
| 352 | + ); | |
| 379 | 353 | |
| 380 | - case "sse": | |
| 381 | - if (!serverConfig.url) { | |
| 382 | - throw new Error("MCP server URL is not specified for SSE transport"); | |
| 383 | - } | |
| 384 | - return new SSEClientTransport(new URL(serverConfig.url), { | |
| 385 | - eventSourceInit: { | |
| 386 | - fetch: (input, init) => | |
| 387 | - fetch(input, { | |
| 388 | - ...init, | |
| 389 | - headers: { | |
| 390 | - ...init?.headers, | |
| 391 | - ...(serverConfig.requestOptions?.headers as | |
| 392 | - | Record<string, string> | |
| 393 | - | undefined), | |
| 394 | - }, | |
| 395 | - }), | |
| 396 | - }, | |
| 397 | - requestInit: { headers: serverConfig.requestOptions?.headers }, | |
| 398 | - }); | |
| 354 | + if ("command" in serverConfig) { | |
| 355 | + // STDIO: no need to check type, just if command is present | |
| 356 | + logger.debug("Connecting to MCP server", { | |
| 357 | + name: serverConfig.name, | |
| 358 | + command: serverConfig.command, | |
| 359 | + }); | |
| 360 | + const transport = this.constructStdioTransport(serverConfig); | |
| 361 | + await client.connect(transport, {}); | |
| 362 | + } else { | |
| 363 | + // SSE/HTTP: if type isn't explicit: try http and fall back to sse | |
| 364 | + logger.debug("Connecting to MCP server", { | |
| 365 | + name: serverConfig.name, | |
| 366 | + url: serverConfig.url, | |
| 367 | + }); | |
| 399 | 368 | |
| 400 | - case "streamable-http": | |
| 401 | - if (!serverConfig.url) { | |
| 402 | - throw new Error( | |
| 403 | - "MCP server URL is not specified for streamable-http transport", | |
| 369 | + if (serverConfig.type === "sse") { | |
| 370 | + const transport = this.constructSseTransport(serverConfig); | |
| 371 | + await client.connect(transport, {}); | |
| 372 | + } else if (serverConfig.type === "streamable-http") { | |
| 373 | + const transport = this.constructHttpTransport(serverConfig); | |
| 374 | + await client.connect(transport, {}); | |
| 375 | + } else if (serverConfig.type) { | |
| 376 | + throw new Error(`Unsupported transport type: ${serverConfig.type}`); | |
| 377 | + } else { | |
| 378 | + try { | |
| 379 | + const transport = this.constructHttpTransport(serverConfig); | |
| 380 | + await client.connect(transport, {}); | |
| 381 | + } catch { | |
| 382 | + logger.debug( | |
| 383 | + "MCP Connection: http connection failed, falling back to sse connection", | |
| 384 | + { | |
| 385 | + name: serverConfig.name, | |
| 386 | + }, | |
| 404 | 387 | ); |
| 388 | + try { | |
| 389 | + const transport = this.constructSseTransport(serverConfig); | |
| 390 | + await client.connect(transport, {}); | |
| 391 | + } catch (e) { | |
| 392 | + throw new Error( | |
| 393 | + `MCP config with URL and no type specified failed both SSE and HTTP connection: ${e instanceof Error ? e.message : String(e)}`, | |
| 394 | + ); | |
| 395 | + } | |
| 405 | 396 | } |
| 406 | - return new StreamableHTTPClientTransport(new URL(serverConfig.url), { | |
| 407 | - requestInit: { headers: serverConfig.requestOptions?.headers }, | |
| 408 | - }); | |
| 397 | + } | |
| 398 | + } | |
| 399 | + | |
| 400 | + return client; | |
| 401 | + } | |
| 409 | 402 | |
| 410 | - default: | |
| 411 | - throw new Error(`Unsupported transport type: ${transportType}`); | |
| 403 | + private constructSseTransport( | |
| 404 | + serverConfig: SseMcpServer, | |
| 405 | + ): SSEClientTransport { | |
| 406 | + return new SSEClientTransport(new URL(serverConfig.url), { | |
| 407 | + eventSourceInit: { | |
| 408 | + fetch: (input, init) => | |
| 409 | + fetch(input, { | |
| 410 | + ...init, | |
| 411 | + headers: { | |
| 412 | + ...init?.headers, | |
| 413 | + ...serverConfig.requestOptions?.headers, | |
| 414 | + }, | |
| 415 | + }), | |
| 416 | + }, | |
| 417 | + requestInit: { headers: serverConfig.requestOptions?.headers }, | |
| 418 | + }); | |
| 419 | + } | |
| 420 | + private constructHttpTransport( | |
| 421 | + serverConfig: HttpMcpServer, | |
| 422 | + ): StreamableHTTPClientTransport { | |
| 423 | + return new StreamableHTTPClientTransport(new URL(serverConfig.url), { | |
| 424 | + requestInit: { headers: serverConfig.requestOptions?.headers }, | |
| 425 | + }); | |
| 426 | + } | |
| 427 | + private constructStdioTransport( | |
| 428 | + serverConfig: StdioMcpServer, | |
| 429 | + ): StdioClientTransport { | |
| 430 | + const env: Record<string, string> = serverConfig.env || {}; | |
| 431 | + if (process.env.PATH !== undefined) { | |
| 432 | + env.PATH = process.env.PATH; | |
| 412 | 433 | } |
| 434 | + | |
| 435 | + return new StdioClientTransport({ | |
| 436 | + command: serverConfig.command, | |
| 437 | + args: serverConfig.args || [], | |
| 438 | + env, | |
| 439 | + cwd: serverConfig.cwd, | |
| 440 | + stderr: "ignore", | |
| 441 | + }); | |
| 413 | 442 | } |
| 414 | 443 | } |
modified extensions/cli/src/ui/MCPSelector.tsx +14 −4
| @@ -328,14 +328,24 @@ | ||
| 328 | 328 | |
| 329 | 329 | const { color: statusColor, statusText } = |
| 330 | 330 | getServerStatusDisplay(serverInfo); |
| 331 | - const { command, args } = serverInfo.config; | |
| 332 | - let cmd = command ? quote([command, ...(args ?? [])]) : ""; | |
| 333 | - cmd = cmd.replace(/\$\{\{.*\}\}/, "(secret)"); | |
| 331 | + | |
| 332 | + let configText = ""; | |
| 333 | + if ("command" in serverInfo.config) { | |
| 334 | + const { command, args } = serverInfo.config; | |
| 335 | + const cmd = command ? quote([command, ...(args ?? [])]) : ""; | |
| 336 | + if (cmd) { | |
| 337 | + configText = ` • Command: ${cmd}`; | |
| 338 | + } | |
| 339 | + } else { | |
| 340 | + const { url } = serverInfo.config; | |
| 341 | + configText = ` • URL: ${url}`; | |
| 342 | + } | |
| 343 | + configText = configText.replace(/\$\{\{.*\}\}/, "(secret)"); | |
| 334 | 344 | |
| 335 | 345 | return ( |
| 336 | 346 | <Text color="dim"> |
| 337 | 347 | Status: <Text color={statusColor}>{statusText}</Text> |
| 338 | - {cmd && ` • Command: ${cmd}`} | |
| 348 | + {configText} | |
| 339 | 349 | </Text> |
| 340 | 350 | ); |
| 341 | 351 | })()} |
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +2 −0
| @@ -92,6 +92,8 @@ | ||
| 92 | 92 | "config/updateSharedConfig", |
| 93 | 93 | "config/updateSelectedModel", |
| 94 | 94 | "mcp/reloadServer", |
| 95 | + "mcp/startAuthentication", | |
| 96 | + "mcp/removeAuthentication", | |
| 95 | 97 | "mcp/getPrompt", |
| 96 | 98 | "context/getContextItems", |
| 97 | 99 | "context/getSymbolsForFiles", |
modified gui/src/pages/config/sections/ToolsSection.tsx +43 −31
| @@ -82,13 +82,23 @@ | ||
| 82 | 82 | }; |
| 83 | 83 | |
| 84 | 84 | const onAuthenticate = async () => { |
| 85 | - updateMCPServerStatus("authenticating"); | |
| 86 | - await ideMessenger.request("mcp/startAuthentication", server); | |
| 85 | + if ("url" in server) { | |
| 86 | + updateMCPServerStatus("authenticating"); | |
| 87 | + await ideMessenger.request("mcp/startAuthentication", { | |
| 88 | + serverId: server.id, | |
| 89 | + serverUrl: server.url, | |
| 90 | + }); | |
| 91 | + } | |
| 87 | 92 | }; |
| 88 | 93 | |
| 89 | 94 | const onRemoveAuth = async () => { |
| 90 | - updateMCPServerStatus("authenticating"); | |
| 91 | - await ideMessenger.request("mcp/removeAuthentication", server); | |
| 95 | + if ("url" in server) { | |
| 96 | + updateMCPServerStatus("authenticating"); | |
| 97 | + await ideMessenger.request("mcp/removeAuthentication", { | |
| 98 | + serverId: server.id, | |
| 99 | + serverUrl: server.url, | |
| 100 | + }); | |
| 101 | + } | |
| 92 | 102 | }; |
| 93 | 103 | |
| 94 | 104 | const onRefresh = async () => { |
| @@ -217,37 +227,39 @@ | ||
| 217 | 227 | </div> |
| 218 | 228 | |
| 219 | 229 | <div className="-mr-2.5 flex items-center gap-1"> |
| 220 | - {server.isProtectedResource && server.status !== "connected" && ( | |
| 221 | - <ToolTip | |
| 222 | - content={ | |
| 223 | - server.status === "error" | |
| 224 | - ? "Authenticate" | |
| 225 | - : server.status === "authenticating" | |
| 226 | - ? "Authenticating..." | |
| 227 | - : "Remove authentication" | |
| 228 | - } | |
| 229 | - > | |
| 230 | - <Button | |
| 231 | - onClick={ | |
| 230 | + {server.isProtectedResource && | |
| 231 | + "url" in server && | |
| 232 | + server.status !== "connected" && ( | |
| 233 | + <ToolTip | |
| 234 | + content={ | |
| 232 | 235 | server.status === "error" |
| 233 | - ? onAuthenticate | |
| 236 | + ? "Authenticate" | |
| 234 | 237 | : server.status === "authenticating" |
| 235 | - ? undefined | |
| 236 | - : onRemoveAuth | |
| 238 | + ? "Authenticating..." | |
| 239 | + : "Remove authentication" | |
| 237 | 240 | } |
| 238 | - variant="ghost" | |
| 239 | - size="sm" | |
| 240 | - className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0 pt-0.5" | |
| 241 | - disabled={server.status === "authenticating"} | |
| 242 | 241 | > |
| 243 | - {server.status === "authenticating" ? ( | |
| 244 | - <GlobeAltIcon className="animate-spin-slow h-4 w-4 flex-shrink-0" /> | |
| 245 | - ) : ( | |
| 246 | - <UserCircleIcon className="h-4 w-4 flex-shrink-0" /> | |
| 247 | - )} | |
| 248 | - </Button> | |
| 249 | - </ToolTip> | |
| 250 | - )} | |
| 242 | + <Button | |
| 243 | + onClick={ | |
| 244 | + server.status === "error" | |
| 245 | + ? onAuthenticate | |
| 246 | + : server.status === "authenticating" | |
| 247 | + ? undefined | |
| 248 | + : onRemoveAuth | |
| 249 | + } | |
| 250 | + variant="ghost" | |
| 251 | + size="sm" | |
| 252 | + className="text-description-muted hover:enabled:text-foreground my-0 h-6 w-6 p-0 pt-0.5" | |
| 253 | + disabled={server.status === "authenticating"} | |
| 254 | + > | |
| 255 | + {server.status === "authenticating" ? ( | |
| 256 | + <GlobeAltIcon className="animate-spin-slow h-4 w-4 flex-shrink-0" /> | |
| 257 | + ) : ( | |
| 258 | + <UserCircleIcon className="h-4 w-4 flex-shrink-0" /> | |
| 259 | + )} | |
| 260 | + </Button> | |
| 261 | + </ToolTip> | |
| 262 | + )} | |
| 251 | 263 | <Listbox> |
| 252 | 264 | <ListboxButton> |
| 253 | 265 | <EllipsisVerticalIcon className="h-4 w-4 flex-shrink-0" /> |
added manual-testing-sandbox/claude_desktop_config.json +9 −0
| @@ -0,0 +1,9 @@ | ||
| 1 | +{ | |
| 2 | + "mcpServers": { | |
| 3 | + "linear": { | |
| 4 | + "command": "npx", | |
| 5 | + "args": ["-y", "mcp-remote", "https://mcp.linear.app/sse"], | |
| 6 | + "envFile": "hey" | |
| 7 | + } | |
| 8 | + } | |
| 9 | +} |
modified packages/config-yaml/package-lock.json +0 −0
Not shown: the file is larger than the hub shows, or this page holds as much as it shows. View the file.
modified packages/config-yaml/package.json +1 −1
| @@ -1,6 +1,6 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/config-yaml", |
| 3 | - "version": "1.17.0", | |
| 3 | + "version": "1.23.0", | |
| 4 | 4 | "description": "", |
| 5 | 5 | "main": "dist/index.js", |
| 6 | 6 | "types": "dist/index.d.ts", |
modified packages/config-yaml/src/browser.ts +2 −0
| @@ -14,6 +14,8 @@ | ||
| 14 | 14 | // Note: registryClient.js is excluded because it uses Node.js fs/path APIs |
| 15 | 15 | export * from "./schemas/data/index.js"; |
| 16 | 16 | export * from "./schemas/index.js"; |
| 17 | +export * from "./schemas/mcp/convertJson.js"; | |
| 18 | +export * from "./schemas/mcp/json.js"; | |
| 17 | 19 | export * from "./schemas/models.js"; |
| 18 | 20 | export * from "./schemas/policy.js"; |
| 19 | 21 | export * from "./validation.js"; |
modified packages/config-yaml/src/schemas/index.ts +14 −17
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | import * as z from "zod"; |
| 2 | 2 | import { commonModelSlugs } from "./commonSlugs.js"; |
| 3 | 3 | import { dataSchema } from "./data/index.js"; |
| 4 | +import { mcpServerSchema, partialMcpServerSchema } from "./mcp/index.js"; | |
| 4 | 5 | import { |
| 5 | 6 | modelSchema, |
| 6 | 7 | partialModelSchema, |
| @@ -13,22 +14,7 @@ | ||
| 13 | 14 | params: z.any().optional(), |
| 14 | 15 | }); |
| 15 | 16 | |
| 16 | -// TODO: This should be a discriminated union by type | |
| 17 | -const mcpServerSchema = z.object({ | |
| 18 | - name: z.string(), | |
| 19 | - command: z.string().optional(), | |
| 20 | - type: z.enum(["sse", "stdio", "streamable-http"]).optional(), | |
| 21 | - url: z.string().optional(), | |
| 22 | - faviconUrl: z.string().optional(), | |
| 23 | - args: z.array(z.string()).optional(), | |
| 24 | - env: z.record(z.string()).optional(), | |
| 25 | - cwd: z.string().optional(), | |
| 26 | - connectionTimeout: z.number().gt(0).optional(), | |
| 27 | - requestOptions: requestOptionsSchema.optional(), | |
| 28 | - sourceFile: z.string().optional(), | |
| 29 | -}); | |
| 30 | - | |
| 31 | -export type MCPServer = z.infer<typeof mcpServerSchema>; | |
| 17 | +export { MCPServer } from "./mcp/index.js"; | |
| 32 | 18 | |
| 33 | 19 | const promptSchema = z.object({ |
| 34 | 20 | name: z.string(), |
| @@ -139,7 +125,18 @@ | ||
| 139 | 125 | .optional(), |
| 140 | 126 | context: z.array(blockOrSchema(contextSchema)).optional(), |
| 141 | 127 | data: z.array(blockOrSchema(dataSchema)).optional(), |
| 142 | - mcpServers: z.array(blockOrSchema(mcpServerSchema)).optional(), | |
| 128 | + mcpServers: z | |
| 129 | + .array( | |
| 130 | + z.union([ | |
| 131 | + mcpServerSchema, | |
| 132 | + z.object({ | |
| 133 | + uses: defaultUsesSchema, | |
| 134 | + with: z.record(z.string()).optional(), | |
| 135 | + override: partialMcpServerSchema.optional(), | |
| 136 | + }), | |
| 137 | + ]), | |
| 138 | + ) | |
| 139 | + .optional(), | |
| 143 | 140 | rules: z |
| 144 | 141 | .array( |
| 145 | 142 | z.union([ |
added packages/config-yaml/src/schemas/mcp/convertJson.test.ts +923 −0
| @@ -0,0 +1,923 @@ | ||
| 1 | +import { | |
| 2 | + converMcpServersJsonConfigFileToYamlBlocks, | |
| 3 | + convertJsonMcpConfigToYamlMcpConfig, | |
| 4 | + convertYamlMcpConfigToJsonMcpConfig, | |
| 5 | +} from "./convertJson.js"; | |
| 6 | +import type { HttpMcpServer, SseMcpServer, StdioMcpServer } from "./index.js"; | |
| 7 | +import { | |
| 8 | + claudeDesktopLikeConfigFileSchema, | |
| 9 | + mcpServersJsonSchema, | |
| 10 | + type HttpMcpJsonConfig, | |
| 11 | + type McpServersJsonConfigFile, | |
| 12 | + type SseMcpJsonConfig, | |
| 13 | + type StdioMcpJsonConfig, | |
| 14 | +} from "./json.js"; | |
| 15 | + | |
| 16 | +describe("convertJsonMcpConfigToYamlMcpConfig", () => { | |
| 17 | + describe("STDIO configurations", () => { | |
| 18 | + test("converts basic stdio config", () => { | |
| 19 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 20 | + command: "node", | |
| 21 | + args: ["server.js"], | |
| 22 | + }; | |
| 23 | + | |
| 24 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 25 | + "test-server", | |
| 26 | + jsonConfig, | |
| 27 | + ); | |
| 28 | + | |
| 29 | + expect(result.yamlConfig).toEqual({ | |
| 30 | + name: "test-server", | |
| 31 | + type: "stdio", | |
| 32 | + command: "node", | |
| 33 | + args: ["server.js"], | |
| 34 | + }); | |
| 35 | + expect(result.warnings).toHaveLength(0); | |
| 36 | + }); | |
| 37 | + | |
| 38 | + test("converts stdio config with all fields", () => { | |
| 39 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 40 | + type: "stdio", | |
| 41 | + command: "python", | |
| 42 | + args: ["-m", "server"], | |
| 43 | + env: { | |
| 44 | + API_KEY: "test-key", | |
| 45 | + DEBUG: "true", | |
| 46 | + }, | |
| 47 | + }; | |
| 48 | + | |
| 49 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 50 | + "python-server", | |
| 51 | + jsonConfig, | |
| 52 | + ); | |
| 53 | + | |
| 54 | + expect(result.yamlConfig).toEqual({ | |
| 55 | + name: "python-server", | |
| 56 | + type: "stdio", | |
| 57 | + command: "python", | |
| 58 | + args: ["-m", "server"], | |
| 59 | + env: { | |
| 60 | + API_KEY: "test-key", | |
| 61 | + DEBUG: "true", | |
| 62 | + }, | |
| 63 | + }); | |
| 64 | + expect(result.warnings).toHaveLength(0); | |
| 65 | + }); | |
| 66 | + | |
| 67 | + test("warns about unsupported envFile", () => { | |
| 68 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 69 | + command: "node", | |
| 70 | + args: ["server.js"], | |
| 71 | + envFile: ".env", | |
| 72 | + }; | |
| 73 | + | |
| 74 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 75 | + "env-server", | |
| 76 | + jsonConfig, | |
| 77 | + ); | |
| 78 | + | |
| 79 | + expect(result.yamlConfig).toEqual({ | |
| 80 | + name: "env-server", | |
| 81 | + type: "stdio", | |
| 82 | + command: "node", | |
| 83 | + args: ["server.js"], | |
| 84 | + }); | |
| 85 | + expect(result.warnings).toHaveLength(1); | |
| 86 | + expect(result.warnings[0]).toContain("envFile is not supported"); | |
| 87 | + }); | |
| 88 | + | |
| 89 | + test("converts stdio config from parsed JSON string", () => { | |
| 90 | + const jsonString = JSON.stringify({ | |
| 91 | + command: "deno", | |
| 92 | + args: ["run", "server.ts"], | |
| 93 | + env: { PORT: "3000" }, | |
| 94 | + }); | |
| 95 | + const parsed = mcpServersJsonSchema.parse(JSON.parse(jsonString)); | |
| 96 | + | |
| 97 | + const result = convertJsonMcpConfigToYamlMcpConfig("deno-server", parsed); | |
| 98 | + | |
| 99 | + expect(result.yamlConfig).toEqual({ | |
| 100 | + name: "deno-server", | |
| 101 | + type: "stdio", | |
| 102 | + command: "deno", | |
| 103 | + args: ["run", "server.ts"], | |
| 104 | + env: { PORT: "3000" }, | |
| 105 | + }); | |
| 106 | + }); | |
| 107 | + }); | |
| 108 | + | |
| 109 | + describe("SSE/HTTP configurations", () => { | |
| 110 | + test("converts basic SSE config", () => { | |
| 111 | + const jsonConfig: SseMcpJsonConfig = { | |
| 112 | + url: "https://api.example.com/sse", | |
| 113 | + }; | |
| 114 | + | |
| 115 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 116 | + "sse-server", | |
| 117 | + jsonConfig, | |
| 118 | + ); | |
| 119 | + | |
| 120 | + expect(result.yamlConfig).toEqual({ | |
| 121 | + name: "sse-server", | |
| 122 | + url: "https://api.example.com/sse", | |
| 123 | + }); | |
| 124 | + expect(result.warnings).toHaveLength(0); | |
| 125 | + }); | |
| 126 | + | |
| 127 | + test("converts SSE config with type and headers", () => { | |
| 128 | + const jsonConfig: SseMcpJsonConfig = { | |
| 129 | + type: "sse", | |
| 130 | + url: "https://api.example.com/sse", | |
| 131 | + headers: { | |
| 132 | + Authorization: "Bearer token", | |
| 133 | + "X-Custom-Header": "value", | |
| 134 | + }, | |
| 135 | + }; | |
| 136 | + | |
| 137 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 138 | + "sse-auth", | |
| 139 | + jsonConfig, | |
| 140 | + ); | |
| 141 | + | |
| 142 | + expect(result.yamlConfig).toEqual({ | |
| 143 | + name: "sse-auth", | |
| 144 | + type: "sse", | |
| 145 | + url: "https://api.example.com/sse", | |
| 146 | + requestOptions: { | |
| 147 | + headers: { | |
| 148 | + Authorization: "Bearer token", | |
| 149 | + "X-Custom-Header": "value", | |
| 150 | + }, | |
| 151 | + }, | |
| 152 | + }); | |
| 153 | + expect(result.warnings).toHaveLength(0); | |
| 154 | + }); | |
| 155 | + | |
| 156 | + test("converts HTTP config", () => { | |
| 157 | + const jsonConfig: HttpMcpJsonConfig = { | |
| 158 | + type: "http", | |
| 159 | + url: "https://api.example.com/http", | |
| 160 | + headers: { | |
| 161 | + "Content-Type": "application/json", | |
| 162 | + }, | |
| 163 | + }; | |
| 164 | + | |
| 165 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 166 | + "http-server", | |
| 167 | + jsonConfig, | |
| 168 | + ); | |
| 169 | + | |
| 170 | + expect(result.yamlConfig).toEqual({ | |
| 171 | + name: "http-server", | |
| 172 | + type: "streamable-http", | |
| 173 | + url: "https://api.example.com/http", | |
| 174 | + requestOptions: { | |
| 175 | + headers: { | |
| 176 | + "Content-Type": "application/json", | |
| 177 | + }, | |
| 178 | + }, | |
| 179 | + }); | |
| 180 | + expect(result.warnings).toHaveLength(0); | |
| 181 | + }); | |
| 182 | + | |
| 183 | + test("converts HTTP config from parsed JSON string", () => { | |
| 184 | + const jsonString = JSON.stringify({ | |
| 185 | + type: "http", | |
| 186 | + url: "https://test.com/api", | |
| 187 | + headers: { "API-Key": "secret" }, | |
| 188 | + }); | |
| 189 | + const parsed = mcpServersJsonSchema.parse(JSON.parse(jsonString)); | |
| 190 | + | |
| 191 | + const result = convertJsonMcpConfigToYamlMcpConfig("parsed-http", parsed); | |
| 192 | + | |
| 193 | + expect(result.yamlConfig).toEqual({ | |
| 194 | + name: "parsed-http", | |
| 195 | + type: "streamable-http", | |
| 196 | + url: "https://test.com/api", | |
| 197 | + requestOptions: { | |
| 198 | + headers: { "API-Key": "secret" }, | |
| 199 | + }, | |
| 200 | + }); | |
| 201 | + }); | |
| 202 | + }); | |
| 203 | + | |
| 204 | + test("throws error for invalid config", () => { | |
| 205 | + const invalidConfig = { | |
| 206 | + invalid: "config", | |
| 207 | + } as any; | |
| 208 | + | |
| 209 | + expect(() => | |
| 210 | + convertJsonMcpConfigToYamlMcpConfig("invalid", invalidConfig), | |
| 211 | + ).toThrowError("Invalid MCP server configuration"); | |
| 212 | + }); | |
| 213 | +}); | |
| 214 | + | |
| 215 | +describe("convertYamlMcpConfigToJsonMcpConfig", () => { | |
| 216 | + describe("STDIO configurations", () => { | |
| 217 | + test("converts basic stdio config", () => { | |
| 218 | + const yamlConfig: StdioMcpServer = { | |
| 219 | + name: "test-server", | |
| 220 | + type: "stdio", | |
| 221 | + command: "node", | |
| 222 | + args: ["server.js"], | |
| 223 | + }; | |
| 224 | + | |
| 225 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 226 | + | |
| 227 | + expect(result.name).toBe("test-server"); | |
| 228 | + expect(result.jsonConfig).toEqual({ | |
| 229 | + type: "stdio", | |
| 230 | + command: "node", | |
| 231 | + args: ["server.js"], | |
| 232 | + }); | |
| 233 | + expect(result.MCP_TIMEOUT).toBeUndefined(); | |
| 234 | + expect(result.warnings).toHaveLength(0); | |
| 235 | + }); | |
| 236 | + | |
| 237 | + test("converts stdio config with env and timeout", () => { | |
| 238 | + const yamlConfig: StdioMcpServer = { | |
| 239 | + name: "python-server", | |
| 240 | + command: "python", | |
| 241 | + args: ["-m", "server"], | |
| 242 | + env: { | |
| 243 | + API_KEY: "test-key", | |
| 244 | + DEBUG: "true", | |
| 245 | + }, | |
| 246 | + connectionTimeout: 30000, | |
| 247 | + }; | |
| 248 | + | |
| 249 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 250 | + | |
| 251 | + expect(result.name).toBe("python-server"); | |
| 252 | + expect(result.jsonConfig).toEqual({ | |
| 253 | + type: "stdio", | |
| 254 | + command: "python", | |
| 255 | + args: ["-m", "server"], | |
| 256 | + env: { | |
| 257 | + API_KEY: "test-key", | |
| 258 | + DEBUG: "true", | |
| 259 | + }, | |
| 260 | + }); | |
| 261 | + expect(result.MCP_TIMEOUT).toBe("30000"); | |
| 262 | + expect(result.warnings).toHaveLength(0); | |
| 263 | + }); | |
| 264 | + | |
| 265 | + test("warns about unsupported cwd field", () => { | |
| 266 | + const yamlConfig: StdioMcpServer = { | |
| 267 | + name: "cwd-server", | |
| 268 | + command: "node", | |
| 269 | + cwd: "/path/to/dir", | |
| 270 | + }; | |
| 271 | + | |
| 272 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 273 | + | |
| 274 | + expect(result.jsonConfig).toEqual({ | |
| 275 | + type: "stdio", | |
| 276 | + command: "node", | |
| 277 | + }); | |
| 278 | + expect(result.warnings).toHaveLength(1); | |
| 279 | + expect(result.warnings[0]).toBe( | |
| 280 | + "`cwd` from YAML MCP config not supported in Claude-style JSON, will be removed from server cwd-server", | |
| 281 | + ); | |
| 282 | + }); | |
| 283 | + | |
| 284 | + test("warns about unsupported faviconUrl", () => { | |
| 285 | + const yamlConfig: StdioMcpServer = { | |
| 286 | + name: "icon-server", | |
| 287 | + command: "node", | |
| 288 | + faviconUrl: "https://example.com/icon.png", | |
| 289 | + }; | |
| 290 | + | |
| 291 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 292 | + | |
| 293 | + expect(result.warnings).toHaveLength(1); | |
| 294 | + expect(result.warnings[0]).toBe( | |
| 295 | + "`faviconUrl` from YAML MCP config not supported in Claude-style JSON, will be removed from server icon-server", | |
| 296 | + ); | |
| 297 | + }); | |
| 298 | + | |
| 299 | + test("converts parsed YAML stdio config", () => { | |
| 300 | + const yamlConfig: StdioMcpServer = { | |
| 301 | + name: "parsed-stdio", | |
| 302 | + type: "stdio", | |
| 303 | + command: "bun", | |
| 304 | + args: ["run", "server.ts"], | |
| 305 | + env: { NODE_ENV: "production" }, | |
| 306 | + }; | |
| 307 | + | |
| 308 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 309 | + | |
| 310 | + expect(result.jsonConfig).toEqual({ | |
| 311 | + type: "stdio", | |
| 312 | + command: "bun", | |
| 313 | + args: ["run", "server.ts"], | |
| 314 | + env: { NODE_ENV: "production" }, | |
| 315 | + }); | |
| 316 | + }); | |
| 317 | + }); | |
| 318 | + | |
| 319 | + describe("SSE/HTTP configurations", () => { | |
| 320 | + test("converts basic SSE config", () => { | |
| 321 | + const yamlConfig: SseMcpServer = { | |
| 322 | + name: "sse-server", | |
| 323 | + url: "https://api.example.com/sse", | |
| 324 | + }; | |
| 325 | + | |
| 326 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 327 | + | |
| 328 | + expect(result.name).toBe("sse-server"); | |
| 329 | + expect(result.jsonConfig).toEqual({ | |
| 330 | + url: "https://api.example.com/sse", | |
| 331 | + }); | |
| 332 | + expect(result.warnings).toHaveLength(0); | |
| 333 | + }); | |
| 334 | + | |
| 335 | + test("converts SSE config with type and headers", () => { | |
| 336 | + const yamlConfig: SseMcpServer = { | |
| 337 | + name: "sse-auth", | |
| 338 | + type: "sse", | |
| 339 | + url: "https://api.example.com/sse", | |
| 340 | + requestOptions: { | |
| 341 | + headers: { | |
| 342 | + Authorization: "Bearer token", | |
| 343 | + "X-Custom-Header": "value", | |
| 344 | + }, | |
| 345 | + }, | |
| 346 | + }; | |
| 347 | + | |
| 348 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 349 | + | |
| 350 | + expect(result.jsonConfig).toEqual({ | |
| 351 | + type: "sse", | |
| 352 | + url: "https://api.example.com/sse", | |
| 353 | + headers: { | |
| 354 | + Authorization: "Bearer token", | |
| 355 | + "X-Custom-Header": "value", | |
| 356 | + }, | |
| 357 | + }); | |
| 358 | + expect(result.warnings).toHaveLength(0); | |
| 359 | + }); | |
| 360 | + | |
| 361 | + test("converts HTTP config", () => { | |
| 362 | + const yamlConfig: HttpMcpServer = { | |
| 363 | + name: "http-server", | |
| 364 | + type: "streamable-http", | |
| 365 | + url: "https://api.example.com/http", | |
| 366 | + requestOptions: { | |
| 367 | + headers: { | |
| 368 | + "Content-Type": "application/json", | |
| 369 | + }, | |
| 370 | + }, | |
| 371 | + }; | |
| 372 | + | |
| 373 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 374 | + | |
| 375 | + expect(result.jsonConfig).toEqual({ | |
| 376 | + type: "http", | |
| 377 | + url: "https://api.example.com/http", | |
| 378 | + headers: { | |
| 379 | + "Content-Type": "application/json", | |
| 380 | + }, | |
| 381 | + }); | |
| 382 | + expect(result.warnings).toHaveLength(0); | |
| 383 | + }); | |
| 384 | + | |
| 385 | + test("warns about unsupported requestOptions fields", () => { | |
| 386 | + const yamlConfig: SseMcpServer = { | |
| 387 | + name: "complex-server", | |
| 388 | + url: "https://api.example.com", | |
| 389 | + requestOptions: { | |
| 390 | + headers: { "API-Key": "secret" }, | |
| 391 | + timeout: 5000, | |
| 392 | + proxy: "http://proxy.com", | |
| 393 | + verifySsl: false, | |
| 394 | + }, | |
| 395 | + }; | |
| 396 | + | |
| 397 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 398 | + | |
| 399 | + expect(result.jsonConfig).toEqual({ | |
| 400 | + url: "https://api.example.com", | |
| 401 | + headers: { "API-Key": "secret" }, | |
| 402 | + }); | |
| 403 | + expect(result.warnings).toHaveLength(3); | |
| 404 | + expect(result.warnings).toContain( | |
| 405 | + "timeout requestOption from YAML MCP config not supported in Claude-style JSON, will be ignored in server complex-server", | |
| 406 | + ); | |
| 407 | + expect(result.warnings).toContain( | |
| 408 | + "proxy requestOption from YAML MCP config not supported in Claude-style JSON, will be ignored in server complex-server", | |
| 409 | + ); | |
| 410 | + expect(result.warnings).toContain( | |
| 411 | + "verifySsl requestOption from YAML MCP config not supported in Claude-style JSON, will be ignored in server complex-server", | |
| 412 | + ); | |
| 413 | + }); | |
| 414 | + | |
| 415 | + test("converts parsed YAML HTTP config", () => { | |
| 416 | + const yamlConfig: HttpMcpServer = { | |
| 417 | + name: "parsed-http", | |
| 418 | + type: "streamable-http", | |
| 419 | + url: "https://test.com/api", | |
| 420 | + requestOptions: { | |
| 421 | + headers: { "API-Key": "secret" }, | |
| 422 | + }, | |
| 423 | + connectionTimeout: 10000, | |
| 424 | + }; | |
| 425 | + | |
| 426 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 427 | + | |
| 428 | + expect(result.jsonConfig).toEqual({ | |
| 429 | + type: "http", | |
| 430 | + url: "https://test.com/api", | |
| 431 | + headers: { "API-Key": "secret" }, | |
| 432 | + }); | |
| 433 | + expect(result.MCP_TIMEOUT).toBe("10000"); | |
| 434 | + }); | |
| 435 | + }); | |
| 436 | + | |
| 437 | + test("throws error for invalid config", () => { | |
| 438 | + const invalidConfig = { | |
| 439 | + name: "invalid", | |
| 440 | + invalid: "config", | |
| 441 | + } as any; | |
| 442 | + | |
| 443 | + expect(() => | |
| 444 | + convertYamlMcpConfigToJsonMcpConfig(invalidConfig), | |
| 445 | + ).toThrowError("Invalid MCP server configuration"); | |
| 446 | + }); | |
| 447 | +}); | |
| 448 | + | |
| 449 | +describe("converMcpServersJsonConfigFileToYamlBlocks", () => { | |
| 450 | + test("converts empty file", () => { | |
| 451 | + const jsonFile: McpServersJsonConfigFile = { | |
| 452 | + mcpServers: {}, | |
| 453 | + }; | |
| 454 | + | |
| 455 | + const result = converMcpServersJsonConfigFileToYamlBlocks(jsonFile); | |
| 456 | + | |
| 457 | + expect(result.yamlConfigs).toEqual([]); | |
| 458 | + expect(result.warnings).toHaveLength(0); | |
| 459 | + }); | |
| 460 | + | |
| 461 | + test("converts file with multiple servers", () => { | |
| 462 | + const jsonFile: McpServersJsonConfigFile = { | |
| 463 | + mcpServers: { | |
| 464 | + "weather-server": { | |
| 465 | + command: "npx", | |
| 466 | + args: ["@example/weather-server"], | |
| 467 | + env: { | |
| 468 | + WEATHER_API_KEY: "key123", | |
| 469 | + }, | |
| 470 | + }, | |
| 471 | + "database-server": { | |
| 472 | + type: "stdio", | |
| 473 | + command: "python", | |
| 474 | + args: ["-m", "db_server"], | |
| 475 | + }, | |
| 476 | + "api-server": { | |
| 477 | + type: "http", | |
| 478 | + url: "https://api.example.com", | |
| 479 | + headers: { | |
| 480 | + Authorization: "Bearer token", | |
| 481 | + }, | |
| 482 | + }, | |
| 483 | + "sse-server": { | |
| 484 | + type: "sse", | |
| 485 | + url: "https://sse.example.com/stream", | |
| 486 | + }, | |
| 487 | + }, | |
| 488 | + }; | |
| 489 | + | |
| 490 | + const result = converMcpServersJsonConfigFileToYamlBlocks(jsonFile); | |
| 491 | + | |
| 492 | + expect(result.yamlConfigs).toHaveLength(4); | |
| 493 | + expect(result.warnings).toHaveLength(0); | |
| 494 | + | |
| 495 | + // Check each converted server | |
| 496 | + expect(result.yamlConfigs[0]).toEqual({ | |
| 497 | + name: "weather-server", | |
| 498 | + type: "stdio", | |
| 499 | + command: "npx", | |
| 500 | + args: ["@example/weather-server"], | |
| 501 | + env: { | |
| 502 | + WEATHER_API_KEY: "key123", | |
| 503 | + }, | |
| 504 | + }); | |
| 505 | + | |
| 506 | + expect(result.yamlConfigs[1]).toEqual({ | |
| 507 | + name: "database-server", | |
| 508 | + type: "stdio", | |
| 509 | + command: "python", | |
| 510 | + args: ["-m", "db_server"], | |
| 511 | + }); | |
| 512 | + | |
| 513 | + expect(result.yamlConfigs[2]).toEqual({ | |
| 514 | + name: "api-server", | |
| 515 | + type: "streamable-http", | |
| 516 | + url: "https://api.example.com", | |
| 517 | + requestOptions: { | |
| 518 | + headers: { | |
| 519 | + Authorization: "Bearer token", | |
| 520 | + }, | |
| 521 | + }, | |
| 522 | + }); | |
| 523 | + | |
| 524 | + expect(result.yamlConfigs[3]).toEqual({ | |
| 525 | + name: "sse-server", | |
| 526 | + type: "sse", | |
| 527 | + url: "https://sse.example.com/stream", | |
| 528 | + }); | |
| 529 | + }); | |
| 530 | + | |
| 531 | + test("collects warnings from multiple servers", () => { | |
| 532 | + const jsonFile: McpServersJsonConfigFile = { | |
| 533 | + mcpServers: { | |
| 534 | + server1: { | |
| 535 | + command: "node", | |
| 536 | + envFile: ".env", | |
| 537 | + }, | |
| 538 | + server2: { | |
| 539 | + command: "python", | |
| 540 | + args: ["app.py"], | |
| 541 | + envFile: ".env.production", | |
| 542 | + }, | |
| 543 | + }, | |
| 544 | + }; | |
| 545 | + | |
| 546 | + const result = converMcpServersJsonConfigFileToYamlBlocks(jsonFile); | |
| 547 | + | |
| 548 | + expect(result.yamlConfigs).toHaveLength(2); | |
| 549 | + expect(result.warnings).toHaveLength(2); | |
| 550 | + expect(result.warnings[0]).toContain("server1"); | |
| 551 | + expect(result.warnings[1]).toContain("server2"); | |
| 552 | + }); | |
| 553 | + | |
| 554 | + test("converts parsed JSON file", () => { | |
| 555 | + const jsonString = JSON.stringify({ | |
| 556 | + mcpServers: { | |
| 557 | + "test-stdio": { | |
| 558 | + command: "node", | |
| 559 | + args: ["index.js"], | |
| 560 | + }, | |
| 561 | + "test-http": { | |
| 562 | + type: "http", | |
| 563 | + url: "https://test.com", | |
| 564 | + headers: { "X-Test": "value" }, | |
| 565 | + }, | |
| 566 | + }, | |
| 567 | + }); | |
| 568 | + const parsed = claudeDesktopLikeConfigFileSchema.parse( | |
| 569 | + JSON.parse(jsonString), | |
| 570 | + ); | |
| 571 | + | |
| 572 | + const result = converMcpServersJsonConfigFileToYamlBlocks(parsed); | |
| 573 | + | |
| 574 | + expect(result.yamlConfigs).toHaveLength(2); | |
| 575 | + expect(result.yamlConfigs[0].name).toBe("test-stdio"); | |
| 576 | + expect(result.yamlConfigs[1].name).toBe("test-http"); | |
| 577 | + }); | |
| 578 | + | |
| 579 | + test("handles mixed valid and problematic configurations", () => { | |
| 580 | + const jsonFile: McpServersJsonConfigFile = { | |
| 581 | + mcpServers: { | |
| 582 | + "good-server": { | |
| 583 | + command: "node", | |
| 584 | + args: ["server.js"], | |
| 585 | + }, | |
| 586 | + "warning-server": { | |
| 587 | + command: "python", | |
| 588 | + envFile: ".env", | |
| 589 | + env: { | |
| 590 | + PORT: "3000", | |
| 591 | + }, | |
| 592 | + }, | |
| 593 | + }, | |
| 594 | + }; | |
| 595 | + | |
| 596 | + const result = converMcpServersJsonConfigFileToYamlBlocks(jsonFile); | |
| 597 | + | |
| 598 | + expect(result.yamlConfigs).toHaveLength(2); | |
| 599 | + expect(result.warnings).toHaveLength(1); | |
| 600 | + | |
| 601 | + // Check that both servers were converted | |
| 602 | + expect( | |
| 603 | + result.yamlConfigs.find((c) => c.name === "good-server"), | |
| 604 | + ).toBeTruthy(); | |
| 605 | + expect( | |
| 606 | + result.yamlConfigs.find((c) => c.name === "warning-server"), | |
| 607 | + ).toBeTruthy(); | |
| 608 | + | |
| 609 | + // Check that the warning server still has its env vars | |
| 610 | + const warningServer = result.yamlConfigs.find( | |
| 611 | + (c) => c.name === "warning-server", | |
| 612 | + ); | |
| 613 | + expect(warningServer).toMatchObject({ | |
| 614 | + env: { PORT: "3000" }, | |
| 615 | + }); | |
| 616 | + }); | |
| 617 | + | |
| 618 | + test("handles environment variable templating in JSON file", () => { | |
| 619 | + const jsonFile: McpServersJsonConfigFile = { | |
| 620 | + mcpServers: { | |
| 621 | + "weather-server": { | |
| 622 | + command: "npx", | |
| 623 | + args: ["@example/weather-server"], | |
| 624 | + env: { | |
| 625 | + WEATHER_API_KEY: "${WEATHER_API_KEY_ENV_VAR}", | |
| 626 | + STATIC_VALUE: "production", | |
| 627 | + COMPLEX: "https://${API_HOST}:${API_PORT}/v1", | |
| 628 | + }, | |
| 629 | + }, | |
| 630 | + }, | |
| 631 | + }; | |
| 632 | + | |
| 633 | + const result = converMcpServersJsonConfigFileToYamlBlocks(jsonFile); | |
| 634 | + | |
| 635 | + expect(result.yamlConfigs).toHaveLength(1); | |
| 636 | + expect(result.yamlConfigs[0]).toEqual({ | |
| 637 | + name: "weather-server", | |
| 638 | + type: "stdio", | |
| 639 | + command: "npx", | |
| 640 | + args: ["@example/weather-server"], | |
| 641 | + env: { | |
| 642 | + WEATHER_API_KEY: "${{ secrets.WEATHER_API_KEY_ENV_VAR }}", | |
| 643 | + STATIC_VALUE: "production", | |
| 644 | + COMPLEX: "https://${{ secrets.API_HOST }}:${{ secrets.API_PORT }}/v1", | |
| 645 | + }, | |
| 646 | + }); | |
| 647 | + }); | |
| 648 | +}); | |
| 649 | + | |
| 650 | +describe("Environment variable conversion", () => { | |
| 651 | + describe("JSON to YAML conversion", () => { | |
| 652 | + test("converts ${VAR} to ${{ secrets.VAR }}", () => { | |
| 653 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 654 | + command: "node", | |
| 655 | + args: ["server.js"], | |
| 656 | + env: { | |
| 657 | + API_KEY: "${WEATHER_API_KEY}", | |
| 658 | + PORT: "3000", | |
| 659 | + DEBUG: "${DEBUG_MODE}", | |
| 660 | + }, | |
| 661 | + }; | |
| 662 | + | |
| 663 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 664 | + "test-server", | |
| 665 | + jsonConfig, | |
| 666 | + ); | |
| 667 | + | |
| 668 | + expect(result.yamlConfig).toEqual({ | |
| 669 | + name: "test-server", | |
| 670 | + type: "stdio", | |
| 671 | + command: "node", | |
| 672 | + args: ["server.js"], | |
| 673 | + env: { | |
| 674 | + API_KEY: "${{ secrets.WEATHER_API_KEY }}", | |
| 675 | + PORT: "3000", | |
| 676 | + DEBUG: "${{ secrets.DEBUG_MODE }}", | |
| 677 | + }, | |
| 678 | + }); | |
| 679 | + }); | |
| 680 | + | |
| 681 | + test("handles multiple variables in one value", () => { | |
| 682 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 683 | + command: "node", | |
| 684 | + env: { | |
| 685 | + CONNECTION_STRING: | |
| 686 | + "postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:5432/mydb", | |
| 687 | + API_URL: "https://${API_HOST}/v1/${API_VERSION}", | |
| 688 | + }, | |
| 689 | + }; | |
| 690 | + | |
| 691 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 692 | + "test-server", | |
| 693 | + jsonConfig, | |
| 694 | + ); | |
| 695 | + | |
| 696 | + expect(result.yamlConfig).toEqual({ | |
| 697 | + name: "test-server", | |
| 698 | + type: "stdio", | |
| 699 | + command: "node", | |
| 700 | + env: { | |
| 701 | + CONNECTION_STRING: | |
| 702 | + "postgres://${{ secrets.DB_USER }}:${{ secrets.DB_PASS }}@${{ secrets.DB_HOST }}:5432/mydb", | |
| 703 | + API_URL: | |
| 704 | + "https://${{ secrets.API_HOST }}/v1/${{ secrets.API_VERSION }}", | |
| 705 | + }, | |
| 706 | + }); | |
| 707 | + }); | |
| 708 | + | |
| 709 | + test("preserves non-template values", () => { | |
| 710 | + const jsonConfig: StdioMcpJsonConfig = { | |
| 711 | + command: "node", | |
| 712 | + env: { | |
| 713 | + STATIC_VALUE: "production", | |
| 714 | + MIXED: "prefix-${DYNAMIC}-suffix", | |
| 715 | + NUMBER: "8080", | |
| 716 | + }, | |
| 717 | + }; | |
| 718 | + | |
| 719 | + const result = convertJsonMcpConfigToYamlMcpConfig( | |
| 720 | + "test-server", | |
| 721 | + jsonConfig, | |
| 722 | + ); | |
| 723 | + | |
| 724 | + expect(result.yamlConfig).toEqual({ | |
| 725 | + name: "test-server", | |
| 726 | + type: "stdio", | |
| 727 | + command: "node", | |
| 728 | + env: { | |
| 729 | + STATIC_VALUE: "production", | |
| 730 | + MIXED: "prefix-${{ secrets.DYNAMIC }}-suffix", | |
| 731 | + NUMBER: "8080", | |
| 732 | + }, | |
| 733 | + }); | |
| 734 | + }); | |
| 735 | + }); | |
| 736 | + | |
| 737 | + describe("YAML to JSON conversion", () => { | |
| 738 | + test("converts ${{ secrets.VAR }} to ${VAR}", () => { | |
| 739 | + const yamlConfig: StdioMcpServer = { | |
| 740 | + name: "test-server", | |
| 741 | + type: "stdio", | |
| 742 | + command: "node", | |
| 743 | + args: ["server.js"], | |
| 744 | + env: { | |
| 745 | + API_KEY: "${{ secrets.WEATHER_API_KEY }}", | |
| 746 | + PORT: "3000", | |
| 747 | + DEBUG: "${{ secrets.DEBUG_MODE }}", | |
| 748 | + }, | |
| 749 | + }; | |
| 750 | + | |
| 751 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 752 | + | |
| 753 | + expect(result.jsonConfig).toEqual({ | |
| 754 | + type: "stdio", | |
| 755 | + command: "node", | |
| 756 | + args: ["server.js"], | |
| 757 | + env: { | |
| 758 | + API_KEY: "${WEATHER_API_KEY}", | |
| 759 | + PORT: "3000", | |
| 760 | + DEBUG: "${DEBUG_MODE}", | |
| 761 | + }, | |
| 762 | + }); | |
| 763 | + }); | |
| 764 | + | |
| 765 | + test("converts ${{ inputs.VAR }} to ${VAR}", () => { | |
| 766 | + const yamlConfig: StdioMcpServer = { | |
| 767 | + name: "test-server", | |
| 768 | + type: "stdio", | |
| 769 | + command: "node", | |
| 770 | + env: { | |
| 771 | + USER_INPUT: "${{ inputs.USER_NAME }}", | |
| 772 | + API_KEY: "${{ inputs.API_KEY }}", | |
| 773 | + }, | |
| 774 | + }; | |
| 775 | + | |
| 776 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 777 | + | |
| 778 | + expect(result.jsonConfig).toEqual({ | |
| 779 | + type: "stdio", | |
| 780 | + command: "node", | |
| 781 | + env: { | |
| 782 | + USER_INPUT: "${USER_NAME}", | |
| 783 | + API_KEY: "${API_KEY}", | |
| 784 | + }, | |
| 785 | + }); | |
| 786 | + }); | |
| 787 | + | |
| 788 | + test("handles mixed secrets and inputs", () => { | |
| 789 | + const yamlConfig: StdioMcpServer = { | |
| 790 | + name: "test-server", | |
| 791 | + type: "stdio", | |
| 792 | + command: "node", | |
| 793 | + env: { | |
| 794 | + SECRET_KEY: "${{ secrets.API_SECRET }}", | |
| 795 | + USER_INPUT: "${{ inputs.USER_NAME }}", | |
| 796 | + MIXED: "${{ secrets.PART1 }}-${{ inputs.PART2 }}", | |
| 797 | + }, | |
| 798 | + }; | |
| 799 | + | |
| 800 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 801 | + | |
| 802 | + expect(result.jsonConfig).toEqual({ | |
| 803 | + type: "stdio", | |
| 804 | + command: "node", | |
| 805 | + env: { | |
| 806 | + SECRET_KEY: "${API_SECRET}", | |
| 807 | + USER_INPUT: "${USER_NAME}", | |
| 808 | + MIXED: "${PART1}-${PART2}", | |
| 809 | + }, | |
| 810 | + }); | |
| 811 | + }); | |
| 812 | + | |
| 813 | + test("handles whitespace in templates", () => { | |
| 814 | + const yamlConfig: StdioMcpServer = { | |
| 815 | + name: "test-server", | |
| 816 | + type: "stdio", | |
| 817 | + command: "node", | |
| 818 | + env: { | |
| 819 | + SPACED: "${{ secrets.VAR_WITH_SPACES }}", | |
| 820 | + MIXED_SPACE: "${{ secrets.VAR1 }}-${{inputs.VAR2}}", | |
| 821 | + }, | |
| 822 | + }; | |
| 823 | + | |
| 824 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 825 | + | |
| 826 | + expect(result.jsonConfig).toEqual({ | |
| 827 | + type: "stdio", | |
| 828 | + command: "node", | |
| 829 | + env: { | |
| 830 | + SPACED: "${VAR_WITH_SPACES}", | |
| 831 | + MIXED_SPACE: "${VAR1}-${VAR2}", | |
| 832 | + }, | |
| 833 | + }); | |
| 834 | + }); | |
| 835 | + | |
| 836 | + test("handles multiple variables in one value", () => { | |
| 837 | + const yamlConfig: StdioMcpServer = { | |
| 838 | + name: "test-server", | |
| 839 | + type: "stdio", | |
| 840 | + command: "node", | |
| 841 | + env: { | |
| 842 | + CONNECTION_STRING: | |
| 843 | + "postgres://${{ secrets.DB_USER }}:${{ secrets.DB_PASS }}@${{ secrets.DB_HOST }}:5432/mydb", | |
| 844 | + API_URL: | |
| 845 | + "https://${{ inputs.API_HOST }}/v1/${{ secrets.API_VERSION }}", | |
| 846 | + }, | |
| 847 | + }; | |
| 848 | + | |
| 849 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 850 | + | |
| 851 | + expect(result.jsonConfig).toEqual({ | |
| 852 | + type: "stdio", | |
| 853 | + command: "node", | |
| 854 | + env: { | |
| 855 | + CONNECTION_STRING: | |
| 856 | + "postgres://${DB_USER}:${DB_PASS}@${DB_HOST}:5432/mydb", | |
| 857 | + API_URL: "https://${API_HOST}/v1/${API_VERSION}", | |
| 858 | + }, | |
| 859 | + }); | |
| 860 | + }); | |
| 861 | + | |
| 862 | + test("preserves non-template values", () => { | |
| 863 | + const yamlConfig: StdioMcpServer = { | |
| 864 | + name: "test-server", | |
| 865 | + type: "stdio", | |
| 866 | + command: "node", | |
| 867 | + env: { | |
| 868 | + STATIC_VALUE: "production", | |
| 869 | + MIXED: "prefix-${{ secrets.DYNAMIC }}-suffix", | |
| 870 | + NUMBER: "8080", | |
| 871 | + }, | |
| 872 | + }; | |
| 873 | + | |
| 874 | + const result = convertYamlMcpConfigToJsonMcpConfig(yamlConfig); | |
| 875 | + | |
| 876 | + expect(result.jsonConfig).toEqual({ | |
| 877 | + type: "stdio", | |
| 878 | + command: "node", | |
| 879 | + env: { | |
| 880 | + STATIC_VALUE: "production", | |
| 881 | + MIXED: "prefix-${DYNAMIC}-suffix", | |
| 882 | + NUMBER: "8080", | |
| 883 | + }, | |
| 884 | + }); | |
| 885 | + }); | |
| 886 | + }); | |
| 887 | + | |
| 888 | + describe("Roundtrip conversion", () => { | |
| 889 | + test("JSON -> YAML -> JSON preserves values", () => { | |
| 890 | + const originalJson: StdioMcpJsonConfig = { | |
| 891 | + command: "node", | |
| 892 | + args: ["server.js"], | |
| 893 | + env: { | |
| 894 | + API_KEY: "${WEATHER_API_KEY}", | |
| 895 | + STATIC: "production", | |
| 896 | + COMPLEX: "prefix-${VAR1}-middle-${VAR2}-suffix", | |
| 897 | + }, | |
| 898 | + }; | |
| 899 | + | |
| 900 | + // Convert to YAML | |
| 901 | + const yamlResult = convertJsonMcpConfigToYamlMcpConfig( | |
| 902 | + "test", | |
| 903 | + originalJson, | |
| 904 | + ); | |
| 905 | + | |
| 906 | + // Convert back to JSON | |
| 907 | + const jsonResult = convertYamlMcpConfigToJsonMcpConfig( | |
| 908 | + yamlResult.yamlConfig as StdioMcpServer, | |
| 909 | + ); | |
| 910 | + | |
| 911 | + expect(jsonResult.jsonConfig).toEqual({ | |
| 912 | + type: "stdio", | |
| 913 | + command: "node", | |
| 914 | + args: ["server.js"], | |
| 915 | + env: { | |
| 916 | + API_KEY: "${WEATHER_API_KEY}", | |
| 917 | + STATIC: "production", | |
| 918 | + COMPLEX: "prefix-${VAR1}-middle-${VAR2}-suffix", | |
| 919 | + }, | |
| 920 | + }); | |
| 921 | + }); | |
| 922 | + }); | |
| 923 | +}); |
added packages/config-yaml/src/schemas/mcp/convertJson.ts +203 −0
| @@ -0,0 +1,203 @@ | ||
| 1 | +import type { | |
| 2 | + HttpMcpServer, | |
| 3 | + MCPServer, | |
| 4 | + SseMcpServer, | |
| 5 | + StdioMcpServer, | |
| 6 | +} from "./index.js"; | |
| 7 | +import type { | |
| 8 | + HttpMcpJsonConfig, | |
| 9 | + McpJsonConfig, | |
| 10 | + McpServersJsonConfigFile, | |
| 11 | + SseMcpJsonConfig, | |
| 12 | +} from "./json.js"; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * Convert environment variable references from JSON format (${VAR}) to YAML format (${{ secrets.VAR }}) | |
| 16 | + */ | |
| 17 | +export function convertJsonEnvToYamlEnv( | |
| 18 | + env: Record<string, string> | undefined, | |
| 19 | +): Record<string, string> | undefined { | |
| 20 | + if (!env) return undefined; | |
| 21 | + | |
| 22 | + return Object.fromEntries( | |
| 23 | + Object.entries(env).map(([key, value]) => [ | |
| 24 | + key, | |
| 25 | + value.replace(/\$\{([^}]+)\}/g, "${{ secrets.$1 }}"), | |
| 26 | + ]), | |
| 27 | + ); | |
| 28 | +} | |
| 29 | + | |
| 30 | +/** | |
| 31 | + * Convert environment variable references from YAML format (${{ secrets.VAR }} or ${{ inputs.VAR }}) to JSON format (${VAR}) | |
| 32 | + */ | |
| 33 | +export function convertYamlEnvToJsonEnv( | |
| 34 | + env: Record<string, string> | undefined, | |
| 35 | +): Record<string, string> | undefined { | |
| 36 | + if (!env) return undefined; | |
| 37 | + | |
| 38 | + return Object.fromEntries( | |
| 39 | + Object.entries(env).map(([key, value]) => [ | |
| 40 | + key, | |
| 41 | + value.replace(/\$\{\{\s*(?:secrets|inputs)\.([^}\s]+)\s*\}\}/g, "${$1}"), | |
| 42 | + ]), | |
| 43 | + ); | |
| 44 | +} | |
| 45 | + | |
| 46 | +/** | |
| 47 | + * Convert from JSON schema (used in Claude Desktop) to YAML schema (used in Continue) | |
| 48 | + */ | |
| 49 | +export function convertJsonMcpConfigToYamlMcpConfig( | |
| 50 | + name: string, | |
| 51 | + jsonConfig: McpJsonConfig, | |
| 52 | +): { | |
| 53 | + yamlConfig: MCPServer; | |
| 54 | + warnings: string[]; | |
| 55 | +} { | |
| 56 | + const warnings: string[] = []; | |
| 57 | + | |
| 58 | + // STDIO | |
| 59 | + if ("command" in jsonConfig) { | |
| 60 | + if (jsonConfig.envFile) { | |
| 61 | + warnings.push( | |
| 62 | + `envFile is not supported in Continue MCP config (server "${name}"). Environment variables from this file will not be used.`, | |
| 63 | + ); | |
| 64 | + } | |
| 65 | + | |
| 66 | + const stdioConfig: StdioMcpServer = { | |
| 67 | + name, | |
| 68 | + type: "stdio", | |
| 69 | + command: jsonConfig.command, | |
| 70 | + args: jsonConfig.args, | |
| 71 | + env: convertJsonEnvToYamlEnv(jsonConfig.env), | |
| 72 | + }; | |
| 73 | + return { | |
| 74 | + warnings, | |
| 75 | + yamlConfig: stdioConfig, | |
| 76 | + }; | |
| 77 | + } | |
| 78 | + | |
| 79 | + // SSE/HTTP | |
| 80 | + if ("url" in jsonConfig) { | |
| 81 | + const sseOrHttpConfig: SseMcpServer | HttpMcpServer = { | |
| 82 | + name, | |
| 83 | + url: jsonConfig.url, | |
| 84 | + }; | |
| 85 | + | |
| 86 | + if (jsonConfig.type) { | |
| 87 | + sseOrHttpConfig.type = | |
| 88 | + jsonConfig.type === "http" ? "streamable-http" : "sse"; | |
| 89 | + } | |
| 90 | + | |
| 91 | + if (jsonConfig.headers) { | |
| 92 | + sseOrHttpConfig.requestOptions = { | |
| 93 | + headers: jsonConfig.headers, | |
| 94 | + }; | |
| 95 | + } | |
| 96 | + | |
| 97 | + return { | |
| 98 | + warnings, | |
| 99 | + yamlConfig: sseOrHttpConfig, | |
| 100 | + }; | |
| 101 | + } | |
| 102 | + | |
| 103 | + throw new Error(`Invalid MCP server configuration`); | |
| 104 | +} | |
| 105 | + | |
| 106 | +/** | |
| 107 | + * Convert from YAML schema (used in Continue) to JSON schema (e.g. used in Claude Desktop) | |
| 108 | + */ | |
| 109 | +export function convertYamlMcpConfigToJsonMcpConfig(yamlConfig: MCPServer): { | |
| 110 | + name: string; | |
| 111 | + jsonConfig: McpJsonConfig; | |
| 112 | + MCP_TIMEOUT?: string; | |
| 113 | + warnings: string[]; | |
| 114 | +} { | |
| 115 | + const { name, faviconUrl } = yamlConfig; | |
| 116 | + | |
| 117 | + const warnings: string[] = []; | |
| 118 | + if (faviconUrl) { | |
| 119 | + warnings.push( | |
| 120 | + `\`faviconUrl\` from YAML MCP config not supported in Claude-style JSON, will be removed from server ${name}`, | |
| 121 | + ); | |
| 122 | + } | |
| 123 | + | |
| 124 | + // Claude uses MCP_TIMEOUT env variable rather than a configuration for stdio | |
| 125 | + const MCP_TIMEOUT = yamlConfig.connectionTimeout?.toString(); | |
| 126 | + | |
| 127 | + // STDIO | |
| 128 | + if ("command" in yamlConfig) { | |
| 129 | + const { command, args, env, cwd } = yamlConfig; | |
| 130 | + | |
| 131 | + if (cwd) { | |
| 132 | + warnings.push( | |
| 133 | + `\`cwd\` from YAML MCP config not supported in Claude-style JSON, will be removed from server ${name}`, | |
| 134 | + ); | |
| 135 | + } | |
| 136 | + | |
| 137 | + return { | |
| 138 | + name, | |
| 139 | + MCP_TIMEOUT, | |
| 140 | + warnings, | |
| 141 | + jsonConfig: { | |
| 142 | + type: "stdio", | |
| 143 | + command, | |
| 144 | + args, | |
| 145 | + env: convertYamlEnvToJsonEnv(env), | |
| 146 | + }, | |
| 147 | + }; | |
| 148 | + } | |
| 149 | + | |
| 150 | + // SSE/HTTP | |
| 151 | + if ("url" in yamlConfig) { | |
| 152 | + const { url, requestOptions } = yamlConfig; | |
| 153 | + | |
| 154 | + const { headers, ...unsupportedReqOptions } = requestOptions ?? {}; | |
| 155 | + for (const key of Object.keys(unsupportedReqOptions)) { | |
| 156 | + warnings.push( | |
| 157 | + `${key} requestOption from YAML MCP config not supported in Claude-style JSON, will be ignored in server ${name}`, | |
| 158 | + ); | |
| 159 | + } | |
| 160 | + | |
| 161 | + const httpOrSseJsonConfig: HttpMcpJsonConfig | SseMcpJsonConfig = { | |
| 162 | + url, | |
| 163 | + headers, | |
| 164 | + }; | |
| 165 | + | |
| 166 | + if (yamlConfig.type) { | |
| 167 | + httpOrSseJsonConfig.type = | |
| 168 | + yamlConfig.type === "streamable-http" ? "http" : "sse"; | |
| 169 | + } | |
| 170 | + | |
| 171 | + return { | |
| 172 | + name, | |
| 173 | + warnings, | |
| 174 | + jsonConfig: httpOrSseJsonConfig, | |
| 175 | + MCP_TIMEOUT, | |
| 176 | + }; | |
| 177 | + } | |
| 178 | + | |
| 179 | + throw new Error(`Invalid MCP server configuration`); | |
| 180 | +} | |
| 181 | + | |
| 182 | +export function converMcpServersJsonConfigFileToYamlBlocks( | |
| 183 | + jsonFile: McpServersJsonConfigFile, | |
| 184 | +): { | |
| 185 | + yamlConfigs: MCPServer[]; | |
| 186 | + warnings: string[]; | |
| 187 | +} { | |
| 188 | + const allWarnings: string[] = []; | |
| 189 | + const jsonEntries = Object.entries(jsonFile.mcpServers ?? {}); | |
| 190 | + const yamlConfigs = jsonEntries.map(([name, config]) => { | |
| 191 | + const { warnings, yamlConfig } = convertJsonMcpConfigToYamlMcpConfig( | |
| 192 | + name, | |
| 193 | + config, | |
| 194 | + ); | |
| 195 | + allWarnings.push(...warnings); | |
| 196 | + return yamlConfig; | |
| 197 | + }); | |
| 198 | + | |
| 199 | + return { | |
| 200 | + warnings: allWarnings, | |
| 201 | + yamlConfigs, | |
| 202 | + }; | |
| 203 | +} |
added packages/config-yaml/src/schemas/mcp/index.ts +38 −0
| @@ -0,0 +1,38 @@ | ||
| 1 | +import z from "zod"; | |
| 2 | +import { requestOptionsSchema } from "../../schemas/models.js"; | |
| 3 | + | |
| 4 | +const baseMcpServerSchema = z.object({ | |
| 5 | + name: z.string(), | |
| 6 | + faviconUrl: z.string().optional(), | |
| 7 | + sourceFile: z.string().optional(), // Added during loading | |
| 8 | + connectionTimeout: z.number().gt(0).optional(), | |
| 9 | +}); | |
| 10 | + | |
| 11 | +const stdioMcpServerSchema = baseMcpServerSchema.extend({ | |
| 12 | + command: z.string(), | |
| 13 | + type: z.literal("stdio").optional(), | |
| 14 | + args: z.array(z.string()).optional(), | |
| 15 | + env: z.record(z.string()).optional(), | |
| 16 | + cwd: z.string().optional(), | |
| 17 | +}); | |
| 18 | +export type StdioMcpServer = z.infer<typeof stdioMcpServerSchema>; | |
| 19 | + | |
| 20 | +const sseOrHttpMcpServerSchema = baseMcpServerSchema.extend({ | |
| 21 | + url: z.string(), // .url() fails with e.g. IP addresses | |
| 22 | + type: z.union([z.literal("sse"), z.literal("streamable-http")]).optional(), | |
| 23 | + requestOptions: requestOptionsSchema.optional(), | |
| 24 | +}); | |
| 25 | +export type SseMcpServer = z.infer<typeof sseOrHttpMcpServerSchema>; | |
| 26 | +export type HttpMcpServer = z.infer<typeof sseOrHttpMcpServerSchema>; | |
| 27 | + | |
| 28 | +export const mcpServerSchema = z.union([ | |
| 29 | + stdioMcpServerSchema, | |
| 30 | + sseOrHttpMcpServerSchema, | |
| 31 | +]); | |
| 32 | +export type MCPServer = z.infer<typeof mcpServerSchema>; | |
| 33 | + | |
| 34 | +export const partialMcpServerSchema = z.union([ | |
| 35 | + stdioMcpServerSchema.partial(), | |
| 36 | + sseOrHttpMcpServerSchema.partial(), | |
| 37 | +]); | |
| 38 | +export type PartialMCPServer = z.infer<typeof partialMcpServerSchema>; |
added packages/config-yaml/src/schemas/mcp/json.ts +51 −0
| @@ -0,0 +1,51 @@ | ||
| 1 | +import z from "zod"; | |
| 2 | + | |
| 3 | +// This is the schema for an entry in e.g. Claude Desktop, Claude code mcp config | |
| 4 | +const 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 | +}); | |
| 9 | +export type HttpMcpJsonConfig = z.infer<typeof httpOrSseMcpJsonSchema>; | |
| 10 | +export type SseMcpJsonConfig = z.infer<typeof httpOrSseMcpJsonSchema>; | |
| 11 | + | |
| 12 | +const 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 | +}); | |
| 19 | +export type StdioMcpJsonConfig = z.infer<typeof stdioMcpJsonSchema>; | |
| 20 | + | |
| 21 | +export const mcpServersJsonSchema = z.union([ | |
| 22 | + httpOrSseMcpJsonSchema, | |
| 23 | + stdioMcpJsonSchema, | |
| 24 | +]); | |
| 25 | +export type McpJsonConfig = z.infer<typeof mcpServersJsonSchema>; | |
| 26 | + | |
| 27 | +export const mcpServersRecordSchema = z.record( | |
| 28 | + z.string(), | |
| 29 | + mcpServersJsonSchema, | |
| 30 | +); | |
| 31 | +export type McpServersJsonConfigRecord = z.infer<typeof mcpServersRecordSchema>; | |
| 32 | + | |
| 33 | +export const claudeDesktopLikeConfigFileSchema = z.object({ | |
| 34 | + mcpServers: mcpServersRecordSchema, | |
| 35 | +}); | |
| 36 | +export type McpServersJsonConfigFile = z.infer< | |
| 37 | + typeof claudeDesktopLikeConfigFileSchema | |
| 38 | +>; | |
| 39 | + | |
| 40 | +export 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 | +}); | |
| 49 | +export type claudeCodeLikeConfigFileSchema = z.infer< | |
| 50 | + typeof claudeCodeLikeConfigFileSchema | |
| 51 | +>; |
modified packages/continue-sdk/package-lock.json +1 −1
| @@ -20,7 +20,7 @@ | ||
| 20 | 20 | }, |
| 21 | 21 | "../config-yaml": { |
| 22 | 22 | "name": "@continuedev/config-yaml", |
| 23 | - "version": "1.17.0", | |
| 23 | + "version": "1.23.0", | |
| 24 | 24 | "license": "Apache-2.0", |
| 25 | 25 | "dependencies": { |
| 26 | 26 | "@continuedev/config-types": "^1.0.14", |
modified packages/llm-info/package-lock.json +2 −2
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | { |
| 2 | 2 | "name": "@continuedev/llm-info", |
| 3 | - "version": "1.0.9", | |
| 3 | + "version": "1.0.10", | |
| 4 | 4 | "lockfileVersion": 3, |
| 5 | 5 | "requires": true, |
| 6 | 6 | "packages": { |
| 7 | 7 | "": { |
| 8 | 8 | "name": "@continuedev/llm-info", |
| 9 | - "version": "1.0.9", | |
| 9 | + "version": "1.0.10", | |
| 10 | 10 | "license": "Apache-2.0", |
| 11 | 11 | "devDependencies": { |
| 12 | 12 | "@semantic-release/changelog": "^6.0.3", |