refactor mcp and add instructions prefix

This commit is contained in:
David Blass
2025-10-17 22:26:24 -04:00
parent 7f1566d9c2
commit c668578c6f
12 changed files with 91 additions and 96 deletions
+6 -18
View File
@@ -1,7 +1,5 @@
import { Octokit } from "@octokit/rest";
import { type } from "arktype";
import { resolveRepoContext } from "../utils/repo-context.ts";
import { tool } from "./shared.ts";
import { getMcpContext, tool } from "./shared.ts";
export const Comment = type({
issueNumber: type.number.describe("the issue number to comment on"),
@@ -12,22 +10,12 @@ export const CommentTool = tool({
name: "create_issue_comment",
description: "Create a comment on a GitHub issue",
parameters: Comment,
execute: async ({ issueNumber, body }: { issueNumber: number; body: string }) => {
execute: async ({ issueNumber, body }) => {
const ctx = getMcpContext();
try {
const githubInstallationToken = process.env.GITHUB_INSTALLATION_TOKEN;
if (!githubInstallationToken) {
throw new Error("GITHUB_INSTALLATION_TOKEN environment variable is required");
}
const repoContext = resolveRepoContext();
const octokit = new Octokit({
auth: githubInstallationToken,
});
const result = await octokit.rest.issues.createComment({
owner: repoContext.owner,
repo: repoContext.name,
const result = await ctx.octokit.rest.issues.createComment({
owner: ctx.owner,
repo: ctx.name,
issue_number: issueNumber,
body: body,
});