github-repos-manager-mcp
Version:
Model Context Protocol (MCP) server that enables your MCP client (e.g., Claude Desktop, Cline, Roo Code, Cursor, Windsurf, etc.) to interact with GitHub repositories using your GitHub personal access token.
50 lines (45 loc) • 1.13 kB
JavaScript
// src/formatters/pull-requests.cjs
function formatListPRsOutput(prs, owner, repo, state) {
if (!Array.isArray(prs)) {
return {
content: [
{
type: "text",
text: `Error: Could not retrieve ${state} pull requests for ${owner}/${repo}.`,
},
],
isError: true,
};
}
if (prs.length === 0) {
return {
content: [
{
type: "text",
text: `No ${state} pull requests found in ${owner}/${repo}`,
},
],
};
}
const formatted = prs
.map(
(pr) =>
`**#${pr.number}** ${pr.title}\n` +
`State: ${pr.state} | Author: ${pr.user.login}\n` +
`Base: ${pr.base.ref} ← Head: ${pr.head.ref}\n` +
`Created: ${new Date(pr.created_at).toLocaleDateString()}\n` +
`URL: ${pr.html_url}\n`
)
.join("\n\n"); // Changed from \n to \n\n for better readability
return {
content: [
{
type: "text",
text: `Found ${prs.length} ${state} pull requests in ${owner}/${repo}:\n\n${formatted}`,
},
],
};
}
module.exports = {
formatListPRsOutput,
};