Back to portfolio

Engineering notes / AI & Automation

Self-Hosting AI Agents with n8n & MCP

A practical split between orchestration, tool access, and the guardrails that make self-hosting manageable.

·1 min read

Self-hosting gives you control over how an agent accesses data, but it also makes you responsible for operating the workflow. Keep the first version small enough that you can explain every step.

Separate workflow state from tool access

Use n8n to coordinate triggers, retries, and operator notifications. Give MCP tools narrow, documented inputs and outputs. A read-only search tool does not need the same access as a tool that changes records.

Treat tool calls as application decisions

Check the user’s permissions outside the model. For a consequential action, present the proposed change and require an explicit human approval. Set timeouts and rate limits for external calls so an unresponsive tool cannot stall the entire pipeline.

Decide what to measure

Track failure rates, runtime, and model cost for each workflow. Keep inputs and secrets out of routine logs. When you add a new tool, test the steps that will matter at 2 a.m.: working out what happened, retrying safely, and turning the tool off.