Add MCP settings to the remote config (#7123)
* Add MCP settings to the remote config * Refactor MCP server schema * Add model list to the root remote config * Add tests * Add type
This commit is contained in:
1 parent
944ed41f4a
commit
a66b57ef51
2 files changed
+52
-1
No files matched your search
@@ -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")
|
||||
|
||||
@@ -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<typeof AllowedMCPServerSchema>
|
||||
export type OpenAiCompatibleModel = z.infer<typeof OpenAiCompatibleModelSchema>
|
||||
export type OpenAiCompatible = z.infer<typeof OpenAiCompatibleSchema>
|
||||
export type AwsBedrockModel = z.infer<typeof AwsBedrockModelSchema>
|
||||
|
||||
Reference in new issue
Block a user