mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-22 22:44:13 +08:00
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:
@@ -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,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,
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user