GitHub PR Helper
STDIOGitHub Pull Request creation tool using GitHub CLI for automated PR management.
GitHub Pull Request creation tool using GitHub CLI for automated PR management.
這是一個 GitHub Pull Request 創建工具 MCP Service,使用 GitHub CLI (gh
) 命令行工具來創建 PR 和進行代碼審查,無需手動處理權限問題。
該服務提供以下功能:
創建 GitHub Pull Request:根據提供的標題、描述、票號和目標分支,自動創建 GitHub PR。PR 標題將由 "標題 [票號]" 組成,PR 描述將由 PR 標題和描述組成。
Code Review:在 PR 添加評論,方便進行代碼審查。
安裝 GitHub CLI:
brew install gh
winget install --id GitHub.cli
登入 GitHub CLI:
gh auth login
按照提示完成登入流程。這將自動處理身份驗證,無需手動管理 token。
安裝依賴:
npm install
配置環境變數(可選):
在 .env
檔案中設定以下變數:
PORT
:服務器端口(預設為 3000)npm run dev
npm start
npm run mcp
POST /api/github/pr
:創建 GitHub Pull Request
{ "repoPath": "本地 Git 倉庫路徑", "title": "PR 標題", "description": "PR 描述", "ticketNumber": "票號", "baseBranch": "目標分支" }
POST /api/github/pr/comment
:在 PR 添加評論
{ "repoPath": "本地 Git 倉庫路徑", "baseBranch": "比較的基準分支", "filePath": "文件路徑", "lineNumber": 10, "comment": "評論內容" }
create_pull_request
:創建 GitHub Pull Request
repoPath
:本地 Git 倉庫路徑title
:PR 標題description
:PR 描述ticketNumber
:票號baseBranch
:目標分支add_pr_comment
:在 PR 添加評論
repoPath
:本地 Git 倉庫路徑baseBranch
:比較的基準分支filePath
:文件路徑lineNumber
:行號comment
:評論內容確保已經安裝並設定好 Roo Code 擴充功能。
找到 Roo Code 的 MCP 設定檔案:
/Users/aaron/Library/Application Support/Code/User/globalStorage/rooveterinaryinc.roo-cline/settings/cline_mcp_settings.json
編輯該檔案,在 mcpServers
物件中添加以下配置:
"github-pr-helper": { "command": "node", "args": ["/Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js"], "disabled": false, "alwaysAllow": [] }
儲存檔案後,重新啟動 VSCode。
在 Roo Code 中,你現在應該可以使用 create_pull_request
和 add_pr_comment
工具。
找到 Claude 的設定檔案:
/Users/aaron/Library/Application Support/Claude/claude_desktop_config.json
編輯該檔案,在 mcpServers
物件中添加以下配置:
"github-pr-helper": { "command": "node", "args": ["/Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js"], "disabled": false, "alwaysAllow": [] }
儲存檔案後,重新啟動 Claude 應用程式。
在 Claude 中,你現在應該可以使用 create_pull_request
和 add_pr_comment
工具。
找到 Winsurf 的設定檔案,通常位於:
/Users/aaron/Library/Application Support/Winsurf/winsurf_config.json
如果找不到這個檔案,可以嘗試搜尋:
find ~/Library/Application\ Support -name "*winsurf*" -type f
編輯該檔案,在 mcpServers
物件中添加以下配置:
"github-pr-helper": { "command": "node", "args": ["/Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js"], "disabled": false, "alwaysAllow": [] }
如果 mcpServers
物件不存在,則需要創建它:
{ "mcpServers": { "github-pr-helper": { "command": "node", "args": ["/Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js"], "disabled": false, "alwaysAllow": [] } } }
儲存檔案後,重新啟動 Winsurf。
在 Winsurf 中,你現在應該可以使用 create_pull_request
和 add_pr_comment
工具。
在 Cursor 中,打開設定頁面。
找到 MCP 服務設定區域,點擊添加新服務。
填寫以下欄位:
github-pr-helper
(服務名稱)command
(選擇命令類型)node /Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js
(MCP 服務路徑)儲存設定後,重新啟動 Cursor。
在 Cursor 中,你現在應該可以使用 create_pull_request
和 add_pr_comment
工具。
找到 Cursor 的設定檔案:
/Users/aaron/Library/Application Support/Cursor/User/settings.json
編輯該檔案,添加或修改 cursor.experimental.mcp.servers
設定:
"cursor.experimental.mcp.servers": { "github-pr-helper": { "command": "node", "args": ["/Users/aaron/CascadeProjects/app-github-pr-helper/src/mcp-server.js"], "disabled": false, "alwaysAllow": [] } }
儲存檔案後,重新啟動 Cursor。
在 Cursor 中,你現在應該可以使用 create_pull_request
和 add_pr_comment
工具。
在 AI 助手中,你可以使用以下提示來創建 GitHub PR:
請使用 create_pull_request 工具創建 GitHub Pull Request。
參數:
{
"repoPath": "/path/to/your/repo",
"title": "實現新功能",
"description": "這個 PR 實現了新功能,包括...",
"ticketNumber": "JIRA-123",
"baseBranch": "main"
}
你也可以使用以下提示在 PR 添加評論:
請使用 add_pr_comment 工具在 PR 添加評論。
參數:
{
"repoPath": "/path/to/your/repo",
"baseBranch": "main",
"filePath": "src/index.js",
"lineNumber": 42,
"comment": "這裡可以使用更簡潔的寫法"
}
使用此工具前,請確保你已經:
gh auth login
登入 GitHub CLI此工具使用 GitHub CLI (gh
) 來處理 GitHub 相關操作,無需手動管理 token,大大簡化了權限管理。
如果遇到權限問題,請確保你已經正確登入 GitHub CLI,可以通過以下命令檢查登入狀態:
gh auth status