Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d79564db5e | |||
| a7a0e87fd8 | |||
| 7050b8de75 | |||
| 2fc3ddee16 |
+18
-2
@@ -18,8 +18,24 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: "node20"
|
using: "composite"
|
||||||
main: "entry.cjs"
|
steps:
|
||||||
|
- name: Setup Node.js 24
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: "24"
|
||||||
|
cache: "pnpm"
|
||||||
|
cache-dependency-path: ${{ github.action_path }}/pnpm-lock.yaml
|
||||||
|
- name: Setup pnpm
|
||||||
|
uses: pnpm/action-setup@v4
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pnpm install
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ github.action_path }}
|
||||||
|
- name: Run agent
|
||||||
|
run: node entry.ts
|
||||||
|
shell: bash
|
||||||
|
working-directory: ${{ github.action_path }}
|
||||||
|
|
||||||
branding:
|
branding:
|
||||||
icon: "code"
|
icon: "code"
|
||||||
|
|||||||
@@ -26164,7 +26164,7 @@ async function main(params) {
|
|||||||
// package.json
|
// package.json
|
||||||
var package_default = {
|
var package_default = {
|
||||||
name: "@pullfrog/action",
|
name: "@pullfrog/action",
|
||||||
version: "0.0.30",
|
version: "0.0.34",
|
||||||
type: "module",
|
type: "module",
|
||||||
files: [
|
files: [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
|||||||
+69
-133
@@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
import { writeFileSync } from "node:fs";
|
|
||||||
// Minimal GitHub Issue Comment MCP Server
|
// Minimal GitHub Issue Comment MCP Server
|
||||||
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
@@ -8,34 +7,10 @@ import { type } from "arktype";
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { resolveRepoContext } from "../utils/repo-context.ts";
|
import { resolveRepoContext } from "../utils/repo-context.ts";
|
||||||
|
|
||||||
// Simple error logging to file
|
const server = new McpServer({
|
||||||
function logError(message: string, error?: any) {
|
name: "Minimal GitHub Issue Comment Server",
|
||||||
const timestamp = new Date().toISOString();
|
version: "0.0.1",
|
||||||
const errorText = error ? `\nError: ${error.message}\nStack: ${error.stack}` : "";
|
});
|
||||||
const logEntry = `[${timestamp}] ${message}${errorText}\n`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
writeFileSync("/tmp/mcp-error.log", logEntry, { flag: "a" });
|
|
||||||
console.error(logEntry);
|
|
||||||
} catch (writeError) {
|
|
||||||
console.error(`Failed to write error log: ${writeError}`);
|
|
||||||
console.error(logEntry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let server: McpServer;
|
|
||||||
|
|
||||||
try {
|
|
||||||
logError("Creating MCP server...");
|
|
||||||
server = new McpServer({
|
|
||||||
name: "Minimal GitHub Issue Comment Server",
|
|
||||||
version: "0.0.1",
|
|
||||||
});
|
|
||||||
logError("MCP server created successfully");
|
|
||||||
} catch (error) {
|
|
||||||
logError("Failed to create MCP server", error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Define the schema for creating issue comments
|
// Define the schema for creating issue comments
|
||||||
const Comment = type({
|
const Comment = type({
|
||||||
@@ -43,114 +18,75 @@ const Comment = type({
|
|||||||
body: type.string.describe("the comment body content"),
|
body: type.string.describe("the comment body content"),
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
server.tool(
|
||||||
logError("Registering create_issue_comment tool...");
|
"create_issue_comment",
|
||||||
|
"Create a comment on a GitHub issue",
|
||||||
|
{
|
||||||
|
issueNumber: z.number().describe("the issue number to comment on"),
|
||||||
|
body: z.string().describe("the comment body content"),
|
||||||
|
},
|
||||||
|
async ({ issueNumber, body }) => {
|
||||||
|
try {
|
||||||
|
Comment.assert({ issueNumber, body });
|
||||||
|
|
||||||
server.tool(
|
const githubInstallationToken = process.env.GITHUB_INSTALLATION_TOKEN;
|
||||||
"create_issue_comment",
|
if (!githubInstallationToken) {
|
||||||
"Create a comment on a GitHub issue",
|
throw new Error("GITHUB_INSTALLATION_TOKEN environment variable is required");
|
||||||
{
|
|
||||||
issueNumber: z.number().describe("the issue number to comment on"),
|
|
||||||
body: z.string().describe("the comment body content"),
|
|
||||||
},
|
|
||||||
async ({ issueNumber, body }) => {
|
|
||||||
try {
|
|
||||||
Comment.assert({ issueNumber, body });
|
|
||||||
|
|
||||||
const githubInstallationToken = process.env.GITHUB_INSTALLATION_TOKEN;
|
|
||||||
if (!githubInstallationToken) {
|
|
||||||
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: repoContext.owner,
|
|
||||||
repo: repoContext.name,
|
|
||||||
issue_number: issueNumber,
|
|
||||||
body: body,
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: JSON.stringify(
|
|
||||||
{
|
|
||||||
success: true,
|
|
||||||
commentId: result.data.id,
|
|
||||||
url: result.data.html_url,
|
|
||||||
body: result.data.body,
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2
|
|
||||||
),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
||||||
logError("Tool execution failed", error);
|
|
||||||
return {
|
|
||||||
content: [
|
|
||||||
{
|
|
||||||
type: "text",
|
|
||||||
text: `Error creating comment: ${errorMessage}`,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
error: errorMessage,
|
|
||||||
isError: true,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
logError("Tool registered successfully");
|
// Resolve repository context from environment
|
||||||
} catch (error) {
|
const repoContext = resolveRepoContext();
|
||||||
logError("Failed to register tool", error);
|
|
||||||
process.exit(1);
|
const octokit = new Octokit({
|
||||||
}
|
auth: githubInstallationToken,
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await octokit.rest.issues.createComment({
|
||||||
|
owner: repoContext.owner,
|
||||||
|
repo: repoContext.name,
|
||||||
|
issue_number: issueNumber,
|
||||||
|
body: body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: JSON.stringify(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
commentId: result.data.id,
|
||||||
|
url: result.data.html_url,
|
||||||
|
body: result.data.body,
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2
|
||||||
|
),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
return {
|
||||||
|
content: [
|
||||||
|
{
|
||||||
|
type: "text",
|
||||||
|
text: `Error creating comment: ${errorMessage}`,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
error: errorMessage,
|
||||||
|
isError: true,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
async function runServer() {
|
async function runServer() {
|
||||||
try {
|
const transport = new StdioServerTransport();
|
||||||
logError("Starting MCP server...");
|
await server.connect(transport);
|
||||||
|
process.on("exit", () => {
|
||||||
const transport = new StdioServerTransport();
|
server.close();
|
||||||
logError("Transport created, attempting connection...");
|
});
|
||||||
|
|
||||||
await server.connect(transport);
|
|
||||||
logError("MCP server connected successfully");
|
|
||||||
|
|
||||||
process.on("exit", () => {
|
|
||||||
logError("Process exiting, closing server...");
|
|
||||||
server.close();
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on("SIGTERM", () => {
|
|
||||||
logError("SIGTERM received, closing server...");
|
|
||||||
server.close();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
|
|
||||||
process.on("SIGINT", () => {
|
|
||||||
logError("SIGINT received, closing server...");
|
|
||||||
server.close();
|
|
||||||
process.exit(0);
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
logError("Server startup failed", error);
|
|
||||||
process.exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logError("Initializing MCP server process...");
|
await runServer();
|
||||||
|
|
||||||
runServer().catch((error) => {
|
|
||||||
logError("Unhandled server error", error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pullfrog/action",
|
"name": "@pullfrog/action",
|
||||||
"version": "0.0.30",
|
"version": "0.0.34",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"files": [
|
"files": [
|
||||||
"index.js",
|
"index.js",
|
||||||
|
|||||||
Reference in New Issue
Block a user