This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "multi_agent_Cloudmcpserver_sse_mssql_v3_2-sent",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
-1080,
220
],
"id": "f81e18f8-343f-40e9-a9a1-cefb24eb93ef",
"name": "When chat message received"
},
{
"parameters": {},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
-340,
440
],
"id": "bad493ce-a679-4c3e-ab58-be1b496a728a",
"name": "Simple Memory"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 2
},
"conditions": [
{
"id": "2966067a-7bb6-4316-8ad9-2b7681c7e0b9",
"leftValue": "={{$json[\"output\"]}}",
"rightValue": "",
"operator": {
"type": "string",
"operation": "equals",
"name": "filter.operator.equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.if",
"typeVersion": 2.2,
"position": [
0,
0
],
"id": "6e738ba8-7071-4b93-8e36-71aedad53fe5",
"name": "If"
},
{
"parameters": {
"promptType": "define",
"text": "=\u0e41\u0e1b\u0e25\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e19\u0e35\u0e49\u0e40\u0e1b\u0e47\u0e19 JSON \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a MongoDB: {{ $('Query Agent').first().json.output }}",
"options": {
"systemMessage": "=\u0e04\u0e38\u0e13\u0e40\u0e1b\u0e47\u0e19 data engineer \u0e17\u0e35\u0e48\u0e23\u0e31\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e08\u0e32\u0e01 AI agent \u0e41\u0e23\u0e01\u0e21\u0e32\u0e41\u0e1b\u0e25\u0e07\u0e40\u0e1b\u0e47\u0e19 JSON \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a MongoDB\n\n\u0e02\u0e49\u0e2d\u0e01\u0e33\u0e2b\u0e19\u0e14:\n- Return \u0e40\u0e09\u0e1e\u0e32\u0e30 valid JSON object (\u0e44\u0e21\u0e48\u0e43\u0e2a\u0e48 ```json``` \u0e2b\u0e23\u0e37\u0e2d\u0e04\u0e33\u0e2d\u0e18\u0e34\u0e1a\u0e32\u0e22)\n- \u0e43\u0e0a\u0e49\u0e20\u0e32\u0e29\u0e32\u0e44\u0e17\u0e22\u0e43\u0e19\u0e1f\u0e34\u0e25\u0e14\u0e4c\u0e17\u0e35\u0e48\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\n- \u0e42\u0e04\u0e23\u0e07\u0e2a\u0e23\u0e49\u0e32\u0e07 JSON \u0e15\u0e49\u0e2d\u0e07\u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19\u0e41\u0e25\u0e30 query \u0e44\u0e14\u0e49\u0e21\u0e35\u0e1b\u0e23\u0e30\u0e2a\u0e34\u0e17\u0e18\u0e34\u0e20\u0e32\u0e1e\n\n\u0e01\u0e32\u0e23\u0e08\u0e31\u0e14\u0e01\u0e32\u0e23\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25:\n- \u0e43\u0e0a\u0e49\u0e40\u0e09\u0e1e\u0e32\u0e30\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e44\u0e14\u0e49\u0e23\u0e31\u0e1a\u0e08\u0e32\u0e01 agent \u0e41\u0e23\u0e01\n- \u0e2b\u0e49\u0e32\u0e21\u0e40\u0e1e\u0e34\u0e48\u0e21\u0e40\u0e15\u0e34\u0e21\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e2b\u0e23\u0e37\u0e2d\u0e15\u0e35\u0e04\u0e27\u0e32\u0e21\u0e40\u0e01\u0e34\u0e19\u0e08\u0e32\u0e01\u0e17\u0e35\u0e48\u0e21\u0e35\n- \u0e2b\u0e49\u0e32\u0e21\u0e2a\u0e23\u0e49\u0e32\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e2b\u0e23\u0e37\u0e2d\u0e02\u0e49\u0e2d\u0e2a\u0e23\u0e38\u0e1b\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e43\u0e19\u0e15\u0e49\u0e19\u0e09\u0e1a\u0e31\u0e1a\n- \u0e16\u0e49\u0e32\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e44\u0e21\u0e48\u0e2a\u0e21\u0e1a\u0e39\u0e23\u0e13\u0e4c \u0e43\u0e2b\u0e49\u0e40\u0e1e\u0e34\u0e48\u0e21 \"data_incomplete\": true\n\n\u0e15\u0e31\u0e27\u0e2d\u0e22\u0e48\u0e32\u0e07 output:\n{\"_id\": \"analysis_001\", \"data\": {...}}"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
280,
220
],
"id": "0864d8e6-d633-4dae-ae3e-afa0e4eb9f9b",
"name": "Data Engineer Agent"
},
{
"parameters": {
"jsCode": "const staticData = $getWorkflowStaticData('global');\n\n// \u0e15\u0e23\u0e27\u0e08\u0e2a\u0e2d\u0e1a\u0e27\u0e48\u0e32\u0e40\u0e1b\u0e47\u0e19\u0e23\u0e2d\u0e1a\u0e41\u0e23\u0e01\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48\nif (!staticData.current_session_data) {\n // \u0e23\u0e2d\u0e1a\u0e41\u0e23\u0e01: \u0e40\u0e01\u0e47\u0e1a\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u0e08\u0e32\u0e01 input\n staticData.current_session_data = {\n original_question: $json[\"chatInput\"],\n sessionId: $json[\"userId\"] || \"default-session\",\n startTime: new Date().toISOString()\n };\n}\n\n// \u0e2a\u0e48\u0e07\u0e2d\u0e2d\u0e01\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e17\u0e35\u0e48\u0e04\u0e07\u0e2d\u0e22\u0e39\u0e48\u0e17\u0e38\u0e01\u0e23\u0e2d\u0e1a\nreturn [{\n sessionId: staticData.current_session_data.sessionId,\n original_question: staticData.current_session_data.original_question\n}];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-780,
220
],
"id": "1f1dc578-1b4b-4bdb-b22e-bb6627a1cdac",
"name": "Question memorizer"
},
{
"parameters": {
"model": {
"__rl": true,
"value": "openai/gpt-oss-120b",
"mode": "list",
"cachedResultName": "openai/gpt-oss-120b"
},
"options": {
"maxTokens": 8000
}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
-520,
440
],
"id": "907949fb-86b6-4626-923c-c0818685fe91",
"name": "OpenAI Chat Model by OpenRouter",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"model": {
"__rl": true,
"value": "qwen/qwen-max",
"mode": "list",
"cachedResultName": "qwen/qwen-max"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
160,
440
],
"id": "ed147d6c-6543-40ea-83cd-ceae08955b38",
"name": "OpenAI Chat Model by OpenRouter-1",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "\u0e41\u0e2a\u0e14\u0e07\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25\u0e2a\u0e23\u0e38\u0e1b\u0e40\u0e01\u0e35\u0e48\u0e22\u0e27\u0e01\u0e31\u0e1a\u0e10\u0e32\u0e19\u0e02\u0e49\u0e2d\u0e21\u0e39\u0e25",
"connectionType": "sse",
"operation": "executeTool",
"toolName": "get_database_info_tool"
},
"type": "n8n-nodes-mcp.mcpClientTool",
"typeVersion": 1,
"position": [
-460,
640
],
"id": "7b904a2f-e98c-4936-882e-76068498333b",
"name": "get_database_info_tool",
"credentials": {
"mcpClientSseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Execute a read-only SQL query and return the results",
"connectionType": "sse",
"operation": "executeTool",
"toolName": "execute_query_tool",
"toolParameters": "={{ (function() {\n const paramsString = $fromAI('Tool_Parameters');\n \n // Default query \u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e14\u0e39\u0e23\u0e32\u0e22\u0e0a\u0e37\u0e48\u0e2d\u0e15\u0e32\u0e23\u0e32\u0e07\n const defaultParams = {\n query: \"SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE' ORDER BY TABLE_NAME\"\n };\n \n if (!paramsString) {\n return defaultParams;\n }\n \n try {\n // \u0e25\u0e2d\u0e07\u0e41\u0e1b\u0e25\u0e07 JSON \u0e01\u0e48\u0e2d\u0e19\n const params = JSON.parse(paramsString);\n return {\n query: params.query || params.sql || params.statement || defaultParams.query\n };\n } catch (e) {\n // \u0e16\u0e49\u0e32\u0e41\u0e1b\u0e25\u0e07 JSON \u0e44\u0e21\u0e48\u0e44\u0e14\u0e49 \u0e16\u0e37\u0e2d\u0e27\u0e48\u0e32\u0e40\u0e1b\u0e47\u0e19 SQL string \u0e42\u0e14\u0e22\u0e15\u0e23\u0e07\n if (typeof paramsString === 'string' && paramsString.trim().length > 0) {\n return {\n query: paramsString.trim()\n };\n }\n return defaultParams;\n }\n})() }}"
},
"type": "n8n-nodes-mcp.mcpClientTool",
"typeVersion": 1,
"position": [
-300,
640
],
"id": "8c0e8f73-e0bb-4dcb-9bbb-9bc7351fd1ef",
"name": "execute_query_tool",
"credentials": {
"mcpClientSseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"descriptionType": "manual",
"toolDescription": "Preview sample data from a specific table with configurable row limit",
"connectionType": "sse",
"operation": "executeTool",
"toolName": "preview_table",
"toolParameters": "={{ (function() {\n const paramsString = $fromAI('Tool_Parameters');\n \n // Default \u0e2a\u0e33\u0e2b\u0e23\u0e31\u0e1a preview_table\n const defaultParams = {\n table_name: \"allrawloanstat\",\n limit: 10\n };\n \n if (!paramsString) {\n return defaultParams;\n }\n \n try {\n // \u0e25\u0e2d\u0e07\u0e41\u0e1b\u0e25\u0e07 JSON \u0e01\u0e48\u0e2d\u0e19\n const params = JSON.parse(paramsString);\n return {\n table_name: params.table_name || params.tableName || params.table || defaultParams.table_name,\n limit: params.limit || params.row_count || params.rows || defaultParams.limit\n };\n } catch (e) {\n // \u0e16\u0e49\u0e32\u0e41\u0e1b\u0e25\u0e07 JSON \u0e44\u0e21\u0e48\u0e44\u0e14\u0e49 \u0e25\u0e2d\u0e07 parse SQL query\n if (typeof paramsString === 'string' && paramsString.trim().length > 0) {\n const sql = paramsString.trim().toUpperCase();\n \n // \u0e2b\u0e32 table name \u0e08\u0e32\u0e01 FROM clause\n const fromMatch = sql.match(/FROM\\s+(\\w+)/);\n const tableName = fromMatch ? fromMatch[1].toLowerCase() : defaultParams.table_name;\n \n // \u0e2b\u0e32 limit \u0e08\u0e32\u0e01 TOP clause\n const topMatch = sql.match(/TOP\\s+(\\d+)/);\n const limit = topMatch ? parseInt(topMatch[1]) : defaultParams.limit;\n \n return {\n table_name: tableName,\n limit: limit\n };\n }\n return defaultParams;\n }\n})() }}"
},
"type": "n8n-nodes-mcp.mcpClientTool",
"typeVersion": 1,
"position": [
-140,
640
],
"id": "e3923ff6-c0e6-4b70-9305-ce1008851449",
"name": "preview_table",
"credentials": {
"mcpClientSseApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"promptType": "define",
"text": "={{$json[\"original_question\"]}}",
"options": {
"systemMessage": "=CORE IDENTITY\nYou are a professional SQL Data Analyst Agent with SELF-CORRECTION and DYNAMIC SCHEMA DISCOVERY capabilities. Your primary goals are ACCURACY, REPRODUCIBILITY, and ADAPTABILITY to any database structure.\n\nTOOL USAGE REQUIREMENT\nYou MUST use SQL tools for every analysis request. You cannot provide SQL analysis without executing actual queries against the database.\n\nMANDATORY OUTPUT FORMAT\nEvery analysis MUST include:\nANALYSIS REQUEST: [restate user question]\nATTEMPT #: [current attempt number]\nSCHEMA DISCOVERY: [tables and columns found]\nSQL QUERY EXECUTED:\n[exact query with complete syntax]\nEXECUTION STATUS: [SUCCESS/FAILED/TOOL_MALFUNCTION]\nRAW RESULTS: [actual numbers from database OR error message OR tool issue description]\nERROR ANALYSIS: [if failed - what went wrong and why]\nCORRECTIVE ACTION: [if failed - what changes will be made]\nVERIFIED FINDINGS: [interpretation of actual results only - or statement that retry is needed]\n\nDYNAMIC SCHEMA DISCOVERY WORKFLOW\nPhase 1: Database Discovery\n Discover all available tables\n Identify table naming patterns (fact/dim, raw tables, views)\n No assumptions about specific table names\nPhase 2: Adaptive Structure Analysis\n Examine key tables that match the analysis requirements\n Discover actual column names and data types\n Identify relationships through foreign keys or naming patterns\n Build understanding of business domain from column names\n NEVER assume specific column names exist\nPhase 3: Flexible Query Construction\n Use ONLY columns that actually exist in the schema\n Adapt business logic to discovered data types and ranges\n Build JOINs based on discovered relationships\n Validate data ranges based on actual data, not assumptions\n\nSELF-CORRECTION WORKFLOW\nPhase 1: Initial Execution\n Execute your best SQL query based on discovered schema\n Capture results OR errors\n If successful \u2192 proceed to findings\n If failed \u2192 activate correction protocol\n If tool malfunction \u2192 activat",
"maxIterations": 30
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.9,
"position": [
-440,
220
],
"id": "d2b0d960-8e8a-474e-92cc-cd0f71438990",
"name": "Query Agent",
"alwaysOutputData": false,
"retryOnFail": true
}
],
"connections": {
"When chat message received": {
"main": [
[
{
"node": "Question memorizer",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "Query Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"If": {
"main": [
[
{
"node": "Question memorizer",
"type": "main",
"index": 0
}
],
[
{
"node": "Data Engineer Agent",
"type": "main",
"index": 0
}
]
]
},
"Question memorizer": {
"main": [
[
{
"node": "Query Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model by OpenRouter": {
"ai_languageModel": [
[
{
"node": "Query Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model by OpenRouter-1": {
"ai_languageModel": [
[
{
"node": "Data Engineer Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"get_database_info_tool": {
"ai_tool": [
[
{
"node": "Query Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"execute_query_tool": {
"ai_tool": [
[
{
"node": "Query Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"preview_table": {
"ai_tool": [
[
{
"node": "Query Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Query Agent": {
"main": [
[
{
"node": "If",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "b76b73b8-bfaf-4dfe-9d57-7d9499c15474",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "DKHT4X074sV1E63r",
"tags": [
{
"createdAt": "2025-08-30T11:42:07.880Z",
"updatedAt": "2025-08-30T11:42:07.880Z",
"id": "4JFGzrMLWzj571P5",
"name": "in-progress"
},
{
"createdAt": "2025-08-21T02:48:15.126Z",
"updatedAt": "2025-08-21T02:48:15.126Z",
"id": "V3ge46YcXRI0kQG8",
"name": "stable"
},
{
"createdAt": "2025-09-03T10:47:57.996Z",
"updatedAt": "2025-09-03T10:47:57.996Z",
"id": "lQc8M4u3jRrrVWpx",
"name": "tested@3Sep2025"
},
{
"name": "tested@7Sep2025",
"id": "mBqZ2c627fVAy57R",
"createdAt": "2025-09-07T14:37:33.640Z",
"updatedAt": "2025-09-07T14:37:33.640Z"
}
]
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
mcpClientSseApiopenAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
multi_agent_Cloudmcpserver_sse_mssql_v3_2-sent. Uses chatTrigger, memoryBufferWindow, agent, lmChatOpenAi. Chat trigger; 11 nodes.
Source: https://github.com/kuan31898/2025-n8n-mcp/blob/c22d48eae33490ce46efabf5064bcee0f04920b7/2025-n8n-mcp-main-revised@6Sept2025/n8n-mcpserver-sse-mssql/multi_agent_Cloudmcpserver_sse_mssql_v3_2_sent.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.
This template obtains all the possible tools from Bright Data MCP, process this through chatbot, then run any tool based on the user's query
💥🛠️Build a Web Search Chatbot with GPT-4o and MCP Brave Search. Uses agent, chatTrigger, n8n-nodes-mcp, memoryBufferWindow. Chat trigger; 15 nodes.
Disclaimer: This workflow only works with local installations of n8n because it uses a community MCP node
Disclaimer: This template is for self-hosted n8n instances only.