use GITHUB_REPOSITORY for context

This commit is contained in:
ssalbdivad
2025-10-09 17:04:03 -04:00
parent 9459803aaa
commit 3e7122611c
7 changed files with 381 additions and 398 deletions
+1 -7
View File
@@ -3,11 +3,7 @@
*/
const actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
export function createMcpConfig(
githubInstallationToken: string,
repoOwner: string,
repoName: string
) {
export function createMcpConfig(githubInstallationToken: string) {
return JSON.stringify(
{
mcpServers: {
@@ -16,8 +12,6 @@ export function createMcpConfig(
args: [`${actionPath}/mcp/server.ts`],
env: {
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
REPO_OWNER: repoOwner,
REPO_NAME: repoName,
},
},
},
+6 -11
View File
@@ -5,15 +5,7 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
import { Octokit } from "@octokit/rest";
import { type } from "arktype";
import { z } from "zod";
// Get repository information from environment variables
const REPO_OWNER = process.env.REPO_OWNER;
const REPO_NAME = process.env.REPO_NAME;
if (!REPO_OWNER || !REPO_NAME) {
console.error("Error: REPO_OWNER and REPO_NAME environment variables are required");
process.exit(1);
}
import { resolveRepoContext } from "../utils/repo-context.ts";
const server = new McpServer({
name: "Minimal GitHub Issue Comment Server",
@@ -42,13 +34,16 @@ server.tool(
throw new Error("GITHUB_INSTALLATION_TOKEN environment variable is required");
}
// Resolve repository context from environment
const repoContext = resolveRepoContext();
const octokit = new Octokit({
auth: githubInstallationToken,
});
const result = await octokit.rest.issues.createComment({
owner: REPO_OWNER,
repo: REPO_NAME,
owner: repoContext.owner,
repo: repoContext.name,
issue_number: issueNumber,
body: body,
});