<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bruno Sorban on Medium]]></title>
        <description><![CDATA[Stories by Bruno Sorban on Medium]]></description>
        <link>https://medium.com/@brunosorban?source=rss-5aa53ce0fd4c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*57f1YxGOichmGiYd4sWMsg.jpeg</url>
            <title>Stories by Bruno Sorban on Medium</title>
            <link>https://medium.com/@brunosorban?source=rss-5aa53ce0fd4c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 10:54:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brunosorban/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Step-by-Step: Build Custom Chat Agents in LibreChat Using n8n and MCP]]></title>
            <link>https://medium.com/@brunosorban/step-by-step-build-custom-chat-agents-in-librechat-using-n8n-and-mcp-b45739d6e33a?source=rss-5aa53ce0fd4c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b45739d6e33a</guid>
            <category><![CDATA[mcp-server]]></category>
            <category><![CDATA[librechat]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[n8n]]></category>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[Bruno Sorban]]></dc:creator>
            <pubDate>Tue, 20 May 2025 18:26:42 GMT</pubDate>
            <atom:updated>2025-05-20T18:26:42.750Z</atom:updated>
            <content:encoded><![CDATA[<p>The rise of the <strong>Model Context Protocol (MCP)</strong> has transformed how we connect large language models (LLMs) to real-world tools and data sources.</p><p>While MCP setups are often seen in code editors or specialized environments like Claude Desktop, today I’ll show you how to set up <strong>n8n as an MCP server</strong> and integrate it directly with <strong>LibreChat</strong> — unlocking powerful, automated chat agents.</p><p>By the end of this tutorial, you’ll have a local LibreChat instance wired up to n8n, capable of calling custom workflows (like sending Gmail messages or triggering APIs) through MCP.</p><h3>📦 Prerequisites</h3><p>Before we begin, make sure you have the following ready:</p><p>✅ <a href="https://docs.n8n.io/hosting/installation/docker/">n8n installed</a> (either self-hosted or cloud-based)<br>✅ <a href="https://www.librechat.ai/docs/local/docker">LibreChat installed via Docker</a></p><p>👉 If you haven’t set these up yet, follow the official installation guides and return here when ready.</p><h3>⚙️ What Is MCP (Model Context Protocol)?</h3><p>According to <a href="https://modelcontextprotocol.io/introduction">ModelContextProtocol.io</a>, <strong>MCP</strong> is an open protocol that standardizes how applications provide context to LLMs.</p><p>Think of it like a <strong>USB-C port for AI applications</strong> — it provides a universal connection point for chatbots to access tools, data sources, and workflows.</p><p>✅ <strong>Benefits:</strong></p><ul><li>Use pre-built integrations without custom glue code</li><li>Swap between LLM providers easily</li><li>Securely connect to local and remote data or services</li></ul><p>In this setup, <strong>n8n acts as an MCP server</strong> and <strong>LibreChat acts as the MCP client</strong>.</p><h3>🏗 Architecture Overview</h3><p>When your agent wants to execute an action, the following process will be triggered:</p><p><strong>LibreChat (MCP Client)</strong> → <strong>MCP Protocol</strong> → <strong>n8n (MCP Server)</strong> → <strong>External Tools (e.g., Gmail, APIs, Databases)</strong></p><h3>🛠 Setting Up n8n as an MCP Server</h3><h3>Step 1: Create the MCP Workflow in n8n</h3><ul><li>Open your the n8n editor</li><li>Create a <strong>new workflow</strong></li><li>Add the <strong>MCP Server Trigger</strong> node — this will listen for incoming requests from LibreChat</li><li>Connect downstream tools (e.g., Gmail, Slack, database queries). n8n also allows you to expose workflows as tools, increasing the overall capabilities of even exposing entire agents as tools.</li><li>Activate the workflow</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*xVqehTaWa9vRL7z2up1kMA.png" /></figure><p>✅ Once active, the MCP server endpoint will provide a url that points to the server endpoint. In the example, the name mcp-server was given. Add authentication accordingly.</p><h3>🔗 Adding a Reference to the Server in LibreChat</h3><h3>Step 2: Clone the Required Config Files</h3><p>Assuming you’ve cloned the LibreChat repository:</p><pre>cp docker-compose.override.yml.example docker-compose.override.yml</pre><h3>Step 3: Adjust docker-compose.override.yml</h3><p>Edit the file docker-compose.override.yml:</p><pre>version: &#39;3.4&#39;<br><br>services:<br>  api:<br>    volumes:<br>      - type: bind<br>        source: ./librechat.yaml<br>        target: /app/librechat.yaml<br>    extra_hosts: # only for n8n hosted in localhost<br>      - &quot;host.docker.internal:host-gateway&quot;</pre><p>✅ <strong>Why this matters:</strong><br>It ensures the Docker container can read the librechat.yaml and resolve the host machine where n8n is running.</p><h3>Step 4: Clone the Main Config File</h3><pre>cp librechat.example.yaml librechat.yaml</pre><h3>Step 5: Add the MCP Server to librechat.yaml</h3><p>Open librechat.yaml and add:</p><pre>mcpServers:<br>  n8n: # name of the server as displayed for the user<br>    type: sse<br>    url: http://host.docker.internal:5678/mcp/mcp-server/sse # change &#39;localhost&#39; to &#39;host.docker.internal&#39;<br>    headers:<br>      Authorization: &quot;Bearer ${N8N_API_KEY}&quot;</pre><p>✅ <strong>Important:</strong></p><ul><li><strong>Add </strong><strong>${N8N_API_KEY} to your </strong><strong>.env file</strong> to store the actual API key securely.</li></ul><h3>🗂 Example .env File</h3><p>Add the following lines to your .env file:</p><pre>N8N_API_KEY=your-real-n8n-api-key-here<br>CONFIG_PATH=/app/librechat.yaml</pre><p>✅ <strong>Tip:</strong> Replace your-real-n8n-api-key-here with the actual API key you configured in n8n.</p><h3>🚀 Step 6: Launch LibreChat with the New Configuration</h3><p>To apply the changes and ensure LibreChat recognizes the new MCP server, run:</p><pre>sudo docker-compose up -d --force-recreate api</pre><p>✅ <strong>Explanation:</strong></p><ul><li>The api service is the part of LibreChat that runs the backend server.</li><li>Using --force-recreate ensures the container is rebuilt with the <strong>new configuration files</strong> you modified.</li><li>Without it, Docker might reuse a cached container and <strong>ignore your changes</strong>.</li></ul><h3>🔍 Debugging Tip</h3><p>To monitor the startup process or debug issues, use:</p><pre>sudo docker-compose logs -f api</pre><p>✅ This will display live logs from the api service, showing whether the MCP server is correctly registered or if any connection/authentication errors occur.</p><p>✅ <strong>Access LibreChat at:</strong></p><pre>http://localhost:3080/</pre><h3>💬 Final Thoughts</h3><p>By turning n8n into an MCP server and connecting it to LibreChat, you unlock a modular, scalable setup for <strong>building AI agents</strong> that bridge conversations to real-world actions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b45739d6e33a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>