Integrations
Works with local Git repositories to create Pull Requests and add comments, requiring proper repository state and branch management.
Provides tools for creating GitHub Pull Requests with structured titles and descriptions, and adding code review comments to specific lines in files within PRs.
Integrates with Jira ticket numbers, allowing them to be included in Pull Request titles when creating PRs through the GitHub integration.
GitHub PR Helper
這是一個 GitHub Pull Request 創建工具 MCP Service,使用 GitHub CLI (gh
) 命令行工具來創建 PR 和進行代碼審查,無需手動處理權限問題。
功能
該服務提供以下功能:
- 創建 GitHub Pull Request:根據提供的標題、描述、票號和目標分支,自動創建 GitHub PR。PR 標題將由 "標題 [票號]" 組成,PR 描述將由 PR 標題和描述組成。
- Code Review:在 PR 添加評論,方便進行代碼審查。
前置條件
- 安裝 GitHub CLI:
- macOS:
brew install gh
- Windows:
winget install --id GitHub.cli
- Linux: 參考 GitHub CLI 官方文檔
- macOS:
- 登入 GitHub CLI:按照提示完成登入流程。這將自動處理身份驗證,無需手動管理 token。Copy
安裝與設定
- 安裝依賴:Copy
- 配置環境變數(可選):
在
.env
檔案中設定以下變數:PORT
:服務器端口(預設為 3000)
使用方式
HTTP 服務
開發模式
生產模式
MCP 服務
API 端點
HTTP API
POST /api/github/pr
:創建 GitHub Pull Request- 請求體:Copy
- 請求體:
POST /api/github/pr/comment
:在 PR 添加評論- 請求體:Copy
- 請求體:
MCP 工具
create_pull_request
:創建 GitHub Pull Request- 參數:
repoPath
:本地 Git 倉庫路徑title
:PR 標題description
:PR 描述ticketNumber
:票號baseBranch
:目標分支
- 參數:
add_pr_comment
:在 PR 添加評論- 參數:
repoPath
:本地 Git 倉庫路徑baseBranch
:比較的基準分支filePath
:文件路徑lineNumber
:行號comment
:評論內容
- 參數:
安裝到 AI 助手
安裝到 Roo Code (VSCode)
- 確保已經安裝並設定好 Roo Code 擴充功能。
- 找到 Roo Code 的 MCP 設定檔案:Copy
- 編輯該檔案,在
mcpServers
物件中添加以下配置:Copy - 儲存檔案後,重新啟動 VSCode。
- 在 Roo Code 中,你現在應該可以使用
create_pull_request
和add_pr_comment
工具。
安裝到 Claude (Anthropic)
- 找到 Claude 的設定檔案:Copy
- 編輯該檔案,在
mcpServers
物件中添加以下配置:Copy - 儲存檔案後,重新啟動 Claude 應用程式。
- 在 Claude 中,你現在應該可以使用
create_pull_request
和add_pr_comment
工具。
安裝到 Windsurf
- 找到 Winsurf 的設定檔案,通常位於:如果找不到這個檔案,可以嘗試搜尋:CopyCopy
- 編輯該檔案,在
mcpServers
物件中添加以下配置:Copy - 如果
mcpServers
物件不存在,則需要創建它:Copy - 儲存檔案後,重新啟動 Winsurf。
- 在 Winsurf 中,你現在應該可以使用
create_pull_request
和add_pr_comment
工具。
安裝到 Cursor
方法一:通過 GUI 設定(推薦)
- 在 Cursor 中,打開設定頁面。
- 找到 MCP 服務設定區域,點擊添加新服務。
- 填寫以下欄位:
- Name:
github-pr-helper
(服務名稱) - Type:
command
(選擇命令類型) - Command:
node /Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js
(MCP 服務路徑)
- Name:
- 儲存設定後,重新啟動 Cursor。
- 在 Cursor 中,你現在應該可以使用
create_pull_request
和add_pr_comment
工具。
方法二:通過編輯設定檔案
- 找到 Cursor 的設定檔案:Copy
- 編輯該檔案,添加或修改
cursor.experimental.mcp.servers
設定:Copy - 儲存檔案後,重新啟動 Cursor。
- 在 Cursor 中,你現在應該可以使用
create_pull_request
和add_pr_comment
工具。
使用範例
在 AI 助手中,你可以使用以下提示來創建 GitHub PR:
你也可以使用以下提示在 PR 添加評論:
注意事項
- 使用此工具前,請確保你已經:
- 使用
gh auth login
登入 GitHub CLI - 在本地 Git 倉庫中創建並切換到了你想要提交 PR 的分支
- 已經提交了所有更改
- 已經將分支推送到遠程倉庫
- 使用
- 此工具使用 GitHub CLI (
gh
) 來處理 GitHub 相關操作,無需手動管理 token,大大簡化了權限管理。 - 如果遇到權限問題,請確保你已經正確登入 GitHub CLI,可以通過以下命令檢查登入狀態:Copy
This server cannot be installed
An MCP service that enables creating GitHub Pull Requests and adding code review comments using GitHub CLI, eliminating the need to manually handle authentication and permissions.