Fix: Use correct MCP server names and add inline comment server for PRs

- Changed github-comment-server to github_comment (correct registration name)
- Added github_inline_comment server for PR contexts
- Updated workflow to use correct tool names (mcp__github_inline_comment__)
- Simplified prompt to use inline comments instead of full PR reviews
This commit is contained in:
km-anthropic
2025-08-12 08:54:10 -07:00
parent 708a97434b
commit 05d9889165
3 changed files with 52 additions and 11 deletions

View File

@@ -22,11 +22,9 @@ jobs:
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
prompt: |
Please review this PR using the GitHub review tools. You MUST:
1. First, use mcp__github-comment-server__get_pull_request_diff to get the PR changes
2. Then, use mcp__github-comment-server__create_pending_pull_request_review to start a review
3. Use mcp__github-comment-server__add_comment_to_pending_review to add inline comments where needed
4. Finally, use mcp__github-comment-server__submit_pending_pull_request_review with event="COMMENT" to submit the review
Please review this PR and provide comprehensive feedback.
Use the mcp__github_inline_comment__create_inline_comment tool to add inline comments on specific lines where you have feedback.
In your review, provide thoughtful feedback on:
- Code quality and best practices
@@ -35,6 +33,6 @@ jobs:
- Overall architecture and design decisions
- Documentation consistency
IMPORTANT: You must submit the review as a COMMENT, not APPROVE or REQUEST_CHANGES.
Be constructive and specific in your feedback.
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
claude_args: "--allowedTools mcp__github-comment-server__create_pending_pull_request_review,mcp__github-comment-server__add_comment_to_pending_review,mcp__github-comment-server__submit_pending_pull_request_review,mcp__github-comment-server__get_pull_request_diff"
claude_args: "--allowedTools mcp__github_inline_comment__create_inline_comment,Read,Grep,Glob"

View File

@@ -111,10 +111,29 @@ export async function prepareMcpConfig(
};
}
// CI server is included when we have a workflow token and context is a PR
const hasWorkflowToken = !!process.env.DEFAULT_WORKFLOW_TOKEN;
// Include inline comment server for experimental review mode
if (context.inputs.mode === "experimental-review" && context.isPR) {
baseMcpConfig.mcpServers.github_inline_comment = {
command: "bun",
args: [
"run",
`${process.env.GITHUB_ACTION_PATH}/src/mcp/github-inline-comment-server.ts`,
],
env: {
GITHUB_TOKEN: githubToken,
REPO_OWNER: owner,
REPO_NAME: repo,
PR_NUMBER: context.entityNumber?.toString() || "",
GITHUB_API_URL: GITHUB_API_URL,
},
};
}
if (context.isPR && hasWorkflowToken) {
// Only add CI server if we have actions:read permission and we're in a PR context
const hasActionsReadPermission =
context.inputs.additionalPermissions.get("actions") === "read";
if (context.isPR && hasActionsReadPermission) {
// Verify the token actually has actions:read permission
const actuallyHasPermission = await checkActionsReadPermission(
process.env.DEFAULT_WORKFLOW_TOKEN || "",

View File

@@ -67,7 +67,7 @@ export const agentMode: Mode = {
// without requiring users to manually configure the MCP server
const mcpConfig: any = {
mcpServers: {
"github-comment-server": {
github_comment: {
command: "bun",
args: [
"run",
@@ -77,6 +77,7 @@ export const agentMode: Mode = {
GITHUB_TOKEN: githubToken || "",
REPO_OWNER: context.repository.owner,
REPO_NAME: context.repository.repo,
CLAUDE_COMMENT_ID: process.env.CLAUDE_COMMENT_ID || "",
GITHUB_EVENT_NAME: process.env.GITHUB_EVENT_NAME || "",
GITHUB_API_URL:
process.env.GITHUB_API_URL || "https://api.github.com",
@@ -85,6 +86,29 @@ export const agentMode: Mode = {
},
};
// Include inline comment server for PR contexts
if (context.eventName === "pull_request" || context.eventName === "pull_request_review") {
// Get PR number from the context payload
const prNumber = (context as any).payload?.pull_request?.number ||
(context as any).entityNumber ||
"";
mcpConfig.mcpServers.github_inline_comment = {
command: "bun",
args: [
"run",
`${process.env.GITHUB_ACTION_PATH}/src/mcp/github-inline-comment-server.ts`,
],
env: {
GITHUB_TOKEN: githubToken || "",
REPO_OWNER: context.repository.owner,
REPO_NAME: context.repository.repo,
PR_NUMBER: prNumber.toString(),
GITHUB_API_URL: process.env.GITHUB_API_URL || "https://api.github.com",
},
};
}
// Add user-provided additional MCP config if any
const additionalMcpConfig = process.env.MCP_CONFIG || "";
if (additionalMcpConfig.trim()) {