fix: add GITHUB_API_URL to all Octokit client instantiations (#243)

Not all Octokit client instantiations were respecting GITHUB_API_URL, so
these tools would fail on enterprise.
This commit is contained in:
Allen Li
2025-07-11 10:46:23 -04:00
committed by GitHub
parent cefe963a6b
commit 0f9a2c4dc3
2 changed files with 5 additions and 1 deletions

View File

@@ -3,6 +3,7 @@
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod"; import { z } from "zod";
import { GITHUB_API_URL } from "../github/api/config";
import { mkdir, writeFile } from "fs/promises"; import { mkdir, writeFile } from "fs/promises";
import { Octokit } from "@octokit/rest"; import { Octokit } from "@octokit/rest";
@@ -54,6 +55,7 @@ server.tool(
try { try {
const client = new Octokit({ const client = new Octokit({
auth: GITHUB_TOKEN, auth: GITHUB_TOKEN,
baseUrl: GITHUB_API_URL,
}); });
// Get the PR to find the head SHA // Get the PR to find the head SHA
@@ -142,6 +144,7 @@ server.tool(
try { try {
const client = new Octokit({ const client = new Octokit({
auth: GITHUB_TOKEN, auth: GITHUB_TOKEN,
baseUrl: GITHUB_API_URL,
}); });
// Get jobs for this workflow run // Get jobs for this workflow run
@@ -209,6 +212,7 @@ server.tool(
try { try {
const client = new Octokit({ const client = new Octokit({
auth: GITHUB_TOKEN, auth: GITHUB_TOKEN,
baseUrl: GITHUB_API_URL,
}); });
const response = await client.actions.downloadJobLogsForWorkflowRun({ const response = await client.actions.downloadJobLogsForWorkflowRun({

View File

@@ -20,7 +20,7 @@ async function checkActionsReadPermission(
repo: string, repo: string,
): Promise<boolean> { ): Promise<boolean> {
try { try {
const client = new Octokit({ auth: token }); const client = new Octokit({ auth: token, baseUrl: GITHUB_API_URL });
// Try to list workflow runs - this requires actions:read // Try to list workflow runs - this requires actions:read
// We use per_page=1 to minimize the response size // We use per_page=1 to minimize the response size