8
n8n 中文网amn8n.com

Discord MCP服务器

高级

这是一个Building Blocks, AI, IT Ops领域的自动化工作流,包含 16 个节点。主要使用 DiscordTool, HttpRequestTool, McpTrigger 等节点,结合人工智能技术实现智能自动化。 通过 MCP 服务器使用自然语言控制 Discord 机器人

前置要求
  • Discord Bot Token 或 Webhook
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "ly8aZhPk5ZI8uB0Y",
  "meta": {
    "instanceId": "8931e7db592c2960ce253801ea290c1dc66e447734ce3d968310365665cefc80",
    "templateCredsSetupCompleted": true
  },
  "name": "Discord MCP服务器",
  "tags": [],
  "nodes": [
    {
      "id": "6e87d612-3006-4683-b978-87718f89257d",
      "name": "发送Discord消息到频道",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        360,
        280
      ],
      "webhookId": "90b1dca9-c742-4c7e-aef3-ba5a47c5f86d",
      "parameters": {
        "content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Channel', ``, 'string') }}"
        }
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "32a17a73-8953-4474-a49f-9d1cc0cc3eb2",
      "name": "为成员添加角色",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        -200,
        560
      ],
      "webhookId": "e41a85ec-3f16-44fc-ad87-4617c0d0f1c0",
      "parameters": {
        "role": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Role', ``, 'string') }}",
        "userId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('User', ``, 'string') }}"
        },
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "resource": "member",
        "operation": "roleAdd"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "688ea823-b8ea-4bbf-96cb-a64925fc29a9",
      "name": "从成员移除角色",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        -20,
        560
      ],
      "webhookId": "e41a85ec-3f16-44fc-ad87-4617c0d0f1c0",
      "parameters": {
        "role": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Role', ``, 'string') }}",
        "userId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('User', ``, 'string') }}"
        },
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "resource": "member",
        "operation": "roleRemove"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "1d8a14f1-8e63-4112-8076-15b4408c844f",
      "name": "Discord MCP服务器触发器",
      "type": "@n8n/n8n-nodes-langchain.mcpTrigger",
      "position": [
        20,
        -280
      ],
      "webhookId": "404f083e-f3f4-4358-83ef-9804099ee253",
      "parameters": {
        "path": "404f083e-f3f4-4358-83ef-9804099ee253"
      },
      "typeVersion": 1
    },
    {
      "id": "67602807-3126-4564-8fed-912551eb824b",
      "name": "通过服务器ID获取服务器频道",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        420,
        20
      ],
      "webhookId": "73c49e13-24e9-4481-902d-a5f3e1f50032",
      "parameters": {
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "options": {},
        "operation": "getAll",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "5f1c3039-7042-48b8-997c-12bcaa6a1256",
      "name": "通过服务器ID获取服务器成员",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        -80,
        20
      ],
      "webhookId": "ebd6d7dd-bcfa-4546-b48d-5e7862129caa",
      "parameters": {
        "after": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('After', ``, 'string') }}",
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "options": {},
        "resource": "member",
        "returnAll": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Return_All', ``, 'boolean') }}"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "ece7a065-36bb-4667-aa61-610e54f0b22d",
      "name": "发送私信并等待回复",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        -280,
        280
      ],
      "webhookId": "90b1dca9-c742-4c7e-aef3-ba5a47c5f86d",
      "parameters": {
        "sendTo": "user",
        "userId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('User', ``, 'string') }}"
        },
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "resource": "message",
        "operation": "sendAndWait",
        "responseType": "freeText"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c37d0478-5b00-4d21-b0fd-7e2fa34708ec",
      "name": "发送到频道并等待回复",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        580,
        280
      ],
      "webhookId": "90b1dca9-c742-4c7e-aef3-ba5a47c5f86d",
      "parameters": {
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "message": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "options": {},
        "resource": "message",
        "channelId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Channel', ``, 'string') }}"
        },
        "operation": "sendAndWait",
        "responseType": "freeText"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "fb8091b5-114b-422e-be5a-6413d9aec599",
      "name": "向用户发送私信",
      "type": "n8n-nodes-base.discordTool",
      "position": [
        -60,
        280
      ],
      "webhookId": "90b1dca9-c742-4c7e-aef3-ba5a47c5f86d",
      "parameters": {
        "sendTo": "user",
        "userId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('User', ``, 'string') }}"
        },
        "content": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Message', ``, 'string') }}",
        "guildId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('Server', ``, 'string') }}"
        },
        "options": {},
        "resource": "message"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "6f61b18a-8d96-4acb-994a-45ef32c10f16",
      "name": "获取Discord服务器ID",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        180,
        -60
      ],
      "parameters": {
        "url": "https://discord.com/api/v10/users/@me/guilds",
        "options": {},
        "authentication": "predefinedCredentialType",
        "toolDescription": "Retrieves the ID of each discord server the bot is in.",
        "nodeCredentialType": "discordBotApi"
      },
      "credentials": {
        "discordBotApi": {
          "id": "SJhr2V3Xw4B3fVqW",
          "name": "Gopher"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3fe9b9ab-d9c8-4414-b3a4-01dace75da77",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        100,
        -60
      ],
      "parameters": {
        "height": 600,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c886422d-f034-49dc-ad77-bc6e1cd495a8",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        360,
        280
      ],
      "parameters": {
        "width": 300,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "36d5bcc3-f9f2-4161-83d8-d76083ea9e8c",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        280
      ],
      "parameters": {
        "width": 300,
        "height": 240,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "65b6d13e-6f97-4b4c-9a0d-85b07b666c81",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        560
      ],
      "parameters": {
        "width": 520,
        "height": 360,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "e39211f7-7471-4b0b-a253-79b1e3026354",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -60
      ],
      "parameters": {
        "width": 280,
        "content": "一旦我们获得要交互的服务器的服务器ID,我们就可以获取该机器人可以看到的服务器所有成员。"
      },
      "typeVersion": 1
    },
    {
      "id": "84f36c6d-c990-48d0-9328-32a40c803956",
      "name": "便签5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        -60
      ],
      "parameters": {
        "width": 280,
        "content": "一旦我们获得要交互的服务器的服务器ID,我们就可以获取该机器人可以看到的所有频道。"
      },
      "typeVersion": 1
    }
  ],
  "active": true,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "bedf1c45-22f0-422c-8d77-ab058c1cceab",
  "connections": {
    "Send DM to User": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Add Role To Member": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get Discord Server IDs": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Remove Role from member": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send DM and Wait for reply": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send Discord Message to Channel": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get members of server by server ID": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Send to Channel and Wait for Reply": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Get channels of server by server ID": {
      "ai_tool": [
        [
          {
            "node": "Discord MCP Server Trigger",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 构建模块, 人工智能, IT 运维

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量16
分类3
节点类型4
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
David Ashby

David Ashby

@cfomodz

A hacker by nature, programmer by trade ⚒️ I'm looking to collaborate on things that save human labor 📫 How to reach me Github👇 -> Discord

外部链接
在 n8n.io 查看

分享此工作流