This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.
This workflow demonstrates how to build and expose a sophisticated n8n AI Agent as a single, callable tool using the Multi-Agent Collaboration Protocol (MCP). It allows external clients or other AI systems to easily query software library documentation via Context7, without needing to manage the underlying tool orchestration or complex conversational logic.
Core Idea:
Instead of building complex agentic loops on the client-side (e.g., in Python, a VS Code extension, or another AI development environment), this workflow offloads the entire agent's reasoning and tool-use process to n8n. The client simply sends a natural language query (like "How do I use Flexbox in Tailwind CSS?") to an SSE endpoint, and the n8n agent handles the rest.
Key Features & How It Works:
Context7 MCP Server Trigger
node to create an SSE endpoint. This makes the agent accessible to any MCP-compatible client.Tool Workflow
node (named call_context7_ai_agent
in this example) is connected to the MCP Server Trigger. This node defines the single "tool" that external clients will see and call.call_context7_ai_agent
tool invokes a separate sub-workflow which contains the actual AI logic.Context7 Workflow Start
node to receive the user's query
.Context7 AI Agent
node (using Google Gemini in this example) is the brain, equipped with:
Simple Memory
to retain context for each execution (using {{ $execution.id }}
as the session key).context7-resolve-library-id
: To convert library names (e.g., 'Next.js') into Context7-specific IDs.context7-get-library-docs
: To fetch documentation using the resolved ID, with options for specific topics and token limits.resolve-library-id
and get-library-docs
tools based on the user's query, handling the multi-step process internally.Benefits of This Approach:
Use Cases:
Setup:
Path
in the Context7 MCP Server Trigger
node should be unique and secure.This workflow is a great example of how n8n can serve as a powerful backend for building and deploying modular AI agents.
I've made a video to try and explain this a bit too https://www.youtube.com/watch?v=dudvmyp7Pyg