mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 06:54:13 +08:00
Fix MCP config not being passed to Claude CLI
The MCP servers (including github_comment server) were configured but not passed to Claude. This caused the "update_claude_comment" tool to be unavailable. Changes: - Write MCP config to a file at $RUNNER_TEMP/claude-mcp-config.json - Add mcp_config_file output from prepare.ts - Pass MCP config file via --mcp-config flag in claude_args - Use fs/promises writeFile to match codebase conventions
This commit is contained in:
@@ -160,7 +160,7 @@ runs:
|
|||||||
INPUT_PROMPT_FILE: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
INPUT_PROMPT_FILE: ${{ runner.temp }}/claude-prompts/claude-prompt.txt
|
||||||
INPUT_SETTINGS: ${{ inputs.settings }}
|
INPUT_SETTINGS: ${{ inputs.settings }}
|
||||||
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
|
INPUT_TIMEOUT_MINUTES: ${{ inputs.timeout_minutes }}
|
||||||
INPUT_CLAUDE_ARGS: ${{ inputs.claude_args }}
|
INPUT_CLAUDE_ARGS: ${{ steps.prepare.outputs.mcp_config_file && format('--mcp-config {0} {1}', steps.prepare.outputs.mcp_config_file, inputs.claude_args) || inputs.claude_args }}
|
||||||
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands
|
INPUT_EXPERIMENTAL_SLASH_COMMANDS_DIR: ${{ github.action_path }}/slash-commands
|
||||||
|
|
||||||
# Model configuration
|
# Model configuration
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import * as core from "@actions/core";
|
import * as core from "@actions/core";
|
||||||
|
import { writeFile } from "fs/promises";
|
||||||
import { setupGitHubToken } from "../github/token";
|
import { setupGitHubToken } from "../github/token";
|
||||||
import { checkWritePermissions } from "../github/validation/permissions";
|
import { checkWritePermissions } from "../github/validation/permissions";
|
||||||
import { createOctokit } from "../github/api/client";
|
import { createOctokit } from "../github/api/client";
|
||||||
@@ -57,8 +58,11 @@ async function run() {
|
|||||||
githubToken,
|
githubToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
// Set the MCP config output
|
// Write MCP config to a file and set the file path as output
|
||||||
|
const mcpConfigPath = `${process.env.RUNNER_TEMP}/claude-mcp-config.json`;
|
||||||
|
await writeFile(mcpConfigPath, result.mcpConfig);
|
||||||
core.setOutput("mcp_config", result.mcpConfig);
|
core.setOutput("mcp_config", result.mcpConfig);
|
||||||
|
core.setOutput("mcp_config_file", mcpConfigPath);
|
||||||
|
|
||||||
// Step 6: Get system prompt from mode if available
|
// Step 6: Get system prompt from mode if available
|
||||||
if (mode.getSystemPrompt) {
|
if (mode.getSystemPrompt) {
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ const defaultRepository = {
|
|||||||
full_name: "test-owner/test-repo",
|
full_name: "test-owner/test-repo",
|
||||||
};
|
};
|
||||||
|
|
||||||
type MockContextOverrides = Omit<Partial<ParsedGitHubContext>, 'inputs'> & {
|
type MockContextOverrides = Omit<Partial<ParsedGitHubContext>, "inputs"> & {
|
||||||
inputs?: Partial<ParsedGitHubContext['inputs']>;
|
inputs?: Partial<ParsedGitHubContext["inputs"]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createMockContext = (
|
export const createMockContext = (
|
||||||
@@ -46,15 +46,15 @@ export const createMockContext = (
|
|||||||
inputs: defaultInputs,
|
inputs: defaultInputs,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mergedInputs = overrides.inputs
|
const mergedInputs = overrides.inputs
|
||||||
? { ...defaultInputs, ...overrides.inputs }
|
? { ...defaultInputs, ...overrides.inputs }
|
||||||
: defaultInputs;
|
: defaultInputs;
|
||||||
|
|
||||||
return { ...baseContext, ...overrides, inputs: mergedInputs };
|
return { ...baseContext, ...overrides, inputs: mergedInputs };
|
||||||
};
|
};
|
||||||
|
|
||||||
type MockAutomationOverrides = Omit<Partial<AutomationContext>, 'inputs'> & {
|
type MockAutomationOverrides = Omit<Partial<AutomationContext>, "inputs"> & {
|
||||||
inputs?: Partial<AutomationContext['inputs']>;
|
inputs?: Partial<AutomationContext["inputs"]>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const createMockAutomationContext = (
|
export const createMockAutomationContext = (
|
||||||
@@ -70,7 +70,7 @@ export const createMockAutomationContext = (
|
|||||||
inputs: defaultInputs,
|
inputs: defaultInputs,
|
||||||
};
|
};
|
||||||
|
|
||||||
const mergedInputs = overrides.inputs
|
const mergedInputs = overrides.inputs
|
||||||
? { ...defaultInputs, ...overrides.inputs }
|
? { ...defaultInputs, ...overrides.inputs }
|
||||||
: defaultInputs;
|
: defaultInputs;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user