Improve prInfo. Fix prompt duplication

This commit is contained in:
Colin McDonnell
2026-01-21 03:12:44 +00:00
committed by pullfrog[bot]
parent 01ee59a96c
commit 22704dda35
3 changed files with 81 additions and 23 deletions
+33 -8
View File
@@ -121084,32 +121084,57 @@ function CreatePullRequestTool(ctx) {
}
// mcp/prInfo.ts
var CLOSING_ISSUES_QUERY = `
query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
closingIssuesReferences(first: 10) {
nodes { number title }
}
}
}
}
`;
var PullRequestInfo = type({
pull_number: type.number.describe("The pull request number to fetch")
});
function PullRequestInfoTool(ctx) {
return tool({
name: "get_pull_request",
description: "Retrieve PR metadata (number, title, state, base/head branches, fork status). To checkout a PR branch locally, use checkout_pr instead.",
description: "Retrieve PR metadata (title, body, state, branches, author, labels, linked issues). To checkout a PR branch locally, use checkout_pr instead.",
parameters: PullRequestInfo,
execute: execute(async ({ pull_number }) => {
const pr = await ctx.octokit.rest.pulls.get({
owner: ctx.repo.owner,
repo: ctx.repo.name,
pull_number
});
const data = pr.data;
const [restResponse, graphqlResponse] = await Promise.all([
ctx.octokit.rest.pulls.get({
owner: ctx.repo.owner,
repo: ctx.repo.name,
pull_number
}),
ctx.octokit.graphql(CLOSING_ISSUES_QUERY, {
owner: ctx.repo.owner,
repo: ctx.repo.name,
number: pull_number
})
]);
const data = restResponse.data;
const isFork = data.head.repo?.full_name !== data.base.repo.full_name;
const closingIssues = graphqlResponse.repository.pullRequest.closingIssuesReferences.nodes;
return {
number: data.number,
url: data.html_url,
title: data.title,
body: data.body,
state: data.state,
draft: data.draft,
merged: data.merged,
maintainerCanModify: data.maintainer_can_modify,
base: data.base.ref,
head: data.head.ref,
isFork
isFork,
author: data.user?.login,
assignees: data.assignees?.map((a) => a.login),
labels: data.labels.map((l) => l.name),
closingIssues: closingIssues.map((i) => ({ number: i.number, title: i.title }))
};
})
});