n8n + MCP: Build and Automate Anything! Run ALL Your AI Locally - LLMs, AI Agents! (Opensource)

WorldofAIAbout 5 min readApr 22, 2025Watch original
THE SUMMARYAI-generated

Key Concepts

  • Model Context Protocol (MCP): An open standard by Anthropic that allows AI applications to connect with external data sources, services, or local file systems.
  • N: An open-source workflow automation tool that allows users to connect services and run tasks visually using a single Docker container.
  • Docker: A platform that uses containerization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels.
  • Docker Desktop: A tool that simplifies Docker container management and integrates with development tools.
  • AI Agents: Software entities that can perceive their environment, make decisions, and take actions to achieve specific goals.
  • Community Nodes: External tools or integrations within N, often contributed by the community, that extend its functionality.

Setting Up a Local AI Workflow with N, MCP, and Docker

Introduction

The video demonstrates how to set up a local AI workflow using N, MCP, and Docker. This setup allows users to create AI agents that can execute tasks, interact with large language models, and perform Retrieval-Augmented Generation (RAG) pipelines, all within a local environment.

Docker as a Foundation

  • Containerization: Docker is used to create isolated environments called containers, ensuring that applications run smoothly without dependency issues or system conflicts.
  • Simplified Setup: Docker simplifies the installation and configuration of N and MCP servers.
  • Portability and Security: Docker provides a clean, portable, and secure environment for running AI workflows.
  • Installation: Download and install Docker Desktop for your operating system.

Installing and Configuring N with Docker

  1. Pull the N Image: Search for the official N Docker image in Docker Desktop and pull it.
  2. Run the Image: Click the "Run" button on the image and configure the optional settings.
    • Container Name: Assign a name to the container.
    • Port: Set the port to 5678.
    • Volume:
      • Host Path: Create a directory (e.g., "nan" in your documents) and specify its path.
      • Container Path: Use the path /home/node/.nan.
    • Environment Variable: Set N_NODES_ALLOW_EXTERNAL to true to enable external community nodes (use at your own discretion).
  3. Access N: Access N through your local host (e.g., localhost:5678).
  4. Create an Account: Create a free account on the N platform.

Integrating MCP into N

  1. Install Community Nodes: In N, go to settings, then community nodes, and install the "nodes-mcp" community node. Acknowledge the risks before installing.
  2. Restart Docker Container (if needed): If the MCP client node doesn't appear, restart the Docker container.

Building a Workflow with MCP

  1. Create a New Workflow: Start a new workflow in N and give it a name.
  2. Add a Chat Trigger: Use a chat trigger to initiate the workflow when a chat message is received.
  3. Add a Chat Model: Select a chat model (e.g., Gemini, Deepseek, Open Router, or Olama). Provide the necessary API key and credentials.
  4. Add Memory: Include a memory component to the AI agent.
  5. Add MCP Client Node: Add the MCP client node to the workflow.
  6. Configure MCP Credentials:
    • Create a new credential for the MCP server.
    • Use MPX to install the MCP server with the appropriate protocol. Example: mpx -y npm:@brave-intl/mcp-server for Brave Search.
    • Set the environment variable for the Brave Search API.
  7. List Available Tools: Configure the MCP client node to list available tools. Test the step to verify the tools are accessible.
  8. Execute a Tool: Add another MCP client node to execute a specific tool (e.g., Brave Search).
    • Set the operation to "execute tool."
    • Specify the tool name (e.g., "web_search").
    • Leave the tool parameters blank for automatic setting.
  9. Configure AI Agent:
    • Add a system message to the AI agent.
    • Connect the chat trigger, AI agent, and MCP client nodes in the workflow.
  10. Test the Workflow: Interact with the AI agent through the chat interface and observe the results.

Example: Using Brave Search with MCP

  • Installation: Use mpx -y npm:@brave-intl/mcp-server to install the Brave Search MCP server.
  • API Key: Set the environment variable for the Brave Search API.
  • Tool Execution: Configure the MCP client node to execute the "web_search" tool.
  • Interaction: Ask the AI agent a question, and it will use Brave Search to retrieve an answer.

Enthropic and Docker Partnership

  • Enthropic partnered with Docker to run cloud desktops with containerized MCP servers.
  • This setup allows for automating browser tasks with Puppeteer, accessing GitHub, and working with databases in an isolated Docker environment.

Notable Quotes

  • "MCP or model context protocol is an open standard by Enthropic that allows AI apps to connect with external data sources services or even your local AI file system."
  • "Think of Docker as a virtual container system. It lets you run applications in isolated self-contained environments called containers."

Technical Terms

  • RAG (Retrieval-Augmented Generation): An AI framework that combines information retrieval with text generation to improve the quality and relevance of generated text.
  • API (Application Programming Interface): A set of rules and specifications that software programs can follow to communicate with each other.
  • MPX: A tool used to install and run packages, often used with MCP servers.

Conclusion

The video provides a detailed guide on setting up a local AI workflow using N, MCP, and Docker. By leveraging Docker's containerization capabilities, N's workflow automation features, and MCP's ability to connect AI agents with external tools, users can create powerful and flexible AI applications within a local environment. This setup is open-source, free, and can be customized to suit various needs.

AI summaries can miss context or contain errors. Check important details against the original video.

Go a little deeper.

Have a question about this video? Load its transcript to open the video chat.