mcp-github-helper
GitHub PR Helper is a tool for creating GitHub Pull Requests and conducting code reviews using the GitHub CLI, eliminating manual permission handling.
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:
gh auth login
按照提示完成登入流程。這將自動處理身份驗證,無需手動管理 token。
安裝與設定
-
安裝依賴:
npm install
-
配置環境變數(可選): 在
.env
檔案中設定以下變數:PORT
:服務器端口(預設為 3000)
使用方式
HTTP 服務
開發模式
npm run dev
生產模式
npm start
MCP 服務
npm run mcp
API 端點
HTTP API
-
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": "評論內容" }
- 請求體:
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 設定檔案:
/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 (Anthropic)
-
找到 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
工具。
安裝到 Windsurf
-
找到 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
方法一:通過 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 的設定檔案:
/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 - 在本地 Git 倉庫中創建並切換到了你想要提交 PR 的分支
- 已經提交了所有更改
- 已經將分支推送到遠程倉庫
- 使用
-
此工具使用 GitHub CLI (
gh
) 來處理 GitHub 相關操作,無需手動管理 token,大大簡化了權限管理。 -
如果遇到權限問題,請確保你已經正確登入 GitHub CLI,可以通過以下命令檢查登入狀態:
gh auth status
Related MCP Servers
View all developer_tools servers →context7
by upstash
Context7 MCP provides up-to-date, version-specific documentation and code examples directly into your prompt, enhancing the capabilities of LLMs by ensuring they use the latest information.
Sequential Thinking
by modelcontextprotocol
An MCP server implementation that provides a tool for dynamic and reflective problem-solving through a structured thinking process.
git-mcp
by idosal
GitMCP is a free, open-source, remote Model Context Protocol (MCP) server that transforms GitHub projects into documentation hubs, enabling AI tools to access up-to-date documentation and code.
Everything MCP Server
by modelcontextprotocol
The Everything MCP Server is a comprehensive test server designed to demonstrate the full capabilities of the Model Context Protocol (MCP). It is not intended for production use but serves as a valuable tool for developers building MCP clients.
exa-mcp-server
by exa-labs
A Model Context Protocol (MCP) server allows AI assistants to use the Exa AI Search API for real-time web searches in a secure manner.
repomix
by yamadashy
Repomix is a tool that packs your codebase into AI-friendly formats, making it easier to use with AI tools like LLMs.
mcpdoc
by langchain-ai
MCP LLMS-TXT Documentation Server provides a structured way to manage and retrieve LLM documentation using the Model Context Protocol.