Dynamic MCP server selection with OpenAI GPT-4.1 and contextual AI reranker
UnknownWhat this workflow does
This AI workflow has 12 nodes and runs when a chat message arrives. Along the way it connects OpenAI Chat Model and Contextualai (community).
How it runs
Trigger: When a chat message arrives.
- LLM Agent for Decision-Making (AI Agent): runs an AI agent, with model: OpenAI Chat Model
- If: checks a condition and branches into true / false
- PulseMCP Fetch MCP Servers (HTTP Request): calls an HTTP API
- Merge: merges the data from its input branches
- Final Response (Chat): uses Chat
- Parse MCP Server list into documents w metadata (Code): runs custom JavaScript code
- Merge: merges the data from its input branches
- Rerank documents (Contextual Ai): work with reranker
- Format the top 5 results (Code): runs custom JavaScript code
- Final Response (Chat): uses Chat
Services it uses
Before you upgrade to n8n 3.0
We can't fully verify this one: it relies on 1 community package, and n8n 3.0 turns unverified community packages off by default (N8N_UNVERIFIED_PACKAGES_ENABLED=false).
- Check that n8n-nodes-contextualai is verified or supports 3.0 (used in Rerank documents).
Nodes used (9)
- OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - If
n8n-nodes-base.if - Merge
n8n-nodes-base.merge - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - HTTP Request
n8n-nodes-base.httpRequest - Chat
@n8n/n8n-nodes-langchain.chat - Code
n8n-nodes-base.code - Contextual Ai
n8n-nodes-contextualai.contextualAi
From the author
PROBLEM Thousands of MCP Servers exist and many are updated daily, making server selection difficult for LLMs. - Current approaches require manually downloading and configuring servers, limiting flexibility. - When multiple servers are pre-configured, LLMs…