diff --git a/src/shared/remote-config/__tests__/schema.test.ts b/src/shared/remote-config/__tests__/schema.test.ts index 92c70b21..b2efea26 100644 --- a/src/shared/remote-config/__tests__/schema.test.ts +++ b/src/shared/remote-config/__tests__/schema.test.ts @@ -191,6 +191,41 @@ describe("Remote Config Schema", () => { }) }) + describe("MCPSettingsSchema", () => { + it("should reject servers with a missing name", () => { + const config = { + version: "v1", + allowedMCPServers: [{ id: "server-1" }], + } + + expect(() => RemoteConfigSchema.parse(config)).to.throw() + }) + + it("should reject servers with a missing id", () => { + const config = { + version: "v1", + allowedMCPServers: [{ name: "server 1" }], + } + + expect(() => RemoteConfigSchema.parse(config)).to.throw() + }) + + it("should accept valid MCP settings", () => { + const config = { + version: "v1", + mcpMarketplaceEnabled: true, + allowedMCPServers: [ + { id: "server-1", name: "Server One" }, + { id: "server-2", name: "Server Two" }, + ], + } + + const result = RemoteConfigSchema.parse(config) + expect(result.mcpMarketplaceEnabled).to.equal(true) + expect(result.allowedMCPServers).to.deep.equal(config.allowedMCPServers) + }) + }) + describe("RemoteConfigSchema", () => { it("should accept valid complete remote config", () => { const validConfig: RemoteConfig = { @@ -291,6 +326,10 @@ describe("Remote Config Schema", () => { version: "v1", telemetryEnabled: true, mcpMarketplaceEnabled: false, + allowedMCPServers: [ + { id: "server-1", name: "Server One" }, + { id: "server-2", name: "Server Two" }, + ], yoloModeAllowed: true, openTelemetryEnabled: true, openTelemetryMetricsExporter: "otlp", @@ -370,9 +409,11 @@ describe("Remote Config Schema", () => { // Verify all top-level fields expect(result.version).to.equal("v1") expect(result.telemetryEnabled).to.equal(true) - expect(result.mcpMarketplaceEnabled).to.equal(false) expect(result.yoloModeAllowed).to.equal(true) + expect(result.mcpMarketplaceEnabled).to.equal(false) + expect(result.allowedMCPServers).to.deep.equal(config.allowedMCPServers) + // Verify OpenAI Compatible settings expect(result.providerSettings?.OpenAiCompatible?.models).to.have.lengthOf(2) expect(result.providerSettings?.OpenAiCompatible?.openAiBaseUrl).to.equal("https://custom.openai.api/v1") diff --git a/src/shared/remote-config/schema.ts b/src/shared/remote-config/schema.ts index aabfb775..41297a2c 100644 --- a/src/shared/remote-config/schema.ts +++ b/src/shared/remote-config/schema.ts @@ -81,6 +81,11 @@ const ProviderSettingsSchema = z.object({ Cline: ClineSettingsSchema.optional(), }) +export const AllowedMCPServerSchema = z.object({ + id: z.string(), + name: z.string(), +}) + export const RemoteConfigSchema = z.object({ // The version of the remote config settings, e.g. v1 // This field is for internal use only, and won't be visible to the administrator in the UI. @@ -88,7 +93,11 @@ export const RemoteConfigSchema = z.object({ // General settings not specific to any provider telemetryEnabled: z.boolean().optional(), + + // MCP settings mcpMarketplaceEnabled: z.boolean().optional(), + allowedMCPServers: z.array(AllowedMCPServerSchema).optional(), + // If the user is allowed to enable YOLO mode. Note this is different from the extension setting // yoloModeEnabled, because we do not want to force YOLO enabled for the user. yoloModeAllowed: z.boolean().optional(), @@ -118,6 +127,7 @@ export const RemoteConfigSchema = z.object({ }) // Type inference from schemas +export type MCPServer = z.infer export type OpenAiCompatibleModel = z.infer export type OpenAiCompatible = z.infer export type AwsBedrockModel = z.infer