mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-01-23 15:04:13 +08:00
feat: add MCP servers to agent mode
- Update agent mode to use prepareMcpConfig instead of empty config - Update prepareMcpConfig to accept both ParsedGitHubContext and AutomationContext - Add type guards for context-specific properties (isPR, entityNumber) - This enables bot actors to use full MCP capabilities via workflow_dispatch
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import * as core from "@actions/core";
|
||||
import { GITHUB_API_URL, GITHUB_SERVER_URL } from "../github/api/config";
|
||||
import type { ParsedGitHubContext } from "../github/context";
|
||||
import type { GitHubContext } from "../github/context";
|
||||
import { Octokit } from "@octokit/rest";
|
||||
|
||||
type PrepareConfigParams = {
|
||||
@@ -12,7 +12,7 @@ type PrepareConfigParams = {
|
||||
additionalMcpConfig?: string;
|
||||
claudeCommentId?: string;
|
||||
allowedTools: string[];
|
||||
context: ParsedGitHubContext;
|
||||
context: GitHubContext;
|
||||
};
|
||||
|
||||
async function checkActionsReadPermission(
|
||||
@@ -115,7 +115,7 @@ export async function prepareMcpConfig(
|
||||
const hasActionsReadPermission =
|
||||
context.inputs.additionalPermissions.get("actions") === "read";
|
||||
|
||||
if (context.isPR && hasActionsReadPermission) {
|
||||
if ('isPR' in context && context.isPR && hasActionsReadPermission) {
|
||||
// Verify the token actually has actions:read permission
|
||||
const actuallyHasPermission = await checkActionsReadPermission(
|
||||
process.env.ACTIONS_TOKEN || "",
|
||||
@@ -141,7 +141,7 @@ export async function prepareMcpConfig(
|
||||
GITHUB_TOKEN: process.env.ACTIONS_TOKEN,
|
||||
REPO_OWNER: owner,
|
||||
REPO_NAME: repo,
|
||||
PR_NUMBER: context.entityNumber?.toString() || "",
|
||||
PR_NUMBER: 'entityNumber' in context ? context.entityNumber?.toString() || "" : "",
|
||||
RUNNER_TEMP: process.env.RUNNER_TEMP || "/tmp",
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user