Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions src/converters/claude-to-kiro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export function convertClaudeToKiro(
convertCommandToSkill(command, usedSkillNames, agentNames),
)

// Convert MCP servers (stdio only)
// Convert MCP servers (stdio and remote)
const mcpServers = convertMcpServers(plugin.mcpServers)

// Build steering files from CLAUDE.md
Expand Down Expand Up @@ -177,19 +177,20 @@ function convertMcpServers(

const result: Record<string, KiroMcpServer> = {}
for (const [name, server] of Object.entries(servers)) {
if (!server.command) {
if (server.command) {
const entry: KiroMcpServer = { command: server.command }
if (server.args && server.args.length > 0) entry.args = server.args
if (server.env && Object.keys(server.env).length > 0) entry.env = server.env
result[name] = entry
} else if (server.url) {
const entry: KiroMcpServer = { url: server.url }
if (server.headers && Object.keys(server.headers).length > 0) entry.headers = server.headers
result[name] = entry
} else {
console.warn(
`Warning: MCP server "${name}" has no command (HTTP/SSE transport). Kiro only supports stdio. Skipping.`,
`Warning: MCP server "${name}" has no command or url. Skipping.`,
)
continue
}

const entry: KiroMcpServer = { command: server.command }
if (server.args && server.args.length > 0) entry.args = server.args
if (server.env && Object.keys(server.env).length > 0) entry.env = server.env

console.log(`MCP server "${name}" will execute: ${server.command}${server.args ? " " + server.args.join(" ") : ""}`)
result[name] = entry
}
return result
}
Expand Down
13 changes: 11 additions & 2 deletions src/parsers/claude.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ async function loadMcpServers(

const mcpPath = path.join(root, ".mcp.json")
if (await pathExists(mcpPath)) {
return readJson<Record<string, ClaudeMcpServer>>(mcpPath)
const raw = await readJson<Record<string, unknown>>(mcpPath)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The mcpServers unwrap logic is duplicated. The same if (raw.mcpServers && typeof raw.mcpServers === "object") block appears in both loadMcpServers (line ~161) and loadMcpPaths (line ~239) in src/parsers/claude.ts. This could be a small helper like unwrapMcpServers(raw). It's small but worth just addressing.

if (raw.mcpServers && typeof raw.mcpServers === "object") {
return raw.mcpServers as Record<string, ClaudeMcpServer>
}
return raw as Record<string, ClaudeMcpServer>
}

return undefined
Expand Down Expand Up @@ -232,7 +236,12 @@ async function loadMcpPaths(
for (const entry of toPathList(value)) {
const resolved = resolveWithinRoot(root, entry, "mcpServers path")
if (await pathExists(resolved)) {
configs.push(await readJson<Record<string, ClaudeMcpServer>>(resolved))
const raw = await readJson<Record<string, unknown>>(resolved)
if (raw.mcpServers && typeof raw.mcpServers === "object") {
configs.push(raw.mcpServers as Record<string, ClaudeMcpServer>)
} else {
configs.push(raw as Record<string, ClaudeMcpServer>)
}
}
}
return configs
Expand Down
23 changes: 20 additions & 3 deletions tests/kiro-converter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,32 @@ describe("convertClaudeToKiro", () => {
expect(bundle.mcpServers.local.args).toEqual(["hello"])
})

test("MCP HTTP servers skipped with warning", () => {
test("MCP HTTP servers converted with url", () => {
const plugin: ClaudePlugin = {
...fixturePlugin,
mcpServers: {
httpServer: { url: "https://example.com/mcp" },
},
agents: [],
commands: [],
skills: [],
}

const bundle = convertClaudeToKiro(plugin, defaultOptions)

expect(Object.keys(bundle.mcpServers)).toHaveLength(1)
expect(bundle.mcpServers.httpServer).toEqual({ url: "https://example.com/mcp" })
})

test("MCP servers with no command or url skipped with warning", () => {
const warnings: string[] = []
const originalWarn = console.warn
console.warn = (msg: string) => warnings.push(msg)

const plugin: ClaudePlugin = {
...fixturePlugin,
mcpServers: {
httpServer: { url: "https://example.com/mcp" },
broken: {} as any,
},
agents: [],
commands: [],
Expand All @@ -193,7 +210,7 @@ describe("convertClaudeToKiro", () => {
console.warn = originalWarn

expect(Object.keys(bundle.mcpServers)).toHaveLength(0)
expect(warnings.some((w) => w.includes("no command") || w.includes("HTTP"))).toBe(true)
expect(warnings.some((w) => w.includes("no command or url"))).toBe(true)
})

test("plugin with zero agents produces empty agents array", () => {
Expand Down