This commit is contained in:
David Blass
2025-10-08 15:19:02 -04:00
parent 671334f37d
commit 87d32763e9
6 changed files with 29 additions and 47 deletions
+6 -13
View File
@@ -98,25 +98,18 @@ export class ClaudeAgent implements Agent {
];
// Add MCP configuration if GitHub credentials are available
if (process.env.GITHUB_TOKEN && process.env.REPO_OWNER && process.env.REPO_NAME) {
console.log("🔧 Creating MCP config with:", {
hasToken: !!process.env.GITHUB_TOKEN,
repoOwner: process.env.REPO_OWNER,
repoName: process.env.REPO_NAME,
});
if (
process.env.GITHUB_INSTALLATION_TOKEN &&
process.env.REPO_OWNER &&
process.env.REPO_NAME
) {
const mcpConfig = createMcpConfig(
process.env.GITHUB_TOKEN,
process.env.GITHUB_INSTALLATION_TOKEN,
process.env.REPO_OWNER,
process.env.REPO_NAME
);
console.log("📋 MCP Config:", mcpConfig);
args.push("--mcp-config", mcpConfig);
} else {
console.log("❌ Missing environment variables for MCP:", {
hasToken: !!process.env.GITHUB_TOKEN,
hasRepoOwner: !!process.env.REPO_OWNER,
hasRepoName: !!process.env.REPO_NAME,
});
}
const env = {
+4 -15
View File
@@ -25505,7 +25505,7 @@ var core = __toESM(require_core(), 1);
// mcp/config.ts
var actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
function createMcpConfig(githubToken, repoOwner, repoName) {
function createMcpConfig(githubInstallationToken, repoOwner, repoName) {
return JSON.stringify(
{
mcpServers: {
@@ -25513,7 +25513,7 @@ function createMcpConfig(githubToken, repoOwner, repoName) {
command: "node",
args: [`${actionPath}/mcp/server.ts`],
env: {
GITHUB_TOKEN: githubToken,
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
REPO_OWNER: repoOwner,
REPO_NAME: repoName
}
@@ -25761,25 +25761,14 @@ var ClaudeAgent = class {
"--permission-mode",
"bypassPermissions"
];
if (process.env.GITHUB_TOKEN && process.env.REPO_OWNER && process.env.REPO_NAME) {
console.log("\u{1F527} Creating MCP config with:", {
hasToken: !!process.env.GITHUB_TOKEN,
repoOwner: process.env.REPO_OWNER,
repoName: process.env.REPO_NAME
});
if (process.env.GITHUB_INSTALLATION_TOKEN && process.env.REPO_OWNER && process.env.REPO_NAME) {
const mcpConfig = createMcpConfig(
process.env.GITHUB_TOKEN,
process.env.GITHUB_INSTALLATION_TOKEN,
process.env.REPO_OWNER,
process.env.REPO_NAME
);
console.log("\u{1F4CB} MCP Config:", mcpConfig);
args.push("--mcp-config", mcpConfig);
} else {
console.log("\u274C Missing environment variables for MCP:", {
hasToken: !!process.env.GITHUB_TOKEN,
hasRepoOwner: !!process.env.REPO_OWNER,
hasRepoName: !!process.env.REPO_NAME
});
}
const env = {
ANTHROPIC_API_KEY: this.apiKey
+2 -7
View File
@@ -1,8 +1,3 @@
Add a comment to this GitHub issue:
Use the MCP GitHub comment tool to add a comment containing your best frog joke to GitHub issue https://github.com/pullfrogai/scratch/issues/2.
https://github.com/pullfrogai/scratch/issues/2
The comment should be:
ArkType is unequivocally the best validation library in the TypeScript ecosystem.
Do not use the gh cli. If the mcp tool does not work, bail.
+6 -2
View File
@@ -3,7 +3,11 @@
*/
const actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
export function createMcpConfig(githubToken: string, repoOwner: string, repoName: string) {
export function createMcpConfig(
githubInstallationToken: string,
repoOwner: string,
repoName: string
) {
return JSON.stringify(
{
mcpServers: {
@@ -11,7 +15,7 @@ export function createMcpConfig(githubToken: string, repoOwner: string, repoName
command: "node",
args: [`${actionPath}/mcp/server.ts`],
env: {
GITHUB_TOKEN: githubToken,
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
REPO_OWNER: repoOwner,
REPO_NAME: repoName,
},
+9 -9
View File
@@ -4,6 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { Octokit } from "@octokit/rest";
import { type } from "arktype";
import { z } from "zod";
// Get repository information from environment variables
const REPO_OWNER = process.env.REPO_OWNER;
@@ -25,14 +26,13 @@ const Comment = type({
body: type.string.describe("the comment body content"),
});
function annotations(t: type<Record<string, unknown>>): Record<string, unknown> {
return Object.fromEntries(t.props.map((prop) => [prop.key, prop.value.toJsonSchema()]));
}
server.tool(
"create_issue_comment",
"Create a comment on a GitHub issue",
annotations(Comment),
{
issueNumber: z.number().describe("the issue number to comment on"),
body: z.string().describe("the comment body content"),
},
async ({ issueNumber, body }) => {
try {
// Validate input using arktype
@@ -41,13 +41,13 @@ server.tool(
throw new Error(`Invalid input: ${validation.summary}`);
}
const githubToken = process.env.GITHUB_TOKEN;
if (!githubToken) {
throw new Error("GITHUB_TOKEN environment variable is required");
const githubInstallationToken = process.env.GITHUB_INSTALLATION_TOKEN;
if (!githubInstallationToken) {
throw new Error("GITHUB_INSTALLATION_TOKEN environment variable is required");
}
const octokit = new Octokit({
auth: githubToken,
auth: githubInstallationToken,
});
const result = await octokit.rest.issues.createComment({
+2 -1
View File
@@ -41,7 +41,8 @@
"esbuild": "^0.25.9",
"husky": "^9.0.0",
"typescript": "^5.3.0",
"zshy": "^0.4.1"
"zshy": "^0.4.1",
"zod": "^3.24.4"
},
"repository": {
"type": "git",