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
21 changes: 13 additions & 8 deletions src/mcp/install-mcp-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,25 @@ export async function prepareMcpConfig(
// Detect if we're in agent mode (explicit prompt provided)
const isAgentMode = mode === "agent";

const hasGitHubCommentTools = allowedToolsList.some((tool) =>
tool.startsWith("mcp__github_comment__"),
const hasGitHubCommentTools = allowedToolsList.some(
(tool) =>
tool.startsWith("mcp__github_comment__") ||
tool === "mcp__github_comment",
);

const hasGitHubMcpTools = allowedToolsList.some((tool) =>
tool.startsWith("mcp__github__"),
const hasGitHubMcpTools = allowedToolsList.some(
(tool) => tool.startsWith("mcp__github__") || tool === "mcp__github",
);

const hasInlineCommentTools = allowedToolsList.some((tool) =>
tool.startsWith("mcp__github_inline_comment__"),
const hasInlineCommentTools = allowedToolsList.some(
(tool) =>
tool.startsWith("mcp__github_inline_comment__") ||
tool === "mcp__github_inline_comment",
);

const hasGitHubCITools = allowedToolsList.some((tool) =>
tool.startsWith("mcp__github_ci__"),
const hasGitHubCITools = allowedToolsList.some(
(tool) =>
tool.startsWith("mcp__github_ci__") || tool === "mcp__github_ci",
);

const baseMcpConfig: { mcpServers: Record<string, unknown> } = {
Expand Down
42 changes: 42 additions & 0 deletions test/install-mcp-server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,27 @@ describe("prepareMcpConfig", () => {
);
});

test("should include github MCP server when all mcp__github tools are allowed", async () => {
const result = await prepareMcpConfig({
githubToken: "test-token",
owner: "test-owner",
repo: "test-repo",
branch: "test-branch",
baseBranch: "main",
allowedTools: ["mcp__github"],
mode: "tag",
context: mockContext,
});

const parsed = JSON.parse(result);
expect(parsed.mcpServers).toBeDefined();
expect(parsed.mcpServers.github).toBeDefined();
expect(parsed.mcpServers.github.command).toBe("docker");
expect(parsed.mcpServers.github.env.GITHUB_PERSONAL_ACCESS_TOKEN).toBe(
"test-token",
);
});

test("should include github MCP server when mcp__github__ tools are allowed", async () => {
const result = await prepareMcpConfig({
githubToken: "test-token",
Expand Down Expand Up @@ -164,6 +185,27 @@ describe("prepareMcpConfig", () => {
expect(parsed.mcpServers.github_inline_comment.env.PR_NUMBER).toBe("456");
});

test("should include inline comment server when all mcp__github_inline_comment tools are allowed", async () => {
const result = await prepareMcpConfig({
githubToken: "test-token",
owner: "test-owner",
repo: "test-repo",
branch: "test-branch",
baseBranch: "main",
allowedTools: ["mcp__github_inline_comment"],
mode: "tag",
context: mockPRContext,
});

const parsed = JSON.parse(result);
expect(parsed.mcpServers).toBeDefined();
expect(parsed.mcpServers.github_inline_comment).toBeDefined();
expect(parsed.mcpServers.github_inline_comment.env.GITHUB_TOKEN).toBe(
"test-token",
);
expect(parsed.mcpServers.github_inline_comment.env.PR_NUMBER).toBe("456");
});

test("should include comment server when no GitHub tools are allowed and signing disabled", async () => {
const result = await prepareMcpConfig({
githubToken: "test-token",
Expand Down