构建您自己的PostgreSQL MCP服务器(无可视化界面)
高级
这是一个Support, AI, IT Ops领域的自动化工作流,包含 21 个节点。主要使用 Switch, Postgres, PostgresTool, Agent, ToolThink 等节点,结合人工智能技术实现智能自动化。 使用Claude和DeepSeek的PostgreSQL对话代理(多KPI、安全)
前置要求
- •PostgreSQL 数据库连接信息
- •Anthropic API Key
使用的节点 (21)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "Wsw6HdSAFk8y7jxh",
"meta": {
"instanceId": "1fc85153dfc4ea22a8172f0d7347fa9f591f71e2064dc331f7bdc1d7ee422e7a",
"templateId": "3631",
"templateCredsSetupCompleted": true
},
"name": "构建您自己的 PostgreSQL MCP 服务器(无可视化界面)",
"tags": [],
"nodes": [
{
"id": "735a96e6-a254-4c0c-8268-88c33db886e8",
"name": "获取表结构",
"type": "n8n-nodes-base.postgresTool",
"position": [
-40,
920
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "aba773b1-8fd0-4b5a-953f-c2de44029b68",
"name": "列出数据表",
"type": "n8n-nodes-base.postgresTool",
"position": [
60,
1020
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "217bac36-8448-4f91-b53f-2ffb8dcb13c1",
"name": "当由另一个工作流执行时",
"type": "n8n-nodes-base.executeWorkflowTrigger",
"position": [
760,
880
],
"parameters": {},
"typeVersion": 1.1
},
{
"id": "8752c39a-5bb6-4696-a591-cb7a4f649586",
"name": "创建表记录",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
180,
1020
],
"parameters": {},
"typeVersion": 2.1
},
{
"id": "448c74a8-8051-4aeb-be50-98f61b4c1476",
"name": "读取表记录",
"type": "n8n-nodes-base.postgres",
"position": [
1260,
720
],
"parameters": {},
"typeVersion": 2.6,
"alwaysOutputData": true
},
{
"id": "a51c89a7-3c6e-4c71-83f7-c17dea2fac6a",
"name": "操作",
"type": "n8n-nodes-base.switch",
"position": [
920,
880
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "0ee5c0cf-cb53-41a7-a81e-1eca93648eee",
"name": "更新表记录",
"type": "n8n-nodes-base.postgres",
"position": [
1260,
1040
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "2f0fafb5-e369-4550-99df-04983c4f0080",
"name": "批量更新表记录",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
300,
1040
],
"parameters": {},
"typeVersion": 2.1
},
{
"id": "40deab57-d6f3-4f40-8368-ae0b5c0830e7",
"name": "创建表记录",
"type": "n8n-nodes-base.postgres",
"position": [
1260,
880
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "e6d70398-2fda-4ad4-9fa9-9277b0e8037f",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-120,
500
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "13154e61-77a4-40bb-b2a1-49c43af5e8c8",
"name": "PostgreSQL MCP 服务器",
"type": "@n8n/n8n-nodes-langchain.mcpTrigger",
"position": [
120,
580
],
"webhookId": "9007e426-56a9-489f-a131-28b63d76ddfa",
"parameters": {},
"typeVersion": 1
},
{
"id": "62e57740-0e1c-46ce-8a12-d963dfe47d65",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
720,
500
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "87fba2e8-96d1-48e1-bd2e-fefbf6d1ba74",
"name": "当收到聊天消息时",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
300,
1440
],
"webhookId": "5c88c23d-5544-46f9-867c-4ea03b41ed62",
"parameters": {},
"typeVersion": 1.1
},
{
"id": "19d4bfb8-ab2f-447f-8d58-4bfe2b7d182c",
"name": "AI 代理",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
540,
1400
],
"parameters": {},
"typeVersion": 1.8
},
{
"id": "87781b4a-1c07-4447-b28f-bc9010dfe672",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
540,
1760
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "3ff30556-c402-47d7-b0d4-200c61006cb9",
"name": "MCP 客户端",
"type": "@n8n/n8n-nodes-langchain.mcpClientTool",
"position": [
700,
1760
],
"parameters": {},
"typeVersion": 1
},
{
"id": "a43e3dc5-adbf-4ae5-b46a-d04654cebbf0",
"name": "Anthropic 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatAnthropic",
"position": [
360,
1740
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "b683d331-989f-4b09-8158-df302fe12cab",
"name": "思考",
"type": "@n8n/n8n-nodes-langchain.toolThink",
"position": [
1000,
1720
],
"parameters": {},
"typeVersion": 1
},
{
"id": "cf864de0-57a5-4537-b42c-5ad12da49d01",
"name": "获取表详细信息",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
540,
860
],
"parameters": {},
"typeVersion": 2.1
},
{
"id": "01300da8-259d-43ca-9185-2f16cf7e2913",
"name": "读取表行数据",
"type": "@n8n/n8n-nodes-langchain.toolWorkflow",
"position": [
480,
1020
],
"parameters": {},
"typeVersion": 2.1
},
{
"id": "9bdb7802-23ad-45d2-a35e-1de546aa8903",
"name": "便签 2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
1320
],
"parameters": {
"content": ""
},
"typeVersion": 1
}
],
"active": true,
"pinData": {},
"settings": {},
"versionId": "ab18f1aa-d451-4aa8-b682-e8d3ab6697b7",
"connections": {
"Think": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"AI Agent": {
"main": [
[]
]
},
"Operation": {
"main": [
[
{
"node": "ReadTableRecord",
"type": "main",
"index": 0
}
],
[
{
"node": "CreateTableRecord",
"type": "main",
"index": 0
}
],
[
{
"node": "UpdateTableRecord",
"type": "main",
"index": 0
}
]
]
},
"ListTables": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"MCP Client": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"ReadTableRows": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"GetTableSchema": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"ReadTableRecord": {
"main": [
[]
]
},
"get table details": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"CreateTableRecords": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"UpdateTableRecords": {
"ai_tool": [
[
{
"node": "PostgreSQL MCP Server",
"type": "ai_tool",
"index": 0
}
]
]
},
"Anthropic Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"When chat message received": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"When Executed by Another Workflow": {
"main": [
[
{
"node": "Operation",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级 - 客户支持, 人工智能, IT 运维
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
基于AI的MIS代理
基于AI的管理信息系统代理
If
Set
Code
+29
129 节点Kumar Shivam
客户支持
构建自定义n8n工作流MCP服务器
构建自定义n8n工作流MCP服务器
If
N8n
Set
+15
46 节点Jimleuk
其他
构建集成Claude、RAG、Perplexity和Drive的全源知识助手
构建集成Claude、RAG、Perplexity和Drive的全源知识助手
Set
Switch
Google Drive
+21
38 节点Paul
内部知识库
自动化多平台销售代理
使用 RAG、CRM 和支付处理的多平台销售代理
If
Set
Switch
+24
83 节点Electrabot
销售
Mistral转录
使用Google日历和自定义函数构建MCP服务器
Set
Switch
Debug Helper
+11
32 节点Solomon
构建模块
多平台AI销售代理:集成RAG、CRM、日历和Stripe
集成RAG、CRM、日历和Stripe的多平台AI销售代理
If
Set
Switch
+24
83 节点Vansh Arora
销售