mirror of
https://github.com/Kilo-Org/kilocode.git
synced 2026-09-24 16:02:55 +08:00
fix(cli,vscode): import disabled MCPs with enabled: false instead of skipping them (#8098)
The MCP importer was silently ignoring disabled MCP servers during import. Now imports all configured MCPs and preserves their disabled state by setting enabled: false in the converted config. Closes #8096 Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com> Co-authored-by: Imanol Maiztegui <imanol.mzd@gmail.com> Co-authored-by: Mark IJbema <mark@kilocode.ai>
This commit is contained in:
co-authored by
kiloconnect[bot]
Imanol Maiztegui
Mark IJbema
parent
c9c6781a45
commit
e09040fe45
@@ -51,9 +51,6 @@ export namespace McpMigrator {
|
||||
}
|
||||
|
||||
export function convertServer(name: string, server: KilocodeMcpServer): Config.Mcp | null {
|
||||
// Skip disabled servers
|
||||
if (server.disabled) return null
|
||||
|
||||
if (isRemote(server)) {
|
||||
if (!server.url) {
|
||||
log.warn("remote MCP server missing url, skipping", { name })
|
||||
@@ -63,6 +60,7 @@ export namespace McpMigrator {
|
||||
type: "remote",
|
||||
url: server.url,
|
||||
...(server.headers && Object.keys(server.headers).length > 0 && { headers: server.headers }),
|
||||
...(server.disabled && { enabled: false }),
|
||||
}
|
||||
return config
|
||||
}
|
||||
@@ -80,6 +78,7 @@ export namespace McpMigrator {
|
||||
type: "local",
|
||||
command,
|
||||
...(server.env && Object.keys(server.env).length > 0 && { environment: server.env }),
|
||||
...(server.disabled && { enabled: false }),
|
||||
}
|
||||
|
||||
return config
|
||||
@@ -130,11 +129,6 @@ export namespace McpMigrator {
|
||||
|
||||
// Convert each server
|
||||
for (const [name, server] of serversByName) {
|
||||
if (server.disabled) {
|
||||
skipped.push({ name, reason: "Server is disabled" })
|
||||
continue
|
||||
}
|
||||
|
||||
// Warn about alwaysAllow permissions that cannot be migrated
|
||||
if (server.alwaysAllow && server.alwaysAllow.length > 0) {
|
||||
warnings.push(
|
||||
|
||||
@@ -34,7 +34,7 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("returns null for disabled servers", () => {
|
||||
test("converts disabled servers with enabled: false", () => {
|
||||
const server: McpMigrator.KilocodeMcpServer = {
|
||||
command: "npx",
|
||||
args: ["-y", "some-package"],
|
||||
@@ -43,7 +43,11 @@ describe("McpMigrator", () => {
|
||||
|
||||
const result = McpMigrator.convertServer("disabled-server", server)
|
||||
|
||||
expect(result).toBeNull()
|
||||
expect(result).toEqual({
|
||||
type: "local",
|
||||
command: ["npx", "-y", "some-package"],
|
||||
enabled: false,
|
||||
})
|
||||
})
|
||||
|
||||
test("omits environment when env is empty object", () => {
|
||||
@@ -294,7 +298,7 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("skips disabled servers and records them", async () => {
|
||||
test("imports disabled servers with enabled: false", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
const settingsDir = path.join(dir, ".kilo")
|
||||
@@ -316,10 +320,15 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
|
||||
expect(result.mcp).toHaveProperty("enabled")
|
||||
expect(result.mcp).not.toHaveProperty("disabled")
|
||||
expect(result.skipped).toContainEqual({
|
||||
name: "disabled",
|
||||
reason: "Server is disabled",
|
||||
expect(result.mcp.enabled).toEqual({
|
||||
type: "local",
|
||||
command: ["enabled-cmd"],
|
||||
})
|
||||
expect(result.mcp).toHaveProperty("disabled")
|
||||
expect(result.mcp.disabled).toEqual({
|
||||
type: "local",
|
||||
command: ["disabled-cmd"],
|
||||
enabled: false,
|
||||
})
|
||||
})
|
||||
|
||||
@@ -495,7 +504,7 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("returns null for disabled remote server", () => {
|
||||
test("converts disabled remote server with enabled: false", () => {
|
||||
const server = {
|
||||
type: "streamable-http",
|
||||
url: "http://localhost:4321/mcp",
|
||||
@@ -504,7 +513,11 @@ describe("McpMigrator", () => {
|
||||
|
||||
const result = McpMigrator.convertServer("disabled-remote", server)
|
||||
|
||||
expect(result).toBeNull()
|
||||
expect(result).toEqual({
|
||||
type: "remote",
|
||||
url: "http://localhost:4321/mcp",
|
||||
enabled: false,
|
||||
})
|
||||
})
|
||||
|
||||
test("omits headers when not provided on remote server", () => {
|
||||
@@ -678,7 +691,7 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
})
|
||||
|
||||
test("skips disabled remote servers and records them", async () => {
|
||||
test("imports disabled remote servers with enabled: false", async () => {
|
||||
await using tmp = await tmpdir({
|
||||
init: async (dir) => {
|
||||
const settingsDir = path.join(dir, ".kilo")
|
||||
@@ -707,10 +720,15 @@ describe("McpMigrator", () => {
|
||||
})
|
||||
|
||||
expect(result.mcp).toHaveProperty("enabled")
|
||||
expect(result.mcp).not.toHaveProperty("disabled")
|
||||
expect(result.skipped).toContainEqual({
|
||||
name: "disabled",
|
||||
reason: "Server is disabled",
|
||||
expect(result.mcp.enabled).toEqual({
|
||||
type: "remote",
|
||||
url: "http://localhost:4321/mcp",
|
||||
})
|
||||
expect(result.mcp).toHaveProperty("disabled")
|
||||
expect(result.mcp.disabled).toEqual({
|
||||
type: "remote",
|
||||
url: "http://localhost:4322/mcp",
|
||||
enabled: false,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user