Junior Carlos
← All projects
AI and automationIn use

Self-hosted AI agents: assistants that remember and work inside my systems

By Junior Carlos de MattosUpdated 23/11/20262 min read

Off-the-shelf AI assistants forget context, have unpredictable costs and can't work inside my systems.

Diagram: I talk through Telegram or the terminal; the agent runs on my server; it uses four-layer memory; and works inside my systems through MCP.
Figure: I talk through Telegram or the terminal; the agent runs on my server; it uses four-layer memory; and works inside my systems through MCP.

The problem

Off-the-shelf AI assistants forget context from one conversation to the next, have costs that are hard to predict and can't work inside my systems.

The solution

I set up agents that run on my own server and answer through Telegram and the terminal:

  • four-layer memory (session, daily note, topics and a central index) that cuts token use at startup and keeps decisions continuous;
  • daily versioned backup to a private repository;
  • private-network access, with no sensitive ports exposed to the internet;
  • connections to my systems through MCP (Project Hub, Post Flow and finance);
  • clear rules: anything sensitive goes through human approval.

How it works

  1. I write to the agent through Telegram or the terminal, from anywhere.
  2. It runs on my server, on a private network, with no sensitive ports exposed to the internet.
  3. Memory has four layers: session, daily note, topics and a central index, which avoids rereading everything at each start.
  4. Through MCP, it queries and acts on my systems, and anything sensitive goes through human approval.

Where it stands

Active and in daily use. The backup routine, server security and the connection to each system are still being refined.

Stack: Python, Hermes Agent, MCP, Docker, systemd, Tailscale, Git.

What I learned

  • Organized memory beats a giant context: separating the ephemeral from the permanent cuts token use and preserves decisions.
  • The provider's native authentication has a predictable cost and is more stable than relying on intermediaries.
  • Deleting an old bot can silently take down alerts from other services. I now check who uses a token before removing it.

Frequently asked questions

What is MCP?

It's an open protocol that lets an AI assistant use tools and data from other systems in a standard way. My agents use it to query Project Hub, Post Flow and finance.

Why run it on my own server?

To keep control of cost, data and security, with versioned backups and private-network access.

Junior Carlos de Mattos

By Junior Carlos de Mattos
I work in marketing and build systems and AI automations. This post describes one of my own projects, in progress. About the author

Want something like this for your business?

Tell me what you need and I'll reply on WhatsApp.

Get in touch