From 2c0d6b1a1e832a95d8178398fe6b83a8ea27b356 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 01:06:00 +0000 Subject: [PATCH] fix: always load github_file_ops server regardless of allowed_tools - Only apply conditional loading to the github MCP server - Always load github_file_ops server as it contains essential tools - Update tests to reflect this behavior Co-authored-by: ashwin-ant --- src/mcp/install-mcp-server.ts | 41 +++++++++++++++------------------ test/install-mcp-server.test.ts | 4 ++-- 2 files changed, 20 insertions(+), 25 deletions(-) diff --git a/src/mcp/install-mcp-server.ts b/src/mcp/install-mcp-server.ts index a83acbe..ff20269 100644 --- a/src/mcp/install-mcp-server.ts +++ b/src/mcp/install-mcp-server.ts @@ -32,9 +32,6 @@ export async function prepareMcpConfig( const hasGitHubMcpTools = allowedToolsList.some((tool) => tool.startsWith("mcp__github__"), ); - const hasGitHubFileOpsTools = allowedToolsList.some((tool) => - tool.startsWith("mcp__github_file_ops__"), - ); // Start with an empty servers object const mcpServers: Record = {}; @@ -59,26 +56,24 @@ export async function prepareMcpConfig( // Always include github_file_ops server as it contains essential tools // (mcp__github_file_ops__commit_files, mcp__github_file_ops__update_claude_comment) - // These are in the BASE_ALLOWED_TOOLS - if (hasGitHubFileOpsTools || !allowedTools) { - mcpServers.github_file_ops = { - command: "bun", - args: [ - "run", - `${process.env.GITHUB_ACTION_PATH}/src/mcp/github-file-ops-server.ts`, - ], - env: { - GITHUB_TOKEN: githubToken, - REPO_OWNER: owner, - REPO_NAME: repo, - BRANCH_NAME: branch, - REPO_DIR: process.env.GITHUB_WORKSPACE || process.cwd(), - ...(claudeCommentId && { CLAUDE_COMMENT_ID: claudeCommentId }), - GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "", - IS_PR: process.env.IS_PR || "false", - }, - }; - } + // These are in the BASE_ALLOWED_TOOLS and should always be available + mcpServers.github_file_ops = { + command: "bun", + args: [ + "run", + `${process.env.GITHUB_ACTION_PATH}/src/mcp/github-file-ops-server.ts`, + ], + env: { + GITHUB_TOKEN: githubToken, + REPO_OWNER: owner, + REPO_NAME: repo, + BRANCH_NAME: branch, + REPO_DIR: process.env.GITHUB_WORKSPACE || process.cwd(), + ...(claudeCommentId && { CLAUDE_COMMENT_ID: claudeCommentId }), + GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "", + IS_PR: process.env.IS_PR || "false", + }, + }; const baseMcpConfig = { mcpServers, diff --git a/test/install-mcp-server.test.ts b/test/install-mcp-server.test.ts index 539c1fc..5f6d1b3 100644 --- a/test/install-mcp-server.test.ts +++ b/test/install-mcp-server.test.ts @@ -81,7 +81,7 @@ describe("prepareMcpConfig", () => { expect(parsed.mcpServers.github_file_ops).toBeDefined(); }); - test("should not include any MCP servers when no GitHub tools are allowed", async () => { + test("should include file_ops server even when no GitHub tools are allowed", async () => { const result = await prepareMcpConfig({ githubToken: "test-token", owner: "test-owner", @@ -93,7 +93,7 @@ describe("prepareMcpConfig", () => { const parsed = JSON.parse(result); expect(parsed.mcpServers).toBeDefined(); expect(parsed.mcpServers.github).not.toBeDefined(); - expect(parsed.mcpServers.github_file_ops).not.toBeDefined(); + expect(parsed.mcpServers.github_file_ops).toBeDefined(); }); test("should return base config when additional config is empty string", async () => {