N8n 连接 Discourse MCP 配置方法

,

以下使用示例域名,配置时替换为自己的地址:

  • Discourse:https://forum.example.com

  • n8n:https://n8n.example.com

1. 配置 Discourse

在 Discourse 中启用 MCP 服务器,配置 OAuth 客户端:

本文以 n8n 为 Client ID。客户端允许的回调地址需与 n8n 凭据页面显示的 OAuth Redirect URL 完全一致:

https://n8n.example.com/rest/oauth2-credential/callback

2. 配置 n8n OAuth 凭据

在 MCP Client 节点中选择 MCP OAuth2,创建或编辑凭据。

设置项 配置值
Use Dynamic Client Registration 关闭
Grant Type PKCE
Authorization URL https://forum.example.com/oauth2/mcp/authorize
Access Token URL https://forum.example.com/oauth2/mcp/token
Client ID n8n,与 Discourse 客户端配置一致
Authentication Body
Resource URL https://forum.example.com/mcp
Auth URI Query Parameters 留空

Scope 按工作流需要填写,多项权限之间用空格分隔。本次成功连接使用的是:

mcp:profile:read mcp:content:read mcp:content:write mcp:moderation:read mcp:moderation:write
Scope 权限
mcp:profile:read 读取用户资料
mcp:content:read 读取内容
mcp:content:write 写入内容
mcp:moderation:read 读取管理信息
mcp:moderation:write 执行管理操作

只需要查询内容的工作流,选择相应的读取权限即可。

**Client Secret:**本次配置保留原有字段值,未单独验证留空后的表现。

3. 配置 MCP Client 节点

设置项 配置值
Server Transport HTTP Streamable
MCP Endpoint URL https://forum.example.com/mcp
Authentication MCP OAuth2
Credential 上一步保存的 OAuth 凭据

4. 完成授权

  1. 保存凭据,点击 Connect。

  2. 在 Discourse 授权页核对客户端、回调地址和请求权限。

  3. 点击 授权。

  4. 返回 n8n,凭据页面显示 Account connected,即 OAuth 连接成功。

连接成功后,可在 MCP Client 节点中选择工具并配置参数。