Elffuss BraidHub

kikocis/continue public

Merge branch 'main' of https://github.com/continuedev/continue into dependabot/npm_and_yarn/binary/tar-fs-2.1.4
Changeset2fb75447cc67c7e1b6b80d71ba005d23c9695f2765596a3d8ecb7c02914dd26d
AuthorDallin Romney <dallinromney@gmail.com> · 2025-09-26 14:27 -07:00
CommitterDallin Romney <dallinromney@gmail.com> · 2025-09-26 14:27 -07:00
Parentsafa71ef33564, 4d8ba150996e

Browse the files at this changeset

33 files changed

modified core/config/load.ts +23 −10
@@ -6,6 +6,7 @@
66 import {
77 ConfigResult,
88 ConfigValidationError,
9+ mergeConfigYamlRequestOptions,
910 ModelRole,
1011 } from "@continuedev/config-yaml";
1112 import * as JSONC from "comment-json";
@@ -25,6 +26,7 @@
2526 IdeType,
2627 ILLM,
2728 ILLMLogger,
29+ InternalMcpOptions,
2830 LLMOptions,
2931 ModelDescription,
3032 RerankerDescription,
@@ -57,8 +59,9 @@
5759 } from "../util/paths";
5860 import { localPathToUri } from "../util/pathToUri";
5961
60-import { PolicySingleton } from "../control-plane/PolicySingleton";
62+import { loadJsonMcpConfigs } from "../context/mcp/json/loadJsonMcpConfigs";
6163 import CustomContextProviderClass from "../context/providers/CustomContextProvider";
64+import { PolicySingleton } from "../control-plane/PolicySingleton";
6265 import { getBaseToolDefinitions } from "../tools";
6366 import { resolveRelativePathInDir } from "../util/ideUtils";
6467 import { getWorkspaceRcConfigs } from "./json/loadRcConfigs";
@@ -550,17 +553,27 @@
550553 if (orgPolicy?.policy?.allowMcpServers === false) {
551554 await mcpManager.shutdown();
552555 } 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,
561566 ),
562- false,
567+ ...server.transport,
568+ }));
569+ const { errors: jsonMcpErrors, mcpServers } = await loadJsonMcpConfigs(
570+ ide,
571+ true,
572+ config.requestOptions,
563573 );
574+ errors.push(...jsonMcpErrors);
575+ mcpOptions.push(...mcpServers);
576+ mcpManager.setConnections(mcpOptions, false);
564577 }
565578
566579 // 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";
12 import ignore from "ignore";
23 import * as URI from "uri-js";
34 import { IDE } from "..";
@@ -6,12 +7,32 @@
67 DEFAULT_IGNORE_FILETYPES,
78 } from "../indexing/ignore";
89 import { walkDir } from "../indexing/walkDir";
10+import { RULES_MARKDOWN_FILENAME } from "../llm/rules/constants";
911 import { getGlobalFolderWithName } from "../util/paths";
1012 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+}
1232
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) {
1536 return false;
1637 }
1738
@@ -22,6 +43,10 @@
2243 );
2344 }
2445
46+export function isColocatedRulesFile(uri: string): boolean {
47+ return getUriPathBasename(uri) === RULES_MARKDOWN_FILENAME;
48+}
49+
2550 async function getDefinitionFilesInDir(
2651 ide: IDE,
2752 dir: string,
modified core/config/yaml/loadYaml.ts +36 −30
@@ -15,7 +15,14 @@
1515 } from "@continuedev/config-yaml";
1616 import { dirname } from "node:path";
1717
18-import { ContinueConfig, IDE, IdeInfo, IdeSettings, ILLMLogger } from "../..";
18+import {
19+ ContinueConfig,
20+ IDE,
21+ IdeInfo,
22+ IdeSettings,
23+ ILLMLogger,
24+ InternalMcpOptions,
25+} from "../..";
1926 import { MCPManagerSingleton } from "../../context/mcp/MCPManagerSingleton";
2027 import { ControlPlaneClient } from "../../control-plane/client";
2128 import TransformersJsEmbeddingsProvider from "../../llm/llms/TransformersJsEmbeddingsProvider";
@@ -25,6 +32,7 @@
2532
2633 import { convertPromptBlockToSlashCommand } from "../../commands/slash/promptBlockSlashCommand";
2734 import { slashCommandFromPromptFile } from "../../commands/slash/promptFileSlashCommand";
35+import { loadJsonMcpConfigs } from "../../context/mcp/json/loadJsonMcpConfigs";
2836 import { getControlPlaneEnvSync } from "../../control-plane/env";
2937 import { PolicySingleton } from "../../control-plane/PolicySingleton";
3038 import { getBaseToolDefinitions } from "../../tools";
@@ -34,7 +42,10 @@
3442 import { unrollLocalYamlBlocks } from "./loadLocalYamlBlocks";
3543 import { LocalPlatformClient } from "./LocalPlatformClient";
3644 import { llmsFromModelConfig } from "./models";
37-import { convertYamlRuleToContinueRule } from "./yamlToContinueConfig";
45+import {
46+ convertYamlMcpConfigToInternalMcpOptions,
47+ convertYamlRuleToContinueRule,
48+} from "./yamlToContinueConfig";
3849
3950 async function loadConfigYaml(options: {
4051 overrideConfigYaml: AssistantUnrolled | undefined;
@@ -227,17 +238,19 @@
227238 }));
228239
229240 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+ }
236248
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+ }
241254 });
242255
243256 // Prompt files -
@@ -381,25 +394,18 @@
381394 if (orgPolicy?.policy?.allowMcpServers === false) {
382395 await mcpManager.shutdown();
383396 } 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,
402405 );
406+ localErrors.push(...jsonMcpErrors);
407+ mcpOptions.push(...mcpServers);
408+ mcpManager.setConnections(mcpOptions, false, { ide });
403409 }
404410
405411 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 "../..";
314
415 export function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource {
516 if (typeof rule === "string") {
@@ -21,17 +32,43 @@
2132 }
2233 }
2334
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,
3646 };
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;
3774 }
modified core/context/mcp/MCPConnection.ts +162 −111
@@ -10,8 +10,12 @@
1010 import { Agent as HttpsAgent } from "https";
1111 import {
1212 IDE,
13+ InternalMcpOptions,
14+ InternalSseMcpOptions,
15+ InternalStdioMcpOptions,
16+ InternalStreamableHttpMcpOptions,
17+ InternalWebsocketMcpOptions,
1318 MCPConnectionStatus,
14- MCPOptions,
1519 MCPPrompt,
1620 MCPResource,
1721 MCPResourceTemplate,
@@ -65,7 +69,7 @@
6569 };
6670
6771 constructor(
68- public options: MCPOptions,
72+ public options: InternalMcpOptions,
6973 public extras?: MCPExtras,
7074 ) {
7175 // Don't construct transport in constructor to avoid blocking
@@ -132,20 +136,20 @@
132136 this.abortController = new AbortController();
133137
134138 // 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 = {
138142 headers: {},
139143 };
140144 }
141145 const accessToken = await getOauthToken(
142- this.options.transport.url,
146+ this.options.url,
143147 this.extras?.ide!,
144148 );
145149 if (accessToken) {
146150 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,
149153 Authorization: `Bearer ${accessToken}`,
150154 };
151155 }
@@ -178,22 +182,71 @@
178182 });
179183 }),
180184 (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+ );
195228 } 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+ }
197250 }
198251 }
199252
@@ -202,7 +255,6 @@
202255 // this.client.setNotificationHandler(, notification => {
203256 // console.log(notification)
204257 // })
205-
206258 const capabilities = this.client.getServerCapabilities();
207259
208260 // Resources <—> Context Provider
@@ -305,7 +357,7 @@
305357
306358 // Include stdio output if available for stdio transport
307359 if (
308- this.options.transport.type === "stdio" &&
360+ this.options.type === "stdio" &&
309361 (this.stdioOutput.stdout || this.stdioOutput.stderr)
310362 ) {
311363 errorMessage += "\n\nProcess output:";
@@ -356,98 +408,97 @@
356408 };
357409 }
358410
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+ }
384416
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+ }
390443
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+ }
398460
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 } : {};
400465
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;
404469
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+ }
450481 }
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;
451502 }
452503 }
453504
modified core/context/mcp/MCPConnection.vitest.ts +51 −65
@@ -1,5 +1,10 @@
11 import { Client } from "@modelcontextprotocol/sdk/client/index.js";
22 import { beforeEach, describe, expect, it, vi } from "vitest";
3+import {
4+ InternalSseMcpOptions,
5+ InternalStdioMcpOptions,
6+ InternalWebsocketMcpOptions,
7+} from "../..";
38 import MCPConnection from "./MCPConnection";
49
510 // Mock the shell path utility
@@ -16,15 +21,13 @@
1621
1722 describe("constructor", () => {
1823 it("should create instance with stdio transport", () => {
19- const options = {
24+ const options: InternalStdioMcpOptions = {
2025 name: "test-mcp",
2126 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" },
2831 };
2932
3033 const conn = new MCPConnection(options);
@@ -33,34 +36,30 @@
3336 });
3437
3538 it("should create instance with stdio transport including cwd", () => {
36- const options = {
39+ const options: InternalStdioMcpOptions = {
3740 name: "test-mcp",
3841 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",
4647 };
4748
4849 const conn = new MCPConnection(options);
4950 expect(conn).toBeInstanceOf(MCPConnection);
5051 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");
5354 }
5455 });
5556
5657 it("should create instance with websocket transport", () => {
57- const options = {
58+ const options: InternalWebsocketMcpOptions = {
5859 name: "test-mcp",
5960 id: "test-id",
60- transport: {
61- type: "websocket" as const,
62- url: "ws://test.com",
63- },
61+ type: "websocket",
62+ url: "ws://test.com",
6463 };
6564
6665 const conn = new MCPConnection(options);
@@ -69,13 +68,11 @@
6968 });
7069
7170 it("should create instance with SSE transport", () => {
72- const options = {
71+ const options: InternalSseMcpOptions = {
7372 name: "test-mcp",
7473 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",
7976 };
8077
8178 const conn = new MCPConnection(options);
@@ -84,17 +81,15 @@
8481 });
8582
8683 it("should create instance with SSE transport and custom headers", () => {
87- const options = {
84+ const options: InternalSseMcpOptions = {
8885 name: "test-mcp",
8986 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",
9893 },
9994 },
10095 };
@@ -108,9 +103,8 @@
108103 const options = {
109104 name: "test-mcp",
110105 id: "test-id",
111- transport: {
112- type: "invalid",
113- } as any,
106+ type: "invalid" as any,
107+ url: "",
114108 };
115109
116110 const conn = new MCPConnection(options);
@@ -126,14 +120,12 @@
126120
127121 describe("getStatus", () => {
128122 it("should return current status", () => {
129- const options = {
123+ const options: InternalStdioMcpOptions = {
130124 name: "test-mcp",
131125 id: "test-id",
132- transport: {
133- type: "stdio" as const,
134- command: "test",
135- args: [],
136- },
126+ type: "stdio",
127+ command: "test",
128+ args: [],
137129 };
138130
139131 const conn = new MCPConnection(options);
@@ -154,14 +146,12 @@
154146 });
155147
156148 describe("connectClient", () => {
157- const options = {
149+ const options: InternalStdioMcpOptions = {
158150 name: "test-mcp",
159151 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: [],
165155 };
166156
167157 it("should connect successfully", async () => {
@@ -282,17 +272,15 @@
282272 vi.restoreAllMocks();
283273
284274 // Use a command that will definitely fail and produce stderr output
285- const failingOptions = {
275+ const failingOptions: InternalStdioMcpOptions = {
286276 name: "failing-mcp",
287277 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+ ],
296284 timeout: 5000, // Give enough time for the command to run and fail
297285 };
298286
@@ -315,11 +303,9 @@
315303 const conn = new MCPConnection({
316304 id: "filesystem",
317305 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", "."],
323309 });
324310
325311 try {
modified core/context/mcp/MCPManagerSingleton.ts +20 −27
@@ -1,11 +1,6 @@
11 import { Client } from "@modelcontextprotocol/sdk/client/index.js";
22
3-import {
4- MCPOptions,
5- MCPServerStatus,
6- StdioOptions,
7- TransportOptions,
8-} from "../..";
3+import { InternalMcpOptions, MCPServerStatus } from "../..";
94 import MCPConnection, { MCPExtras } from "./MCPConnection";
105
116 export class MCPManagerSingleton {
@@ -38,7 +33,7 @@
3833 return this.disconnectedServers;
3934 }
4035
41- createConnection(id: string, options: MCPOptions): MCPConnection {
36+ createConnection(id: string, options: InternalMcpOptions): MCPConnection {
4237 if (this.connections.has(id)) {
4338 return this.connections.get(id)!;
4439 } else {
@@ -77,7 +72,7 @@
7772 }
7873
7974 setConnections(
80- servers: MCPOptions[],
75+ servers: InternalMcpOptions[],
8176 forceRefresh: boolean,
8277 extras?: MCPExtras,
8378 ) {
@@ -89,11 +84,7 @@
8984 !servers.find(
9085 // Refresh the connection if TransportOptions changed
9186 (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),
9788 )
9889 ) {
9990 refresh = true;
@@ -124,33 +115,35 @@
124115 }
125116
126117 private compareTransportOptions(
127- a: TransportOptions,
128- b: TransportOptions,
118+ a: InternalMcpOptions,
119+ b: InternalMcpOptions,
129120 ): boolean {
130121 if (a.type !== b.type) {
131122 return false;
132123 }
133- if (a.type === "stdio" && b.type === "stdio") {
124+ if ("command" in a && "command" in b) {
134125 return (
135126 a.command === b.command &&
136127 JSON.stringify(a.args) === JSON.stringify(b.args) &&
137- this.compareEnv(a, b)
128+ this.compareEnv(a.env, b.env)
138129 );
139- } else if (a.type !== "stdio" && b.type !== "stdio") {
130+ } else if ("url" in a && "url" in b) {
140131 return a.url === b.url;
141132 }
142133 return false;
143134 }
144135
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);
150144
151145 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])
154147 );
155148 }
156149
@@ -204,8 +197,8 @@
204197 }));
205198 }
206199
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;
209202 }
210203
211204 async getPrompt(
modified core/context/mcp/MCPManagerSingleton.vitest.ts +7 −9
@@ -1,11 +1,11 @@
11 import { beforeEach, describe, expect, it, vi } from "vitest";
2-import { MCPOptions } from "../..";
2+import { InternalMcpOptions } from "../..";
33 import MCPConnection from "./MCPConnection";
44 import { MCPManagerSingleton } from "./MCPManagerSingleton";
55
66 // Create test versions with stubbed behavior
77 class TestMCPConnection extends MCPConnection {
8- constructor(options: MCPOptions) {
8+ constructor(options: InternalMcpOptions) {
99 super(options);
1010
1111 // Override with test implementations
@@ -28,14 +28,12 @@
2828
2929 describe("MCPManagerSingleton", () => {
3030 let manager: MCPManagerSingleton;
31- const testOptions: MCPOptions = {
31+ const testOptions: InternalMcpOptions = {
3232 name: "test-mcp",
3333 id: "test-id",
34- transport: {
35- type: "stdio",
36- command: "test-command",
37- args: [],
38- },
34+ type: "stdio",
35+ command: "test-command",
36+ args: [],
3937 };
4038
4139 beforeEach(() => {
@@ -53,7 +51,7 @@
5351 // Override createConnection to use our TestMCPConnection
5452 manager.createConnection = function (
5553 id: string,
56- options: MCPOptions,
54+ options: InternalMcpOptions,
5755 ): MCPConnection {
5856 if (this.connections.has(id)) {
5957 return this.connections.get(id)!;
modified core/context/mcp/MCPOauth.ts +19 −27
@@ -8,7 +8,7 @@
88 OAuthTokens,
99 OAuthTokensSchema,
1010 } from "@modelcontextprotocol/sdk/shared/auth.js";
11-import { IDE, MCPServerStatus, SSEOptions } from "../..";
11+import { IDE } from "../..";
1212
1313 import http from "http";
1414 import url from "url";
@@ -16,14 +16,12 @@
1616 import { GlobalContext, GlobalContextType } from "../../util/GlobalContext";
1717
1818 // 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>();
2725
2826 // Map state parameters to server URLs for OAuth callback matching
2927 const stateToServerUrl = new Map<string, string>();
@@ -242,9 +240,8 @@
242240 * checks if the authentication is already done for the current server
243241 * if not, starts the authentication process by opening a webpage url
244242 */
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);
248245 // Ensure redirect URL is ready before starting auth
249246 await authProvider.ensureRedirectUrl();
250247
@@ -252,22 +249,22 @@
252249 const state = uuidv4();
253250
254251 // Store context for this specific server with state
255- authenticatingContexts.set(mcpServerUrl, {
256- authenticatingServer: mcpServer,
252+ authenticatingContexts.set(url, {
253+ serverId,
257254 ide,
258255 state,
259256 });
260257
261258 // Map state to server URL for callback matching
262- stateToServerUrl.set(state, mcpServerUrl);
259+ stateToServerUrl.set(state, url);
263260
264261 try {
265262 return await auth(authProvider, {
266- serverUrl: mcpServerUrl,
263+ serverUrl: url,
267264 });
268265 } catch (error) {
269266 // Clean up on error
270- authenticatingContexts.delete(mcpServerUrl);
267+ authenticatingContexts.delete(url);
271268 stateToServerUrl.delete(state);
272269 throw error;
273270 }
@@ -278,9 +275,7 @@
278275 */
279276 async function handleMCPOauthCode(authorizationCode: string, state?: string) {
280277 let serverUrl: string | undefined;
281- let context:
282- | { authenticatingServer: MCPServerStatus; ide: IDE; state?: string }
283- | undefined;
278+ let context: MCPOauthContext | undefined;
284279
285280 if (state) {
286281 // Use state parameter to find the correct server
@@ -301,7 +296,7 @@
301296 return;
302297 }
303298
304- const { ide, authenticatingServer } = context;
299+ const { ide, serverId } = context;
305300
306301 try {
307302 if (!serverUrl) {
@@ -331,9 +326,7 @@
331326
332327 if (authStatus === "AUTHORIZED") {
333328 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);
337330 }
338331 } catch (error) {
339332 const errorMessage = error instanceof Error ? error.message : String(error);
@@ -350,8 +343,7 @@
350343 }
351344 }
352345
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);
356348 authProvider.clear();
357349 }
modified core/context/mcp/MCPOauth.vitest.ts +30 −63
@@ -21,7 +21,8 @@
2121 describe("MCPOauth", () => {
2222 let globalContextFilePath: string;
2323 let mockIde: any;
24- let mockMcpServer: any;
24+ let mockMcpServerId: string;
25+ let mockMcpServerUrl: string;
2526
2627 beforeEach(() => {
2728 // file is present in the core/test directory
@@ -36,13 +37,8 @@
3637 getExternalUri: vi.fn((uri) => Promise.resolve(uri)),
3738 };
3839
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";
4642
4743 vi.clearAllMocks();
4844 });
@@ -107,7 +103,11 @@
107103 const mockAuth = vi.mocked(auth);
108104 mockAuth.mockResolvedValue("AUTHORIZED");
109105
110- const result = await performAuth(mockMcpServer, mockIde);
106+ const result = await performAuth(
107+ mockMcpServerId,
108+ mockMcpServerUrl,
109+ mockIde,
110+ );
111111
112112 expect(mockAuth).toHaveBeenCalledWith(
113113 expect.any(Object), // MCPConnectionOauthProvider instance
@@ -142,7 +142,7 @@
142142 },
143143 });
144144
145- removeMCPAuth(mockMcpServer, mockIde);
145+ removeMCPAuth(mockMcpServerUrl, mockIde);
146146
147147 const updatedStorage = globalContext.get("mcpOauthStorage");
148148 expect(updatedStorage).toEqual({
@@ -166,7 +166,7 @@
166166 },
167167 });
168168
169- removeMCPAuth(mockMcpServer, mockIde);
169+ removeMCPAuth(mockMcpServerUrl, mockIde);
170170
171171 const updatedStorage = globalContext.get("mcpOauthStorage");
172172 expect(updatedStorage).toEqual({
@@ -193,7 +193,7 @@
193193 const mockAuth = vi.mocked(auth);
194194 mockAuth.mockResolvedValue("AUTHORIZED");
195195
196- await performAuth(mockMcpServer, vscodeIde);
196+ await performAuth(mockMcpServerId, mockMcpServerUrl, vscodeIde);
197197
198198 expect(vscodeIde.getExternalUri).toHaveBeenCalledWith(
199199 "http://localhost:3000",
@@ -210,7 +210,11 @@
210210 const mockAuth = vi.mocked(auth);
211211 mockAuth.mockResolvedValue("AUTHORIZED");
212212
213- await performAuth(mockMcpServer, ideWithoutExternalUri as any);
213+ await performAuth(
214+ mockMcpServerId,
215+ mockMcpServerUrl,
216+ ideWithoutExternalUri as any,
217+ );
214218
215219 // Should still work without getExternalUri
216220 expect(mockAuth).toHaveBeenCalled();
@@ -227,7 +231,7 @@
227231 mockAuth.mockResolvedValue("AUTHORIZED");
228232
229233 // Should not throw, should fallback to localhost
230- await performAuth(mockMcpServer, errorIde);
234+ await performAuth(mockMcpServerId, mockMcpServerUrl, errorIde);
231235
232236 expect(mockAuth).toHaveBeenCalled();
233237 });
@@ -235,41 +239,14 @@
235239
236240 describe("concurrent authentication", () => {
237241 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-
265242 const { auth } = await import("@modelcontextprotocol/sdk/client/auth.js");
266243 const mockAuth = vi.mocked(auth);
267244 mockAuth.mockResolvedValue("AUTHORIZED");
268245
269246 // Start two auth flows concurrently
270247 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),
273250 ]);
274251
275252 expect(result1).toBe("AUTHORIZED");
@@ -285,15 +262,15 @@
285262
286263 // First successful call to set up the context
287264 mockAuth.mockResolvedValueOnce("AUTHORIZED");
288- await performAuth(mockMcpServer, mockIde);
265+ await performAuth(mockMcpServerId, mockMcpServerUrl, mockIde);
289266
290267 // Reset mock for the failure test
291268 mockAuth.mockRejectedValueOnce(new Error("Auth failed"));
292269
293270 // 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");
297274
298275 // Verify auth was called twice
299276 expect(mockAuth).toHaveBeenCalledTimes(2);
@@ -301,30 +278,20 @@
301278 // The context cleanup happens internally in performAuth's catch block
302279 // We can verify it indirectly by checking that a subsequent auth call works
303280 mockAuth.mockResolvedValueOnce("AUTHORIZED");
304- const result = await performAuth(mockMcpServer, mockIde);
281+ const result = await performAuth(
282+ mockMcpServerId,
283+ mockMcpServerUrl,
284+ mockIde,
285+ );
305286 expect(result).toBe("AUTHORIZED");
306287 });
307288
308289 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-
323290 const { auth } = await import("@modelcontextprotocol/sdk/client/auth.js");
324291 const mockAuth = vi.mocked(auth);
325292 mockAuth.mockResolvedValue("AUTHORIZED");
326293
327- await performAuth(invalidServer, mockIde);
294+ await performAuth("invalid-id", "", mockIde);
328295
329296 // Should still attempt auth with empty URL
330297 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 @@
88 prevFilepaths,
99 } from "./autocomplete/util/openedFilesLruCache";
1010 import { ConfigHandler } from "./config/ConfigHandler";
11-import { SYSTEM_PROMPT_DOT_FILE } from "./config/getWorkspaceContinueRuleDotFiles";
1211 import { addModel, deleteModel } from "./config/util";
1312 import { getAuthUrlForTokenPage } from "./control-plane/auth/index";
1413 import { getControlPlaneEnv } from "./control-plane/env";
@@ -49,11 +48,15 @@
4948 type IDE,
5049 } from ".";
5150
52-import { BLOCK_TYPES, ConfigYaml } from "@continuedev/config-yaml";
51+import { ConfigYaml } from "@continuedev/config-yaml";
5352 import { getDiffFn, GitDiffCache } from "./autocomplete/snippets/gitDiffCache";
5453 import { stringifyMcpPrompt } from "./commands/slash/mcpSlashCommand";
5554 import { createNewAssistantFile } from "./config/createNewAssistantFile";
56-import { isLocalDefinitionFile } from "./config/loadLocalAssistants";
55+import {
56+ isColocatedRulesFile,
57+ isContinueAgentConfigFile,
58+ isContinueConfigRelatedUri,
59+} from "./config/loadLocalAssistants";
5760 import { CodebaseRulesCache } from "./config/markdown/loadCodebaseRules";
5861 import {
5962 setupLocalConfig,
@@ -69,7 +72,6 @@
6972 import { shouldIgnore } from "./indexing/shouldIgnore";
7073 import { walkDirCache } from "./indexing/walkDir";
7174 import { LLMLogger } from "./llm/logger";
72-import { RULES_MARKDOWN_FILENAME } from "./llm/rules/constants";
7375 import { llmStreamChat } from "./llm/streamChat";
7476 import { BeforeAfterDiff } from "./nextEdit/context/diffFormatting";
7577 import { processSmallEdit } from "./nextEdit/context/processSmallEdit";
@@ -80,17 +82,6 @@
8082 import type { IMessenger, Message } from "./protocol/messenger";
8183 import { shareSession } from "./util/historyUtils";
8284 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-};
9485
9586 export class Core {
9687 configHandler: ConfigHandler;
@@ -522,15 +513,26 @@
522513 });
523514 on("mcp/startAuthentication", async (msg) => {
524515 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+ );
527525 if (status === "AUTHORIZED") {
528- await MCPManagerSingleton.getInstance().refreshConnection(msg.data.id);
526+ await MCPManagerSingleton.getInstance().refreshConnection(
527+ msg.data.serverId,
528+ );
529529 }
530530 });
531531 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+ );
534536 });
535537
536538 // Context providers
@@ -864,40 +866,65 @@
864866 };
865867
866868 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+ );
888896 }
889897 });
890898
891899 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+ );
901928 }
902929 });
903930
@@ -1226,10 +1253,9 @@
12261253 const diffCache = GitDiffCache.getInstance(getDiffFn(this.ide));
12271254 diffCache.invalidate();
12281255 walkDirCache.invalidate(); // safe approach for now - TODO - only invalidate on relevant changes
1256+ const currentProfileUri =
1257+ this.configHandler.currentProfile?.profileDescription.uri ?? "";
12291258 for (const uri of data.uris) {
1230- const currentProfileUri =
1231- this.configHandler.currentProfile?.profileDescription.uri ?? "";
1232-
12331259 if (URI.equal(uri, currentProfileUri)) {
12341260 // Trigger a toast notification to provide UI feedback that config has been updated
12351261 const showToast =
@@ -1249,24 +1275,7 @@
12491275 );
12501276 continue;
12511277 }
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)) {
12701279 try {
12711280 const codebaseRulesCache = CodebaseRulesCache.getInstance();
12721281 void codebaseRulesCache.update(this.ide, uri).then(() => {
@@ -1275,6 +1284,10 @@
12751284 } catch (e) {
12761285 Logger.error(`Failed to update codebase rule: ${e}`);
12771286 }
1287+ } else if (isContinueConfigRelatedUri(uri)) {
1288+ await this.configHandler.reloadConfig(
1289+ "Local config-related file updated",
1290+ );
12781291 } else if (
12791292 uri.endsWith(".continueignore") ||
12801293 uri.endsWith(".gitignore")
modified core/index.d.ts +40 −13
@@ -1246,7 +1246,6 @@
12461246 args: string[];
12471247 env?: Record<string, string>;
12481248 cwd?: string;
1249- requestOptions?: RequestOptions;
12501249 }
12511250
12521251 export interface WebSocketOptions {
@@ -1273,15 +1272,6 @@
12731272 | SSEOptions
12741273 | StreamableHTTPOptions;
12751274
1276-export interface MCPOptions {
1277- name: string;
1278- id: string;
1279- transport: TransportOptions;
1280- faviconUrl?: string;
1281- timeout?: number;
1282- requestOptions?: RequestOptions;
1283-}
1284-
12851275 export type MCPConnectionStatus =
12861276 | "connecting"
12871277 | "connected"
@@ -1329,18 +1319,55 @@
13291319 };
13301320 }
13311321
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 & {
13331361 status: MCPConnectionStatus;
13341362 errors: string[];
13351363 infos: string[];
13361364 isProtectedResource: boolean;
1337-
13381365 prompts: MCPPrompt[];
13391366 tools: MCPTool[];
13401367 resources: MCPResource[];
13411368 resourceTemplates: MCPResourceTemplate[];
13421369 sourceFile?: string;
1343-}
1370+};
13441371
13451372 export interface ContinueUIConfig {
13461373 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 @@
1414 import { GlobalContextModelSelections } from "../util/GlobalContext";
1515
1616 import {
17+ BaseSessionMetadata,
1718 BrowserSerializedContinueConfig,
1819 ChatMessage,
1920 CompiledMessagesResult,
@@ -27,7 +28,6 @@
2728 FileSymbolMap,
2829 IdeSettings,
2930 LLMFullCompletionOptions,
30- MCPServerStatus,
3131 MessageOption,
3232 ModelDescription,
3333 PromptLog,
@@ -35,7 +35,6 @@
3535 RangeInFileWithNextEditInfo,
3636 SerializedContinueConfig,
3737 Session,
38- BaseSessionMetadata,
3938 SiteIndexingConfig,
4039 SlashCommandDescWithSource,
4140 StreamDiffLinesPayload,
@@ -161,9 +160,20 @@
161160 description: string | undefined;
162161 },
163162 ];
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+ ];
167177 "context/getSymbolsForFiles": [{ uris: string[] }, FileSymbolMap];
168178 "context/loadSubmenuItems": [{ title: string }, ContextSubmenuItem[]];
169179 "autocomplete/complete": [AutocompleteInput, string[]];
modified core/tools/mcpToolName.vitest.ts +2 −4
@@ -12,10 +12,8 @@
1212 resourceTemplates: [],
1313 status: "connected",
1414 id: "",
15- transport: {
16- type: "sse",
17- url: "",
18- },
15+ type: "sse",
16+ url: "",
1917 isProtectedResource: false,
2018 });
2119
modified docs/reference.mdx +1 −1
@@ -297,8 +297,8 @@
297297 - `args`: An optional array of arguments for the command.
298298 - `env`: An optional map of environment variables for the server process.
299299 - `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.
301300 - `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
302302
303303 **Example:**
304304
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 @@
33 import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js";
44 import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
55 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";
711
812 import { getErrorString } from "../util/error.js";
913 import { logger } from "../util/logger.js";
@@ -217,19 +221,7 @@
217221 this.updateState();
218222
219223 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);
233225
234226 connection.client = client;
235227 connection.status = "connected";
@@ -349,66 +341,103 @@
349341 }
350342
351343 /**
352- * Construct transport based on server configuration
344+ * Construct transport based on server configuration and connect client
353345 */
354- private async constructTransport(
346+ private async getConnectedClient(
355347 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+ );
379353
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+ });
399368
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+ },
404387 );
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+ }
405396 }
406- return new StreamableHTTPClientTransport(new URL(serverConfig.url), {
407- requestInit: { headers: serverConfig.requestOptions?.headers },
408- });
397+ }
398+ }
399+
400+ return client;
401+ }
409402
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;
412433 }
434+
435+ return new StdioClientTransport({
436+ command: serverConfig.command,
437+ args: serverConfig.args || [],
438+ env,
439+ cwd: serverConfig.cwd,
440+ stderr: "ignore",
441+ });
413442 }
414443 }
modified extensions/cli/src/ui/MCPSelector.tsx +14 −4
@@ -328,14 +328,24 @@
328328
329329 const { color: statusColor, statusText } =
330330 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)");
334344
335345 return (
336346 <Text color="dim">
337347 Status: <Text color={statusColor}>{statusText}</Text>
338- {cmd && ` • Command: ${cmd}`}
348+ {configText}
339349 </Text>
340350 );
341351 })()}
modified extensions/intellij/src/main/kotlin/com/github/continuedev/continueintellijextension/constants/MessageTypes.kt +2 −0
@@ -92,6 +92,8 @@
9292 "config/updateSharedConfig",
9393 "config/updateSelectedModel",
9494 "mcp/reloadServer",
95+ "mcp/startAuthentication",
96+ "mcp/removeAuthentication",
9597 "mcp/getPrompt",
9698 "context/getContextItems",
9799 "context/getSymbolsForFiles",
modified gui/src/pages/config/sections/ToolsSection.tsx +43 −31
@@ -82,13 +82,23 @@
8282 };
8383
8484 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+ }
8792 };
8893
8994 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+ }
92102 };
93103
94104 const onRefresh = async () => {
@@ -217,37 +227,39 @@
217227 </div>
218228
219229 <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={
232235 server.status === "error"
233- ? onAuthenticate
236+ ? "Authenticate"
234237 : server.status === "authenticating"
235- ? undefined
236- : onRemoveAuth
238+ ? "Authenticating..."
239+ : "Remove authentication"
237240 }
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"}
242241 >
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+ )}
251263 <Listbox>
252264 <ListboxButton>
253265 <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 @@
11 {
22 "name": "@continuedev/config-yaml",
3- "version": "1.17.0",
3+ "version": "1.23.0",
44 "description": "",
55 "main": "dist/index.js",
66 "types": "dist/index.d.ts",
modified packages/config-yaml/src/browser.ts +2 −0
@@ -14,6 +14,8 @@
1414 // Note: registryClient.js is excluded because it uses Node.js fs/path APIs
1515 export * from "./schemas/data/index.js";
1616 export * from "./schemas/index.js";
17+export * from "./schemas/mcp/convertJson.js";
18+export * from "./schemas/mcp/json.js";
1719 export * from "./schemas/models.js";
1820 export * from "./schemas/policy.js";
1921 export * from "./validation.js";
modified packages/config-yaml/src/schemas/index.ts +14 −17
@@ -1,6 +1,7 @@
11 import * as z from "zod";
22 import { commonModelSlugs } from "./commonSlugs.js";
33 import { dataSchema } from "./data/index.js";
4+import { mcpServerSchema, partialMcpServerSchema } from "./mcp/index.js";
45 import {
56 modelSchema,
67 partialModelSchema,
@@ -13,22 +14,7 @@
1314 params: z.any().optional(),
1415 });
1516
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";
3218
3319 const promptSchema = z.object({
3420 name: z.string(),
@@ -139,7 +125,18 @@
139125 .optional(),
140126 context: z.array(blockOrSchema(contextSchema)).optional(),
141127 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(),
143140 rules: z
144141 .array(
145142 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 @@
2020 },
2121 "../config-yaml": {
2222 "name": "@continuedev/config-yaml",
23- "version": "1.17.0",
23+ "version": "1.23.0",
2424 "license": "Apache-2.0",
2525 "dependencies": {
2626 "@continuedev/config-types": "^1.0.14",
modified packages/llm-info/package-lock.json +2 −2
@@ -1,12 +1,12 @@
11 {
22 "name": "@continuedev/llm-info",
3- "version": "1.0.9",
3+ "version": "1.0.10",
44 "lockfileVersion": 3,
55 "requires": true,
66 "packages": {
77 "": {
88 "name": "@continuedev/llm-info",
9- "version": "1.0.9",
9+ "version": "1.0.10",
1010 "license": "Apache-2.0",
1111 "devDependencies": {
1212 "@semantic-release/changelog": "^6.0.3",