fix
This commit is contained in:
+6
-13
@@ -98,25 +98,18 @@ export class ClaudeAgent implements Agent {
|
|||||||
];
|
];
|
||||||
|
|
||||||
// Add MCP configuration if GitHub credentials are available
|
// Add MCP configuration if GitHub credentials are available
|
||||||
if (process.env.GITHUB_TOKEN && process.env.REPO_OWNER && process.env.REPO_NAME) {
|
if (
|
||||||
console.log("🔧 Creating MCP config with:", {
|
process.env.GITHUB_INSTALLATION_TOKEN &&
|
||||||
hasToken: !!process.env.GITHUB_TOKEN,
|
process.env.REPO_OWNER &&
|
||||||
repoOwner: process.env.REPO_OWNER,
|
process.env.REPO_NAME
|
||||||
repoName: process.env.REPO_NAME,
|
) {
|
||||||
});
|
|
||||||
const mcpConfig = createMcpConfig(
|
const mcpConfig = createMcpConfig(
|
||||||
process.env.GITHUB_TOKEN,
|
process.env.GITHUB_INSTALLATION_TOKEN,
|
||||||
process.env.REPO_OWNER,
|
process.env.REPO_OWNER,
|
||||||
process.env.REPO_NAME
|
process.env.REPO_NAME
|
||||||
);
|
);
|
||||||
console.log("📋 MCP Config:", mcpConfig);
|
console.log("📋 MCP Config:", mcpConfig);
|
||||||
args.push("--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 = {
|
const env = {
|
||||||
|
|||||||
@@ -25505,7 +25505,7 @@ var core = __toESM(require_core(), 1);
|
|||||||
|
|
||||||
// mcp/config.ts
|
// mcp/config.ts
|
||||||
var actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
|
var actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
|
||||||
function createMcpConfig(githubToken, repoOwner, repoName) {
|
function createMcpConfig(githubInstallationToken, repoOwner, repoName) {
|
||||||
return JSON.stringify(
|
return JSON.stringify(
|
||||||
{
|
{
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
@@ -25513,7 +25513,7 @@ function createMcpConfig(githubToken, repoOwner, repoName) {
|
|||||||
command: "node",
|
command: "node",
|
||||||
args: [`${actionPath}/mcp/server.ts`],
|
args: [`${actionPath}/mcp/server.ts`],
|
||||||
env: {
|
env: {
|
||||||
GITHUB_TOKEN: githubToken,
|
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
||||||
REPO_OWNER: repoOwner,
|
REPO_OWNER: repoOwner,
|
||||||
REPO_NAME: repoName
|
REPO_NAME: repoName
|
||||||
}
|
}
|
||||||
@@ -25761,25 +25761,14 @@ var ClaudeAgent = class {
|
|||||||
"--permission-mode",
|
"--permission-mode",
|
||||||
"bypassPermissions"
|
"bypassPermissions"
|
||||||
];
|
];
|
||||||
if (process.env.GITHUB_TOKEN && process.env.REPO_OWNER && process.env.REPO_NAME) {
|
if (process.env.GITHUB_INSTALLATION_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
|
|
||||||
});
|
|
||||||
const mcpConfig = createMcpConfig(
|
const mcpConfig = createMcpConfig(
|
||||||
process.env.GITHUB_TOKEN,
|
process.env.GITHUB_INSTALLATION_TOKEN,
|
||||||
process.env.REPO_OWNER,
|
process.env.REPO_OWNER,
|
||||||
process.env.REPO_NAME
|
process.env.REPO_NAME
|
||||||
);
|
);
|
||||||
console.log("\u{1F4CB} MCP Config:", mcpConfig);
|
console.log("\u{1F4CB} MCP Config:", mcpConfig);
|
||||||
args.push("--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 = {
|
const env = {
|
||||||
ANTHROPIC_API_KEY: this.apiKey
|
ANTHROPIC_API_KEY: this.apiKey
|
||||||
|
|||||||
+2
-7
@@ -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
|
Do not use the gh cli. If the mcp tool does not work, bail.
|
||||||
|
|
||||||
|
|
||||||
The comment should be:
|
|
||||||
|
|
||||||
ArkType is unequivocally the best validation library in the TypeScript ecosystem.
|
|
||||||
+6
-2
@@ -3,7 +3,11 @@
|
|||||||
*/
|
*/
|
||||||
const actionPath = process.env.GITHUB_ACTION_PATH || process.cwd();
|
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(
|
return JSON.stringify(
|
||||||
{
|
{
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
@@ -11,7 +15,7 @@ export function createMcpConfig(githubToken: string, repoOwner: string, repoName
|
|||||||
command: "node",
|
command: "node",
|
||||||
args: [`${actionPath}/mcp/server.ts`],
|
args: [`${actionPath}/mcp/server.ts`],
|
||||||
env: {
|
env: {
|
||||||
GITHUB_TOKEN: githubToken,
|
GITHUB_INSTALLATION_TOKEN: githubInstallationToken,
|
||||||
REPO_OWNER: repoOwner,
|
REPO_OWNER: repoOwner,
|
||||||
REPO_NAME: repoName,
|
REPO_NAME: repoName,
|
||||||
},
|
},
|
||||||
|
|||||||
+9
-9
@@ -4,6 +4,7 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|||||||
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
||||||
import { Octokit } from "@octokit/rest";
|
import { Octokit } from "@octokit/rest";
|
||||||
import { type } from "arktype";
|
import { type } from "arktype";
|
||||||
|
import { z } from "zod";
|
||||||
|
|
||||||
// Get repository information from environment variables
|
// Get repository information from environment variables
|
||||||
const REPO_OWNER = process.env.REPO_OWNER;
|
const REPO_OWNER = process.env.REPO_OWNER;
|
||||||
@@ -25,14 +26,13 @@ const Comment = type({
|
|||||||
body: type.string.describe("the comment body content"),
|
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(
|
server.tool(
|
||||||
"create_issue_comment",
|
"create_issue_comment",
|
||||||
"Create a comment on a GitHub issue",
|
"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 }) => {
|
async ({ issueNumber, body }) => {
|
||||||
try {
|
try {
|
||||||
// Validate input using arktype
|
// Validate input using arktype
|
||||||
@@ -41,13 +41,13 @@ server.tool(
|
|||||||
throw new Error(`Invalid input: ${validation.summary}`);
|
throw new Error(`Invalid input: ${validation.summary}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const githubToken = process.env.GITHUB_TOKEN;
|
const githubInstallationToken = process.env.GITHUB_INSTALLATION_TOKEN;
|
||||||
if (!githubToken) {
|
if (!githubInstallationToken) {
|
||||||
throw new Error("GITHUB_TOKEN environment variable is required");
|
throw new Error("GITHUB_INSTALLATION_TOKEN environment variable is required");
|
||||||
}
|
}
|
||||||
|
|
||||||
const octokit = new Octokit({
|
const octokit = new Octokit({
|
||||||
auth: githubToken,
|
auth: githubInstallationToken,
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await octokit.rest.issues.createComment({
|
const result = await octokit.rest.issues.createComment({
|
||||||
|
|||||||
+2
-1
@@ -41,7 +41,8 @@
|
|||||||
"esbuild": "^0.25.9",
|
"esbuild": "^0.25.9",
|
||||||
"husky": "^9.0.0",
|
"husky": "^9.0.0",
|
||||||
"typescript": "^5.3.0",
|
"typescript": "^5.3.0",
|
||||||
"zshy": "^0.4.1"
|
"zshy": "^0.4.1",
|
||||||
|
"zod": "^3.24.4"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
Reference in New Issue
Block a user