From 48f169602f38b958c66073760aabdde94799cdc8 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Fri, 9 May 2025 19:09:12 +0530 Subject: [PATCH 1/4] error message when mcp arg has unsubstited variable --- core/config/yaml/loadYaml.ts | 13 ++++++++++++- core/util/index.ts | 5 +++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 95a4bdc30..b7296a5b2 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -40,6 +40,7 @@ import { GlobalContext } from "../../util/GlobalContext"; import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; +import { getMCPArgsWithVariables } from "../../util"; import { logger } from "../../util/logger"; import { getCleanUriPath } from "../../util/uri"; import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; @@ -72,7 +73,7 @@ function convertYamlMcpToContinueMcp( args: server.args ?? [], env: server.env, }, - timeout: server.connectionTimeout + timeout: server.connectionTimeout, }; } @@ -241,6 +242,16 @@ async function configYamlToContinueConfig(options: { rootUrl: doc.rootUrl, faviconUrl: doc.faviconUrl, })); + + config.mcpServers?.forEach(mcpServer => { + const mcpArgVariables = getMCPArgsWithVariables(mcpServer.args ?? []); + if(mcpArgVariables.length === 0) return; + localErrors.push({ + fatal: false, + message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}`, + }); + }) + continueConfig.experimental = { modelContextProtocolServers: config.mcpServers?.map( convertYamlMcpToContinueMcp, diff --git a/core/util/index.ts b/core/util/index.ts index 196104f4f..e1ed1f5ed 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -211,3 +211,8 @@ export function splitCamelCaseAndNonAlphaNumeric(value: string) { .filter(t => t.length > 0) .map(t => t.toLowerCase()); } + +export function getMCPArgsWithVariables(args: string[]) { + const isVariableRegex = /\$\{\{ (.*?) \}\}/; + return args.filter((arg) => isVariableRegex.test(arg)); +} From 2933f9b59fe38ddc665f05ef0d999379d62f9092 Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Sun, 11 May 2025 19:37:21 +0530 Subject: [PATCH 2/4] use `TEMPLATE_VAR_REGEX` --- core/config/yaml/loadYaml.ts | 4 ++-- core/util/index.ts | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index b7296a5b2..75521b1c4 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -9,6 +9,7 @@ import { PackageIdentifier, RegistryClient, Rule, + TEMPLATE_VAR_REGEX, unrollAssistant, validateConfigYaml, } from "@continuedev/config-yaml"; @@ -40,7 +41,6 @@ import { GlobalContext } from "../../util/GlobalContext"; import { modifyAnyConfigWithSharedConfig } from "../sharedConfig"; import { getControlPlaneEnvSync } from "../../control-plane/env"; -import { getMCPArgsWithVariables } from "../../util"; import { logger } from "../../util/logger"; import { getCleanUriPath } from "../../util/uri"; import { getAllDotContinueYamlFiles } from "../loadLocalAssistants"; @@ -244,7 +244,7 @@ async function configYamlToContinueConfig(options: { })); config.mcpServers?.forEach(mcpServer => { - const mcpArgVariables = getMCPArgsWithVariables(mcpServer.args ?? []); + const mcpArgVariables = mcpServer.args?.filter(arg=> TEMPLATE_VAR_REGEX.test(arg)) ?? [] if(mcpArgVariables.length === 0) return; localErrors.push({ fatal: false, diff --git a/core/util/index.ts b/core/util/index.ts index e1ed1f5ed..196104f4f 100644 --- a/core/util/index.ts +++ b/core/util/index.ts @@ -211,8 +211,3 @@ export function splitCamelCaseAndNonAlphaNumeric(value: string) { .filter(t => t.length > 0) .map(t => t.toLowerCase()); } - -export function getMCPArgsWithVariables(args: string[]) { - const isVariableRegex = /\$\{\{ (.*?) \}\}/; - return args.filter((arg) => isVariableRegex.test(arg)); -} From 6777b9268df4c86fe0dc778267fff308cafda73f Mon Sep 17 00:00:00 2001 From: uinstinct <61635505+uinstinct@users.noreply.github.com> Date: Sun, 11 May 2025 19:42:46 +0530 Subject: [PATCH 3/4] update error message --- core/config/yaml/loadYaml.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 75521b1c4..8f7f512af 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -248,7 +248,7 @@ async function configYamlToContinueConfig(options: { if(mcpArgVariables.length === 0) return; localErrors.push({ fatal: false, - message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}`, + message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}. Please refer https://docs.continue.dev/hub/secrets/secret-types for managing hub secrets.`, }); }) From 53d1c554f7f0f19d1a127b823466e8461cd3c678 Mon Sep 17 00:00:00 2001 From: Patrick Erichsen Date: Mon, 12 May 2025 14:22:10 -0700 Subject: [PATCH 4/4] Update loadYaml.ts --- core/config/yaml/loadYaml.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/config/yaml/loadYaml.ts b/core/config/yaml/loadYaml.ts index 8f7f512af..e667415d2 100644 --- a/core/config/yaml/loadYaml.ts +++ b/core/config/yaml/loadYaml.ts @@ -243,14 +243,19 @@ async function configYamlToContinueConfig(options: { faviconUrl: doc.faviconUrl, })); - config.mcpServers?.forEach(mcpServer => { - const mcpArgVariables = mcpServer.args?.filter(arg=> TEMPLATE_VAR_REGEX.test(arg)) ?? [] - if(mcpArgVariables.length === 0) return; + config.mcpServers?.forEach((mcpServer) => { + const mcpArgVariables = + mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? []; + + if (mcpArgVariables.length === 0) { + return; + } + localErrors.push({ fatal: false, - message: `MCP server "${mcpServer.name}" has unsubstituted variables in args: ${mcpArgVariables.join(", ")}. Please refer https://docs.continue.dev/hub/secrets/secret-types for managing hub secrets.`, + 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.`, }); - }) + }); continueConfig.experimental = { modelContextProtocolServers: config.mcpServers?.map( @@ -456,7 +461,7 @@ async function configYamlToContinueConfig(options: { args: [], ...server, }, - timeout: server.connectionTimeout + timeout: server.connectionTimeout, })), false, );