构建自定义GitHub MCP服务器
高级
这是一个Engineering, Building Blocks, AI领域的自动化工作流,包含 19 个节点。主要使用 Set, Github, Switch, Aggregate, HttpRequest 等节点,结合人工智能技术实现智能自动化。 构建自定义GitHub MCP服务器
前置要求
- •GitHub Personal Access Token
- •可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"meta": {
"instanceId": "408f9fb9940c3cb18ffdef0e0150fe342d6e655c3a9fac21f0f644e8bedabcd9",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "b0224d75-763d-4f06-8aa3-3f1b4c5ca96d",
"name": "当被其他工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
800,
500
],
"parameters": {
"workflowInputs": {
"values": [
{
"name": "operation"
},
{
"name": "repo"
},
{
"name": "issueNumber"
},
{
"name": "text"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "dd0e2ff0-af31-4503-a276-65682a3009a8",
"name": "操作",
"type": "n8n-nodes-base.switch",
"position": [
980,
500
],
"parameters": {
"rules": {
"values": [
{
"outputKey": "getLatestIssues",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "81b134bc-d671-4493-b3ad-8df9be3f49a6",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.operation }}",
"rightValue": "getLatestIssues"
}
]
},
"renameOutput": true
},
{
"outputKey": "getIssueComments",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "8d57914f-6587-4fb3-88e0-aa1de6ba56c1",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.operation }}",
"rightValue": "getIssueComments"
}
]
},
"renameOutput": true
},
{
"outputKey": "addIssueComment",
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "7c38f238-213a-46ec-aefe-22e0bcb8dffc",
"operator": {
"name": "filter.operator.equals",
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.operation }}",
"rightValue": "addIssueComment"
}
]
},
"renameOutput": true
}
]
},
"options": {}
},
"typeVersion": 3.2
},
{
"id": "bc35f181-e3a4-4aa4-8132-26cd4a6ced8a",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
120
],
"parameters": {
"color": 7,
"width": 680,
"height": 660,
"content": "## 1. 设置 MCP 服务器触发器"
},
"typeVersion": 1
},
{
"id": "e4c8d338-08ad-4c47-935b-b5ea53dc59d7",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
700,
120
],
"parameters": {
"color": 7,
"width": 560,
"height": 300,
"content": "## 2. 使用 Github 节点构建简单支持工具"
},
"typeVersion": 1
},
{
"id": "5d6a5f6d-24e8-48ed-8409-8cd24cc2e668",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
0,
0
],
"parameters": {
"color": 5,
"width": 380,
"height": 100,
"content": "### 始终验证您的服务器!"
},
"typeVersion": 1
},
{
"id": "fd11a97d-cd3d-4356-81d3-4266f65ef606",
"name": "Github MCP 服务器",
"type": "@n8n/n8n-nodes-langchain.mcpTrigger",
"position": [
160,
300
],
"webhookId": "61848df7-3619-4ccf-831b-d6408e0d6519",
"parameters": {
"path": "61848df7-3619-4ccf-831b-d6408e0d6519"
},
"typeVersion": 1
},
{
"id": "b8fd8431-71fa-44d1-abdb-b50e6a8a940f",
"name": "获取最新问题",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
160,
540
],
"parameters": {
"name": "getLatestIssues",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"description": "从 github 仓库检索最新问题",
"workflowInputs": {
"value": {
"repo": "n8n-io/n8n",
"text": "null",
"operation": "getLatestIssues",
"issueNumber": "null"
},
"schema": [
{
"id": "operation",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "operation",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "repo",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "repo",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "issueNumber",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "issueNumber",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "text",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "text",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.1
},
{
"id": "a11f7b8a-aaa9-41de-a693-6d0463e48d10",
"name": "添加问题评论",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
480,
540
],
"parameters": {
"name": "addIssueComment",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"description": "调用此工具为 github 问题添加评论",
"workflowInputs": {
"value": {
"repo": "n8n-io/n8n",
"text": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('text', ``, 'string') }}",
"operation": "addIssueComment",
"issueNumber": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('issueNumber', ``, 'string') }}"
},
"schema": [
{
"id": "operation",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "operation",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "repo",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "repo",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "issueNumber",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "issueNumber",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "text",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "text",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.1
},
{
"id": "57e8370b-caf0-4632-98e3-78316b2cb262",
"name": "简化问题",
"type": "n8n-nodes-base.set",
"position": [
1500,
320
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6d5eb037-7e52-4595-a2da-bb183674ea2a",
"name": "issue_number",
"type": "number",
"value": "={{ $json.number }}"
},
{
"id": "3d365039-f012-444c-a383-c6c70fb93e9d",
"name": "title",
"type": "string",
"value": "={{ $json.title }}"
},
{
"id": "20a1b658-c56c-4578-9b1f-350b454da2d2",
"name": "url",
"type": "string",
"value": "={{ $json.url }}"
},
{
"id": "0eb6930d-2ea9-4a83-bab7-5f673e79c1d1",
"name": "reported_by",
"type": "string",
"value": "={{ $json.user.login }}"
},
{
"id": "2d71c6de-ab54-4721-9e1c-5193350a5110",
"name": "state",
"type": "string",
"value": "={{ $json.state }}"
},
{
"id": "474166aa-4bfa-4230-bce4-28df2de47bed",
"name": "created_at",
"type": "string",
"value": "={{ $json.created_at }}"
},
{
"id": "e4784fc1-4438-4d7a-a2f5-86be077ae7ae",
"name": "updated_at",
"type": "string",
"value": "={{ $json.updated_at }}"
},
{
"id": "e0639b60-4a08-406a-be8e-c3565a519f0c",
"name": "body",
"type": "string",
"value": "={{ $json.body }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "632b1286-7e4a-457b-8544-6ca8f2affb9f",
"name": "聚合结果",
"type": "n8n-nodes-base.aggregate",
"position": [
1680,
320
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "response"
},
"typeVersion": 1
},
{
"id": "447327bc-0b42-47ec-80c0-14d6f521d047",
"name": "获取问题评论",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
320,
600
],
"parameters": {
"name": "getIssueComments",
"workflowId": {
"__rl": true,
"mode": "id",
"value": "={{ $workflow.id }}"
},
"description": "检索问题及相关评论和讨论",
"workflowInputs": {
"value": {
"repo": "n8n-io/n8n",
"text": "null",
"operation": "getIssueComments",
"issueNumber": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('issueNumber', ``, 'string') }}"
},
"schema": [
{
"id": "operation",
"type": "string",
"display": true,
"required": false,
"displayName": "operation",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "repo",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "repo",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "issueNumber",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "issueNumber",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "text",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "text",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
}
},
"typeVersion": 2.1
},
{
"id": "f5c59a05-54e4-4aa5-bef3-192e07adffb0",
"name": "获取评论",
"type": "n8n-nodes-base.httpRequest",
"position": [
1500,
500
],
"parameters": {
"url": "={{ $json.comments_url }}",
"options": {},
"authentication": "predefinedCredentialType",
"nodeCredentialType": "githubApi"
},
"credentials": {
"githubApi": {
"id": "kA70YRmLeHDqZbXA",
"name": "GitHub account"
}
},
"typeVersion": 4.2
},
{
"id": "3fe80456-9fb5-47bb-80d9-484123571a8f",
"name": "简化评论",
"type": "n8n-nodes-base.set",
"position": [
1680,
500
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "6e09ed44-a72c-4915-84f4-0796b45158a7",
"name": "id",
"type": "number",
"value": "={{ $json.id }}"
},
{
"id": "76c34251-7f40-42bc-bb98-17e7fe52d9ed",
"name": "issue_url",
"type": "string",
"value": "={{ $json.issue_url }}"
},
{
"id": "1094dd36-d18d-4ada-ac49-5347f0f245ae",
"name": "user",
"type": "string",
"value": "={{ $json.user.login }}"
},
{
"id": "59b50536-4e0a-46bc-919b-685066253f45",
"name": "author_association",
"type": "string",
"value": "={{ $json.author_association }}"
},
{
"id": "6253bae9-aaff-4a88-9e5a-64126ed80cc4",
"name": "body",
"type": "string",
"value": "={{ $json.body }}"
},
{
"id": "3944598d-8204-45a0-9e0b-448d3cfa5a87",
"name": "created_at",
"type": "string",
"value": "={{ $json.created_at }}"
},
{
"id": "3f395b51-6e57-4d07-9cf9-9a03e7a40c51",
"name": "updated_at",
"type": "string",
"value": "={{ $json.updated_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7926ae2d-5408-4b10-88f3-e6ebfe5f9619",
"name": "聚合评论",
"type": "n8n-nodes-base.aggregate",
"position": [
1860,
500
],
"parameters": {
"options": {},
"aggregate": "aggregateAllItemData",
"destinationFieldName": "response"
},
"typeVersion": 1
},
{
"id": "af2b4c0f-4a83-44a2-bae8-b3c45861d820",
"name": "获取多个问题",
"type": "n8n-nodes-base.github",
"position": [
1320,
320
],
"webhookId": "e08dcf3e-66bb-4ba5-a868-d8c41a98bc95",
"parameters": {
"limit": 10,
"owner": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[0] }}"
},
"resource": "repository",
"repository": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[1] }}"
},
"getRepositoryIssuesFilters": {
"sort": "created"
}
},
"credentials": {
"githubApi": {
"id": "kA70YRmLeHDqZbXA",
"name": "GitHub account"
}
},
"typeVersion": 1.1
},
{
"id": "50568171-5f46-4338-a799-a1854ebc425e",
"name": "获取单个问题",
"type": "n8n-nodes-base.github",
"position": [
1320,
500
],
"webhookId": "e08dcf3e-66bb-4ba5-a868-d8c41a98bc95",
"parameters": {
"owner": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[0] }}"
},
"operation": "get",
"repository": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[1] }}"
},
"issueNumber": "={{ $json.issueNumber }}"
},
"credentials": {
"githubApi": {
"id": "kA70YRmLeHDqZbXA",
"name": "GitHub account"
}
},
"typeVersion": 1.1
},
{
"id": "1a12fadd-e436-4731-ad66-b9d9cdb9c61c",
"name": "创建评论",
"type": "n8n-nodes-base.github",
"position": [
1320,
680
],
"webhookId": "e08dcf3e-66bb-4ba5-a868-d8c41a98bc95",
"parameters": {
"body": "={{ $json.text }}",
"owner": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[0] }}"
},
"operation": "createComment",
"repository": {
"__rl": true,
"mode": "name",
"value": "={{ $json.repo.split('/')[1] }}"
},
"issueNumber": "={{ $json.issueNumber }}"
},
"credentials": {
"githubApi": {
"id": "kA70YRmLeHDqZbXA",
"name": "GitHub account"
}
},
"typeVersion": 1.1
},
{
"id": "b90acf56-c871-49de-95d0-1c6ceb1799f7",
"name": "获取响应",
"type": "n8n-nodes-base.set",
"position": [
1500,
680
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "65631bfa-7448-4188-8cc1-b812361ae9b1",
"name": "response",
"type": "string",
"value": "ok"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "da360f61-4251-4f0f-8081-3b502e9981c9",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-460,
-480
],
"parameters": {
"width": 440,
"height": 1260,
"content": "## 试试看!"
},
"typeVersion": 1
}
],
"pinData": {},
"connections": {
"Operation": {
"main": [
[
{
"node": "Get Many Issues",
"type": "main",
"index": 0
}
],
[
{
"node": "Get Single Issue",
"type": "main",
"index": 0
}
],
[
{
"node": "Create Comment",
"type": "main",
"index": 0
}
]
]
},
"Get Comments": {
"main": [
[
{
"node": "Simplify Comments",
"type": "main",
"index": 0
}
]
]
},
"Create Comment": {
"main": [
[
{
"node": "Get Response",
"type": "main",
"index": 0
}
]
]
},
"Get Many Issues": {
"main": [
[
{
"node": "Simplify Issues",
"type": "main",
"index": 0
}
]
]
},
"Simplify Issues": {
"main": [
[
{
"node": "Aggregate Results",
"type": "main",
"index": 0
}
]
]
},
"Get Single Issue": {
"main": [
[
{
"node": "Get Comments",
"type": "main",
"index": 0
}
]
]
},
"Add Issue Comment": {
"ai_tool": [
[
{
"node": "Github MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Latest Issues": {
"ai_tool": [
[
{
"node": "Github MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"Simplify Comments": {
"main": [
[
{
"node": "Aggregate Comments",
"type": "main",
"index": 0
}
]
]
},
"Get Issue Comments": {
"ai_tool": [
[
{
"node": "Github MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Operation",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 工程, 构建模块, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
构建自定义API MCP服务器
构建自定义API MCP服务器
If
Set
Filter
+8
25 节点Jimleuk
工程
构建自定义YouTube MCP服务器
构建自定义YouTube MCP服务器
Set
Switch
Aggregate
+5
20 节点Jimleuk
构建模块
构建自定义Qdrant向量存储MCP服务器
构建自定义Qdrant向量存储MCP服务器
If
Set
Code
+14
44 节点Jimleuk
构建模块
构建自定义Google Drive MCP服务器
构建自定义Google Drive MCP服务器
Set
Switch
Google Drive
+7
17 节点Jimleuk
构建模块
构建自定义n8n工作流MCP服务器
构建自定义n8n工作流MCP服务器
If
N8n
Set
+15
46 节点Jimleuk
其他
构建自定义PostgreSQL MCP服务器
构建自定义PostgreSQL MCP服务器
Switch
Postgres
Postgres Tool
+4
15 节点Jimleuk
构建模块
工作流信息
难度等级
高级
节点数量19
分类3
节点类型9
作者
Jimleuk
@jimleukFreelance consultant based in the UK specialising in AI-powered automations. I work with select clients tackling their most challenging projects. For business enquiries, send me an email at hello@jimle.uk LinkedIn: https://www.linkedin.com/in/jimleuk/ X/Twitter: https://x.com/jimle_uk
外部链接
在 n8n.io 查看 →
分享此工作流