auto-labeling

This commit is contained in:
David Blass
2025-12-09 17:02:57 -05:00
parent 7ffd7297c3
commit 305fc9b0dd
7 changed files with 137 additions and 87 deletions
+27
View File
@@ -0,0 +1,27 @@
import { type } from "arktype";
import { contextualize, tool } from "./shared.ts";
export const AddLabelsParams = type({
issue_number: type.number.describe("the issue or PR number to add labels to"),
labels: type.string.array().atLeastLength(1).describe("array of label names to add"),
});
export const AddLabelsTool = tool({
name: "add_labels",
description:
"Add labels to a GitHub issue or pull request. Only use labels that already exist in the repository.",
parameters: AddLabelsParams,
execute: contextualize(async ({ issue_number, labels }, ctx) => {
const result = await ctx.octokit.rest.issues.addLabels({
owner: ctx.owner,
repo: ctx.name,
issue_number,
labels,
});
return {
success: true,
labels: result.data.map((label) => label.name),
};
}),
});
+18 -5
View File
@@ -1,7 +1,7 @@
import "./arkConfig.ts";
// this must be imported first
import { createServer } from "node:net";
import { FastMCP } from "fastmcp";
import { FastMCP, type Tool } from "fastmcp";
import { ghPullfrogMcpName } from "../external.ts";
import { GetCheckSuiteLogsTool } from "./checkSuite.ts";
import {
@@ -15,12 +15,18 @@ import { IssueTool } from "./issue.ts";
import { GetIssueCommentsTool } from "./issueComments.ts";
import { GetIssueEventsTool } from "./issueEvents.ts";
import { IssueInfoTool } from "./issueInfo.ts";
import { AddLabelsTool } from "./labels.ts";
import { PullRequestTool } from "./pr.ts";
import { PullRequestInfoTool } from "./prInfo.ts";
import { ReviewTool } from "./review.ts";
import { GetReviewCommentsTool, ListPullRequestReviewsTool } from "./reviewComments.ts";
import { SelectModeTool } from "./selectMode.ts";
import { addTools, initMcpContext, type McpInitContext } from "./shared.ts";
import {
addTools,
initMcpContext,
isProgressCommentDisabled,
type McpInitContext,
} from "./shared.ts";
/**
* Find an available port starting from the given port
@@ -64,9 +70,8 @@ export async function startMcpHttpServer(
version: "0.0.1",
});
addTools(server, [
const tools: Tool<any, any>[] = [
SelectModeTool,
ReportProgressTool,
CreateCommentTool,
EditCommentTool,
ReplyToReviewCommentTool,
@@ -81,7 +86,15 @@ export async function startMcpHttpServer(
ListPullRequestReviewsTool,
GetCheckSuiteLogsTool,
DebugShellCommandTool,
]);
AddLabelsTool,
];
// only include ReportProgressTool if progress comment is not disabled
if (!isProgressCommentDisabled()) {
tools.push(ReportProgressTool);
}
addTools(server, tools);
const port = await findAvailablePort(3764);
const host = "127.0.0.1";
+4
View File
@@ -35,6 +35,10 @@ export function getMcpContext(): McpContext {
};
}
export function isProgressCommentDisabled(): boolean {
return mcpInitContext?.payload.disableProgressComment === true;
}
export const tool = <const params>(toolDef: Tool<any, StandardSchemaV1<params>>) => toolDef;
/**