Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ modular-mcp.json
**/.kilocode/mcp.json
**/.kilocodeignore
**/.kiro/steering/
**/.kiro/settings/mcp.json
**/.aiignore
**/.opencode/memories/
**/.opencode/command/
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ Rulesync supports both **generation** and **import** for All of the major AI cod
| Kilo Code | ✅ 🌏 | ✅ | ✅ | ✅ 🌏 | | ✅ 🌏 |
| Roo Code | ✅ | ✅ | ✅ | ✅ | 🎮 | ✅ 🌏 |
| Qwen Code | ✅ | ✅ | | | | |
| Kiro IDE | ✅ | ✅ | | | | |
| Kiro IDE | ✅ | ✅ | | | | |
| Google Antigravity | ✅ | | | ✅ | | ✅ 🌏 |
| JetBrains Junie | ✅ | ✅ | ✅ | | | |
| AugmentCode | ✅ | ✅ | | | | |
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/gitignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ dist/`;
**/.kilocode/mcp.json
**/.kilocodeignore
**/.kiro/steering/
**/.kiro/settings/mcp.json
**/.aiignore
**/.opencode/memories/
**/.opencode/command/
Expand Down
1 change: 1 addition & 0 deletions src/cli/commands/gitignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const RULESYNC_IGNORE_ENTRIES = [
"**/.kilocodeignore",
// Kiro
"**/.kiro/steering/",
"**/.kiro/settings/mcp.json",
"**/.aiignore",
// OpenCode
"**/.opencode/memories/",
Expand Down
104 changes: 104 additions & 0 deletions src/features/mcp/kiro-mcp.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { join } from "node:path";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";

import { RULESYNC_RELATIVE_DIR_PATH } from "../../constants/rulesync-paths.js";
import { setupTestDirectory } from "../../test-utils/test-directories.js";
import { KiroMcp } from "./kiro-mcp.js";
import { RulesyncMcp } from "./rulesync-mcp.js";

describe("KiroMcp", () => {
let testDir: string;
let cleanup: () => Promise<void>;

beforeEach(async () => {
({ testDir, cleanup } = await setupTestDirectory());
vi.spyOn(process, "cwd").mockReturnValue(testDir);
});

afterEach(async () => {
await cleanup();
vi.restoreAllMocks();
});

describe("getSettablePaths", () => {
it("should return project path", () => {
expect(KiroMcp.getSettablePaths()).toEqual({
relativeDirPath: join(".kiro", "settings"),
relativeFilePath: "mcp.json",
});
});
});

describe("fromRulesyncMcp", () => {
it("should convert exposed servers for project mode", () => {
const rulesyncMcp = new RulesyncMcp({
baseDir: testDir,
relativeDirPath: RULESYNC_RELATIVE_DIR_PATH,
relativeFilePath: ".mcp.json",
fileContent: JSON.stringify({
mcpServers: {
exposedServer: { command: "node", args: ["server.js"], exposed: true },
hiddenServer: { command: "python", args: ["hidden.py"] },
},
}),
validate: true,
});

const kiroMcp = KiroMcp.fromRulesyncMcp({ rulesyncMcp });

expect(kiroMcp.getRelativeDirPath()).toBe(join(".kiro", "settings"));
expect(kiroMcp.getRelativeFilePath()).toBe("mcp.json");
expect(JSON.parse(kiroMcp.getFileContent())).toEqual({
mcpServers: {
exposedServer: { command: "node", args: ["server.js"] },
hiddenServer: { command: "python", args: ["hidden.py"] },
},
});
});
});

describe("fromFile", () => {
it("should initialize missing project file", async () => {
const kiroMcp = await KiroMcp.fromFile({ baseDir: testDir });

expect(kiroMcp.getFilePath()).toBe(join(testDir, ".kiro", "settings", "mcp.json"));
expect(JSON.parse(kiroMcp.getFileContent())).toEqual({ mcpServers: {} });
});
});

describe("toRulesyncMcp", () => {
it("should convert to Rulesync format", () => {
const kiroMcp = new KiroMcp({
baseDir: testDir,
relativeDirPath: join(".kiro", "settings"),
relativeFilePath: "mcp.json",
fileContent: JSON.stringify({
mcpServers: {
api: { command: "node", args: ["server.js"] },
},
}),
validate: true,
});

const rulesyncMcp = kiroMcp.toRulesyncMcp();

expect(rulesyncMcp.getFilePath()).toBe(join(testDir, ".rulesync", ".mcp.json"));
expect(rulesyncMcp.getMcpServers()).toEqual({
api: { command: "node", args: ["server.js"] },
});
});
});

describe("forDeletion", () => {
it("should create deletable placeholder", () => {
const kiroMcp = KiroMcp.forDeletion({
baseDir: testDir,
relativeDirPath: join(".kiro", "settings"),
relativeFilePath: "obsolete.json",
});

expect(kiroMcp.isDeletable()).toBe(true);
expect(kiroMcp.getFileContent()).toBe("{}");
});
});
});
97 changes: 97 additions & 0 deletions src/features/mcp/kiro-mcp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import { join } from "node:path";

import { ValidationResult } from "../../types/ai-file.js";
import { readOrInitializeFileContent } from "../../utils/file.js";
import { RulesyncMcp } from "./rulesync-mcp.js";
import {
ToolMcp,
ToolMcpForDeletionParams,
ToolMcpFromFileParams,
ToolMcpFromRulesyncMcpParams,
ToolMcpParams,
ToolMcpSettablePaths,
} from "./tool-mcp.js";

export class KiroMcp extends ToolMcp {
private readonly json: Record<string, unknown>;

constructor(params: ToolMcpParams) {
super(params);
this.json = JSON.parse(this.fileContent || "{}");
}

getJson(): Record<string, unknown> {
return this.json;
}

static getSettablePaths(): ToolMcpSettablePaths {
return {
relativeDirPath: join(".kiro", "settings"),
relativeFilePath: "mcp.json",
};
}

static async fromFile({
baseDir = process.cwd(),
validate = true,
}: ToolMcpFromFileParams): Promise<KiroMcp> {
const paths = this.getSettablePaths();
const fileContent = await readOrInitializeFileContent(
join(baseDir, paths.relativeDirPath, paths.relativeFilePath),
JSON.stringify({ mcpServers: {} }, null, 2),
);

return new KiroMcp({
baseDir,
relativeDirPath: paths.relativeDirPath,
relativeFilePath: paths.relativeFilePath,
fileContent,
validate,
});
}

static fromRulesyncMcp({
baseDir = process.cwd(),
rulesyncMcp,
validate = true,
}: ToolMcpFromRulesyncMcpParams): KiroMcp {
const paths = this.getSettablePaths();
const fileContent = JSON.stringify(
{ mcpServers: rulesyncMcp.getMcpServers({ type: "exposed" }) },
null,
2,
);

return new KiroMcp({
baseDir,
relativeDirPath: paths.relativeDirPath,
relativeFilePath: paths.relativeFilePath,
fileContent,
validate,
});
}

toRulesyncMcp(): RulesyncMcp {
return this.toRulesyncMcpDefault({
fileContent: JSON.stringify({ mcpServers: this.json.mcpServers ?? {} }, null, 2),
});
}

validate(): ValidationResult {
return { success: true, error: null };
}

static forDeletion({
baseDir = process.cwd(),
relativeDirPath,
relativeFilePath,
}: ToolMcpForDeletionParams): KiroMcp {
return new KiroMcp({
baseDir,
relativeDirPath,
relativeFilePath,
fileContent: "{}",
validate: false,
});
}
}
9 changes: 9 additions & 0 deletions src/features/mcp/mcp-processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { CursorMcp } from "./cursor-mcp.js";
import { GeminiCliMcp } from "./geminicli-mcp.js";
import { JunieMcp } from "./junie-mcp.js";
import { KiloMcp } from "./kilo-mcp.js";
import { KiroMcp } from "./kiro-mcp.js";
import { ModularMcp } from "./modular-mcp.js";
import { OpencodeMcp } from "./opencode-mcp.js";
import { RooMcp } from "./roo-mcp.js";
Expand All @@ -40,6 +41,7 @@ const mcpProcessorToolTargetTuple = [
"cursor",
"geminicli",
"kilo",
"kiro",
"junie",
"opencode",
"roo",
Expand Down Expand Up @@ -134,6 +136,13 @@ const toolMcpFactories = new Map<McpProcessorToolTarget, ToolMcpFactory>([
meta: { supportsProject: true, supportsGlobal: false, supportsModular: false },
},
],
[
"kiro",
{
class: KiroMcp,
meta: { supportsProject: true, supportsGlobal: false, supportsModular: false },
},
],
[
"junie",
{
Expand Down