diff --git a/src/mcp/install-mcp-server.ts b/src/mcp/install-mcp-server.ts index 22de61122..ac9fb00ad 100644 --- a/src/mcp/install-mcp-server.ts +++ b/src/mcp/install-mcp-server.ts @@ -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 } = { diff --git a/test/install-mcp-server.test.ts b/test/install-mcp-server.test.ts index 9d628504d..e16de5098 100644 --- a/test/install-mcp-server.test.ts +++ b/test/install-mcp-server.test.ts @@ -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", @@ -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",