Skip to main content

Give your n8n agent access to your knowledge without a RAG pipeline

In this tutorial, you give an n8n AI agent access to your own knowledge: the result is a RAG chatbot that answers grounded questions, in a chat you can hang off any trigger. Kapa indexes your knowledge sources (your documentation site, Notion, Confluence, GitHub, PDFs, support tickets) into one searchable knowledge base and exposes it over a hosted MCP server; your agent searches it through a single MCP Client Tool node.

n8n's native path to this outcome is building a RAG pipeline yourself: a vector database, an embeddings node, a text splitter, and the ingestion workflows that keep them all in sync. Kapa is what you reach for when you would rather not build and operate that pipeline: there are no pgvector tables to create, no embedding model and dimensions to choose and keep identical on both sides, no chunking strategy to tune, no upserts or deduplication to script, and no re-embedding when your content changes. Indexing, refreshes, and retrieval quality are Kapa's job, and your canvas keeps only the agent.

By the end of this tutorial, you will have:

  • A hosted MCP server exposing search over everything your Kapa project indexes.
  • An n8n AI Agent with your knowledge base connected as a tool.
  • A working chat that answers questions from your connected sources.

Before you start

You need:

  • An n8n instance (cloud or self-hosted).
  • A Kapa project whose indexed knowledge sources contain the knowledge you want the agent to answer from.
note

Self-hosted instances need n8n 1.104 or later, which added HTTP Streamable transport to the MCP Client Tool node.

Set up a hosted MCP server in Kapa

Kapa hosts the MCP server for you, so there is no infrastructure to stand up. Follow Set up the MCP server to create it, with one choice made for you: pick API key as the authentication type, which is what n8n's MCP Client Tool supports as bearer authentication.

Then collect two things for the next section:

  1. Your MCP server URL, the full https://<subdomain>.mcp.kapa.ai endpoint.
  2. An API key: navigate to API Keys (under Configuration in the sidebar), click Add new API key, and copy the key.
note

The screenshots in this tutorial come from an example project that indexes Kapa's own documentation, which is why the server URL, the tool name, and the test questions all mention Kapa. In your build, the subdomain and tool name derive from your project, and the agent answers from whatever knowledge sources you have indexed.

Create the workflow and agent

  1. In n8n, create a new workflow and click Add first step on the empty canvas. Search for and select AI Agent; n8n places the agent on the canvas together with a When chat message received trigger. The AI Agent node is the decision-maker of the workflow: you connect a chat model and tools to it, and on each incoming message the agent decides which tools to call to complete the task.
n8n's first-step panel with AI Agent selected as the way to start the workflow
  1. Leave the agent's configuration on its defaults. Source for Prompt (User Message) is set to Connected Chat Trigger Node: whatever a user types into the workflow's chat becomes the agent's prompt ({{ $json.chatInput }}). In this tutorial, that chat is the one built into the n8n canvas: you open it with the Open chat button below the workflow, and it is how you test the agent at the end.

Connect your knowledge base as a tool

  1. Click the + on the AI Agent's Tool connector and select MCP Client Tool. This node is n8n's MCP client: it makes the tools an external MCP server exposes, in this case Kapa's knowledge search, available to the agent.
  2. Configure it:
    • Endpoint: your MCP server URL, for example https://<subdomain>.mcp.kapa.ai.
    • Server Transport: HTTP Streamable.
    • Authentication: Bearer Auth.
  3. Under Credential for Bearer Auth, open the credential selector and create a new credential. In the credential window, paste your API key into Bearer Token and click Save. n8n stores the credential once and every node that references it reuses it.
n8n's Bearer Auth credential window with the Bearer Token field for the Kapa API key
  1. Set Tools to Include to Selected and pick search_<your_product>_knowledge_sources from the list; n8n fetches the available tools from the server. Choosing All also works, but selecting only the search tool keeps the agent's toolset minimal.
  2. Click Execute step to verify that the connection and authentication work.
The MCP Client Tool node parameters in n8n, configured with a Kapa MCP endpoint, HTTP Streamable transport, Bearer authentication, and the knowledge search tool selected
warning

Use the MCP Client Tool sub-node attached to an AI Agent, not the MCP Server Trigger node. The trigger points the other way: it exposes n8n's own tools to outside agents, and connecting it to a Kapa server URL fails.

Connect a chat model

  1. Click the + on the AI Agent's Chat Model connector and select a model provider, for example OpenAI Chat Model. The chat model is the LLM the agent reasons and writes with; the agent node orchestrates, the model generates.
  2. Select or create the credential for your provider, then pick a model with tool-calling support from the Model list, for example gpt-5.6-terra.
The OpenAI Chat Model node in n8n with a credential selected and gpt-5.6-terra picked from the model list

The finished workflow

The canvas now holds the whole build: the chat trigger feeds the agent, and the agent's two sub-nodes are the chat model and the MCP Client with your knowledge base.

The finished n8n canvas: a When chat message received trigger connected to an AI Agent, with OpenAI Chat Model on the Model input and MCP Client on the Tools input

From here on, the agent decides on every incoming chat message whether to call your knowledge base: the search tool's description, published by Kapa's server, tells the model what the tool returns and when to use it. The chat pattern is the simplest starting point, but the same building blocks work with any n8n trigger: a support ticket that gets triaged against your documentation, an incident alert that pulls up runbooks, or an inbound WhatsApp or Telegram message answered from your company knowledge.

Verify it works

  1. Click Open chat at the bottom of the canvas and ask a question your knowledge sources can answer.
  2. Watch the run in the Logs panel: the model decides to search, the MCP Client call retrieves the relevant chunks from your knowledge base, and a second model call composes the grounded answer that arrives in the chat.
  3. Ask about a different connected source, for example a past support ticket or a community thread, to confirm that search spans all of them.
Testing the agent in n8n's chat panel, with the Logs view showing the AI Agent calling the MCP Client between two model calls and the grounded answer in the chat

Summary

In this tutorial, you:

  • Created a hosted MCP server with API key authentication.
  • Connected it to an n8n AI Agent with the MCP Client Tool node and verified the connection.
  • Built a chat workflow in which the agent answers from your knowledge base, with no vector store, embeddings, or chunking pipeline to run.

Next steps

  • Knowledge sources: everything you can index, from documentation and API references to tickets and community threads, to widen what the agent can answer.
  • Prompt for grounded answers: add a system message to the agent when you want to tune how it uses the search tool, states uncertainty, and cites sources.
  • Customize the MCP tools: rename the search tool or adjust its description to guide your agent.
  • Tune retrieval size: control how much context each search returns.