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 <ashwin-ant@users.noreply.github.com>
This commit is contained in:
claude[bot]
2025-06-04 01:06:00 +00:00
committed by Ashwin Bhat
parent b4a5fb3de6
commit 2c0d6b1a1e
2 changed files with 20 additions and 25 deletions

View File

@@ -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<string, any> = {};
@@ -59,8 +56,7 @@ 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) {
// These are in the BASE_ALLOWED_TOOLS and should always be available
mcpServers.github_file_ops = {
command: "bun",
args: [
@@ -78,7 +74,6 @@ export async function prepareMcpConfig(
IS_PR: process.env.IS_PR || "false",
},
};
}
const baseMcpConfig = {
mcpServers,

View File

@@ -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 () => {