Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .continue/mcpServers/DeepWiki.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"type": [
"hi",
"hello",
{
"hi": "hello",
"val2": "val3"
}
],
"url": "https://mcp.deepwiki.com/mcp"
}
Empty file added .continue/mcpServers/hello.yaml
Empty file.
32 changes: 22 additions & 10 deletions core/config/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import path from "path";
import {
ConfigResult,
ConfigValidationError,
mergeConfigYamlRequestOptions,
ModelRole,
} from "@continuedev/config-yaml";
import * as JSONC from "comment-json";
Expand All @@ -25,6 +26,7 @@ import {
IdeType,
ILLM,
ILLMLogger,
InternalMcpOptions,
LLMOptions,
ModelDescription,
RerankerDescription,
Expand Down Expand Up @@ -57,8 +59,9 @@ import {
} from "../util/paths";
import { localPathToUri } from "../util/pathToUri";

import { PolicySingleton } from "../control-plane/PolicySingleton";
import { loadJsonMcpConfigs } from "../context/mcp/json/loadJsonMcpConfigs";
import CustomContextProviderClass from "../context/providers/CustomContextProvider";
import { PolicySingleton } from "../control-plane/PolicySingleton";
import { getBaseToolDefinitions } from "../tools";
import { resolveRelativePathInDir } from "../util/ideUtils";
import { getWorkspaceRcConfigs } from "./json/loadRcConfigs";
Expand Down Expand Up @@ -550,17 +553,26 @@ async function intermediateToFinalConfig({
if (orgPolicy?.policy?.allowMcpServers === false) {
await mcpManager.shutdown();
} else {
mcpManager.setConnections(
(config.experimental?.modelContextProtocolServers ?? []).map(
(server, index) => ({
id: `continue-mcp-server-${index + 1}`,
name: `MCP Server`,
...server,
requestOptions: config.requestOptions,
}),
const mcpOptions: InternalMcpOptions[] = (
config.experimental?.modelContextProtocolServers ?? []
).map((server, index) => ({
id: `continue-mcp-server-${index + 1}`,
name: `MCP Server`,
requestOptions: mergeConfigYamlRequestOptions(
server.transport.type !== "stdio"
? server.transport.requestOptions
: undefined,
config.requestOptions,
),
false,
...server.transport,
}));
const { errors: jsonMcpErrors, mcpServers } = await loadJsonMcpConfigs(
ide,
true,
);
errors.push(...jsonMcpErrors);
mcpOptions.push(...mcpServers);
mcpManager.setConnections(mcpOptions, false);
}

// Handle experimental modelRole config values for apply and edit
Expand Down
1 change: 1 addition & 0 deletions core/config/profile/doLoadConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ async function loadRules(ide: IDE) {

return { rules, errors };
}

export default async function doLoadConfig(options: {
ide: IDE;
controlPlaneClient: ControlPlaneClient;
Expand Down
63 changes: 34 additions & 29 deletions core/config/yaml/loadYaml.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ import {
} from "@continuedev/config-yaml";
import { dirname } from "node:path";

import { ContinueConfig, IDE, IdeInfo, IdeSettings, ILLMLogger } from "../..";
import {
ContinueConfig,
IDE,
IdeInfo,
IdeSettings,
ILLMLogger,
InternalMcpOptions,
} from "../..";
import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
import { ControlPlaneClient } from "../../control-plane/client";
import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
Expand All @@ -25,6 +32,7 @@ import { modifyAnyConfigWithSharedConfig } from "../sharedConfig";

import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand";
import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand";
import { loadJsonMcpConfigs } from "../../context/mcp/json/loadJsonMcpConfigs";
import { getControlPlaneEnvSync } from "../../control-plane/env";
import { PolicySingleton } from "../../control-plane/PolicySingleton";
import { getBaseToolDefinitions } from "../../tools";
Expand All @@ -34,7 +42,10 @@ import { getAllDotContinueDefinitionFiles } from "../loadLocalAssistants";
import { unrollLocalYamlBlocks } from "./loadLocalYamlBlocks";
import { LocalPlatformClient } from "./LocalPlatformClient";
import { llmsFromModelConfig } from "./models";
import { convertYamlRuleToContinueRule } from "./yamlToContinueConfig";
import {
convertYamlMcpConfigToInternalMcpOptions,
convertYamlRuleToContinueRule,
} from "./yamlToContinueConfig";

async function loadConfigYaml(options: {
overrideConfigYaml: AssistantUnrolled | undefined;
Expand Down Expand Up @@ -227,17 +238,19 @@ export async function configYamlToContinueConfig(options: {
}));

config.mcpServers?.forEach((mcpServer) => {
const mcpArgVariables =
mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? [];
if ("args" in mcpServer) {
const mcpArgVariables =
mcpServer.args?.filter((arg) => TEMPLATE_VAR_REGEX.test(arg)) ?? [];

if (mcpArgVariables.length === 0) {
return;
}
if (mcpArgVariables.length === 0) {
return;
}

localErrors.push({
fatal: false,
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.`,
});
localErrors.push({
fatal: false,
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.`,
});
}
});

// Prompt files -
Expand Down Expand Up @@ -381,25 +394,17 @@ export async function configYamlToContinueConfig(options: {
if (orgPolicy?.policy?.allowMcpServers === false) {
await mcpManager.shutdown();
} else {
mcpManager.setConnections(
(config.mcpServers ?? []).map((server) => ({
id: server.name,
name: server.name,
sourceFile: server.sourceFile,
transport: {
type: "stdio",
args: [],
requestOptions: mergeConfigYamlRequestOptions(
server.requestOptions,
config.requestOptions,
),
...(server as any), // TODO: fix the types on mcpServers in config-yaml
},
timeout: server.connectionTimeout,
})),
false,
{ ide },
const mcpOptions: InternalMcpOptions[] = (config.mcpServers ?? []).map(
(server) =>
convertYamlMcpConfigToInternalMcpOptions(server, config.requestOptions),
);
const { errors: jsonMcpErrors, mcpServers } = await loadJsonMcpConfigs(
ide,
true,
);
localErrors.push(...jsonMcpErrors);
mcpOptions.push(...mcpServers);
mcpManager.setConnections(mcpOptions, false, { ide });
}

return { config: continueConfig, errors: localErrors };
Expand Down
65 changes: 51 additions & 14 deletions core/config/yaml/yamlToContinueConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import { MCPServer, Rule } from "@continuedev/config-yaml";
import { ExperimentalMCPOptions, RuleWithSource } from "../..";
import {
MCPServer,
mergeConfigYamlRequestOptions,
RequestOptions,
Rule,
} from "@continuedev/config-yaml";
import {
InternalMcpOptions,
InternalSseMcpOptions,
InternalStdioMcpOptions,
InternalStreamableHttpMcpOptions,
RuleWithSource,
} from "../..";

export function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource {
if (typeof rule === "string") {
Expand All @@ -21,17 +32,43 @@ export function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource {
}
}

export function convertYamlMcpToContinueMcp(
server: MCPServer,
): ExperimentalMCPOptions {
return {
transport: {
type: "stdio",
command: server.command,
args: server.args ?? [],
env: server.env,
cwd: server.cwd,
} as any, // TODO: Fix the mcpServers types in config-yaml (discriminated union)
timeout: server.connectionTimeout,
export function convertYamlMcpConfigToInternalMcpOptions(
config: MCPServer,
globalRequestOptions?: RequestOptions,
): InternalMcpOptions {
const { connectionTimeout, faviconUrl, name, sourceFile } = config;
const shared = {
id: name,
name,
faviconUrl: faviconUrl,
timeout: connectionTimeout,
sourceFile,
};
// Stdio
if ("command" in config) {
const { args, command, cwd, env, type } = config;
const stdioOptions: InternalStdioMcpOptions = {
type,
command,
args,
cwd,
env,
...shared,
};
return stdioOptions;
}
// HTTP/SSE
const { type, url, requestOptions } = config;
const httpSseConfig:
| InternalStreamableHttpMcpOptions
| InternalSseMcpOptions = {
type,
url,
requestOptions: mergeConfigYamlRequestOptions(
requestOptions,
globalRequestOptions,
),
...shared,
};
return httpSseConfig;
}
Loading
Loading