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:
km-anthropic
2025-08-01 13:54:35 -07:00
parent b4cc5cd6c5
commit 7cc3cff20b
2 changed files with 39 additions and 45 deletions

View File

@@ -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",
},
};