n8n-claw Documentation

repository·main·Indexed 19 days ago

https://github.com/freddy-schuetz/n8n-claw

A self-hosted AI agent framework combining n8n automation, PostgreSQL memory, and LLMs like Claude. It features a proactive assistant with long-term memory, a knowledge graph, and integration with Telegram, Webhooks, and the Model Context Protocol (MCP). Includes a browser-bridge REST wrapper for the Browser Use Python SDK to execute agentic browser tasks with session persistence.

Tokens
23.4K
Snippets
54
Records
103
Agent score
60%

What's inside n8n-claw

  1. Overview of browser-bridge

    main
    The browser-bridge is a REST wrapper around the Browser Use Python SDK. It provides an HTTP interface that allows n8n-claw workflows to execute agentic browser tasks, such as filling out forms, signing up for newsletters, navigating click flows, and performing actions within logged-in sessions. It uses an in-memory session pool to maintain browser states, bypassing limitations in the underlying SDK regarding storage_state saving.
  2. What n8n-claw does

    main

    n8n-claw is a self-hosted AI agent built on n8n, PostgreSQL, and Claude. It provides a natural language interface for managing tasks, long-term memory, and complex workflows.

    Key capabilities include:

    • Communication: Chat via Telegram or a Webhook API (for Slack, Teams, etc.).
    • Memory & Knowledge: Hybrid long-term memory (semantic + full-text) and an automatic knowledge graph that tracks entities like people, companies, and events.
    • Task & Project Management: Create/track tasks with priorities and maintain persistent project notes in markdown.
    • Automation: Proactive heartbeats for reminders, recurring scheduled actions, and smart background checks.
    • Web Capabilities: Web search (via SearXNG), web reading (via Crawl4AI), and browser automation (via Browser Use) with interactive 2FA support.
    • Extensibility: Uses MCP (Model Context Protocol) to install pre-built skills or build custom API integrations on demand.
    • Failure Awareness: Automatically logs workflow errors to memory and notifies you via Telegram.
  3. Use the Webhook Adapter for external integrations

    main

    The Webhook Adapter workflow translates between external message formats (Slack, Teams, Discord, Paperclip) and the agent's internal Webhook API. It uses a mapper node to normalize incoming messages and routes the response back to the original system using the metadata._responseChannel field.

    Available Triggers

    TriggerEndpointDefault stateUse case
    Generic Webhook/webhook/adapterActivePaperclip, Discord bridge, API power-users
    Custom Webhook/webhook/customActiveYour own apps via simple Set node mapping
    Slack TriggerDisabledSlack workspace integration
    Teams TriggerDisabledMicrosoft Teams integration
    Discord/webhook/adapter (via bot sidecar)Opt-inDiscord servers (requires discord-bridge container)

    Adding a Custom Integration

    Option 1: Custom Webhook (No-Code)

    1. Open the Map Custom Input Set node in the Webhook Adapter workflow.
    2. Map your app's JSON fields to the agent's schema:
      • message $\rightarrow$ your text field (e.g., $json.body.text)
      • user_id $\rightarrow$ sender identifier (e.g., $json.body.username)
      • session_id $\rightarrow$ unique conversation ID
      • source $\rightarrow$ your app's name
    3. Send POST requests to /webhook/custom with the X-API-Key header.

    Option 2: Advanced Trigger (Custom Routing)

    1. Add a new Trigger node to the Webhook Adapter workflow.
    2. Add a Map node (Code node) that outputs: { message, user_id, session_id, source, metadata: { _responseChannel: "your-system" } }.
    3. Add a matching output in the Route Response switch node.
    4. Add a Reply node specific to your system.
  4. Understand n8n-claw service architecture and routing

    main

    The stack runs on a single user-defined bridge network n8n-claw-net. By default, only the n8n service is exposed to the public interface.

    ServiceHost ExposurePurpose
    n8n0.0.0.0:5678Agent UI and webhooks (the only public port)
    db127.0.0.1:5432PostgreSQL 17 with uuid-ossp and vector
    studio127.0.0.1:3001Supabase Studio for DB inspection
    searxng127.0.0.1:8888Private web search
    email-bridgeContainer-onlyIMAP/SMTP REST microservice
    file-bridgeContainer-onlyBinary passthrough for the agent
    discord-bridgeContainer-onlyOptional (enabled via COMPOSE_PROFILES=discord)
    crawl4aiContainer-onlyWeb reader / markdown converter

    Routing Notes:

    • Most services are bound to 127.0.0.1 to prevent public access.
    • If you use a managed reverse proxy (like Hostinger's), set SKIP_REVERSE_PROXY=true to prevent the installer from setting up its own Nginx/Let's Encrypt stack.
  5. Manage and install MCP Skills

    main

    The agent includes a Library Manager that can install and manage 43+ pre-built skills from a GitHub template repository. Skills can be installed via chat commands.

    Skill Types

    • Native: n8n wraps a REST API as an MCP server (the default pattern).
    • Bridge: Registers an existing external MCP server (e.g., DeepWiki, Zapier) via a URL and optional authentication. Supported since v1.3.0.

    Common Commands

    • "What skills are available?" - Lists available skills.
    • "Install [skill-name]" (e.g., Install weather-openmeteo) - Fetches the template and imports the workflow into n8n.
    • "Remove [skill-name]" - Uninstalls the skill.
    • "Add credential for [skill-name]" - Regenerates a secure link to provide an API key.

    Handling API Keys

    For skills requiring authentication (e.g., news-newsapi):

    1. Use the install command.
    2. The agent will send a secure, one-time link via Telegram.
    3. Click the link and enter your API key in the provided form.
    4. The key is stored in the template_credentials table in PostgreSQL.

    Security Warning: Skill credentials are currently stored unencrypted in the database. Ensure your VPS is secured via SSH (key-based auth) and that the database/API are not exposed to the public internet.

  6. Configure Reminders and Scheduled Actions

    main

    The agent supports three types of timed actions:

    1. Reminders: Sends a Telegram message at a specific time (e.g., "Remind me in 30 minutes to check the oven").
    2. Scheduled Actions: The agent executes an instruction at a specific time and sends the result (e.g., "Search Hacker News for AI articles at 9am and list them").
    3. Recurring Actions: Repeating actions on an interval, daily, or weekly (e.g., "Check my emails every 15 minutes").

    Management:

    • List/Edit/Delete reminders: "Show my reminders", "Move the workshop reminder to Monday at 10am".
    • List/Pause/Resume/Delete recurring actions: "Show my scheduled actions", "Pause the mail check".

    Delivery Mechanism:

    • Reminder Runner: Polls every minute for one-time reminders and scheduled actions.
    • Heartbeat: Runs every 5 minutes for recurring actions.
  7. The Two-Workflow pattern for MCP tools

    main

    To avoid a known n8n bug where specifyInputSchema: true is silently ignored during API-based workflow creation, the MCP Builder uses a Two-workflow pattern instead of a single toolCode node.

    Every MCP server consists of:

    1. MCP Server workflow: Contains the mcpTrigger and a toolWorkflow node that points to the sub-workflow.
    2. Sub-Workflow: Contains an Execute Workflow Trigger and a Code node containing the actual API logic.

    Data Passing: Parameters must be accessed in the Sub-Workflow via $json.param_name to ensure reliable execution via the API.

  8. n8n-claw Architecture

    main

    The system is composed of a central Agent (running Claude Sonnet) that orchestrates various internal modules and external services:

    Core Agent Modules

    • Task/Project Managers: Handle task lifecycles and persistent markdown notes.
    • Memory & Knowledge Graph: Manage long-term memory and entity relationships.
    • MCP Client/Builder: Interface with and create Model Context Protocol skills.
    • Specialized Tools: Includes Web Search (SearXNG), Web Reader (Crawl4AI), and HTTP tools.

    Background Workflows

    • Heartbeat: Runs every 5 mins for recurring actions and reminders.
    • Memory Consolidation: Summarizes conversations into long-term memory daily at 3am.
    • Reminder Runner: Processes due reminders every 1 min.
    • Error Notification: Catches and reports workflow failures to Telegram.

    Integration Layers

    • Telegram/Webhook: Primary input/output channels.
    • Webhook Adapter: Optional layer to map Slack/Teams/Generic webhooks to the agent's internal POST endpoint.
    • Internal Bridges: File Bridge (temporary binary storage) and Email Bridge (IMAP/SMTP).
  9. Configure LLM providers for browser-bridge

    main
    The browser-bridge synchronizes its LLM provider with the rest of the n8n-claw ecosystem. At the start of every task, the bridge reads tools_config.llm_provider from PostgREST. To ensure the bridge can actually use the provider, you must pass the required Provider API keys via docker-compose environment variables from the host .env file.
  10. How the MCP Builder works

    main

    The MCP Builder is an automated pipeline that creates new Model Context Protocol (MCP) tools. When triggered, it follows a sequence of searching documentation, generating code via LLM, deploying n8n workflows, and registering the tool.

    The build lifecycle:

    1. Research: Searches API docs (via SearXNG) and fetches content (via Jina Reader).
    2. Generation: Builds a prompt and uses Claude to generate the tool logic.
    3. Deployment: Assembles and deploys a two-workflow structure (MCP Server workflow + Sub-Workflow).
    4. Testing: Performs an actual MCP protocol call (initialize -> notifications/initialized -> tools/call) to verify functionality. If testing fails, it attempts an LLM-driven auto-fix.
    5. Registration: Adds the tool to the Supabase mcp_registry and updates the agent's mcp_instructions.
    Start → Search API Docs (SearXNG) → Fetch Docs (Jina Reader)
         → BuildPrompt (LLM prompt with docs)
         → Generate Tool (Claude)
         → Assemble & Deploy
         → Create Sub-Workflow (Code node with actual logic)
         → Activate Sub-Workflow
         → Build MCP JSON
         → Create MCP Workflow (mcpTrigger + toolWorkflow)
         → Test MCP (actual MCP protocol call)
         → Register in Supabase mcp_registry
         → Update agent mcp_instructions
  11. Manage tasks using natural language

    main

    You can manage a task list through conversation. Tasks support priorities (low, medium, high, urgent), due dates, and subtasks.

    • Creating tasks: "Create a task: prepare presentation for Friday, high priority"
    • Checking tasks: "What are my tasks?" or "Show me overdue tasks"
    • Updating tasks: "Mark the dentist task as done" or "Change the presentation priority to urgent"
    • Canceling tasks: "Cancel the groceries task"
  12. Manage Project Memory with persistent documents

    main

    The agent uses persistent markdown files as a "living notebook" for ongoing work.

    • Creating a project: Triggered by natural language (e.g., "New project: server migration to Hetzner"). The agent creates a structured markdown document with goals, notes, and open items.
    • Checking projects: Ask for status (e.g., "What projects do I have?") to see active project names.
    • Updating a project: Add notes directly (e.g., "Update the server migration: DNS is now configured"). The agent reads, appends, and saves the document.
    • Archiving: Tell the agent a project is done (e.g., "The presentation is done") to set its status to completed. It will be removed from the active list but remains in the database.