From 340104d9cfc2d23edacc0d98b77d32140f46f0e6 Mon Sep 17 00:00:00 2001 From: km-anthropic Date: Fri, 1 Aug 2025 15:43:07 -0700 Subject: [PATCH] fix: use proper type guards instead of manual property checks Address review feedback by using isEntityContext() type guard instead of checking 'isPR' in context manually. This provides better type safety and uses the existing type guard infrastructure. --- src/mcp/install-mcp-server.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mcp/install-mcp-server.ts b/src/mcp/install-mcp-server.ts index aed4bce..eae5614 100644 --- a/src/mcp/install-mcp-server.ts +++ b/src/mcp/install-mcp-server.ts @@ -1,6 +1,7 @@ import * as core from "@actions/core"; import { GITHUB_API_URL, GITHUB_SERVER_URL } from "../github/api/config"; import type { GitHubContext } from "../github/context"; +import { isEntityContext } from "../github/context"; import { Octokit } from "@octokit/rest"; type PrepareConfigParams = { @@ -115,7 +116,7 @@ export async function prepareMcpConfig( const hasActionsReadPermission = context.inputs.additionalPermissions.get("actions") === "read"; - if ("isPR" in context && context.isPR && hasActionsReadPermission) { + if (isEntityContext(context) && context.isPR && hasActionsReadPermission) { // Verify the token actually has actions:read permission const actuallyHasPermission = await checkActionsReadPermission( process.env.ACTIONS_TOKEN || "", @@ -141,10 +142,9 @@ export async function prepareMcpConfig( GITHUB_TOKEN: process.env.ACTIONS_TOKEN, REPO_OWNER: owner, REPO_NAME: repo, - PR_NUMBER: - "entityNumber" in context - ? context.entityNumber?.toString() || "" - : "", + PR_NUMBER: isEntityContext(context) + ? context.entityNumber?.toString() || "" + : "", RUNNER_TEMP: process.env.RUNNER_TEMP || "/tmp", }, };