An agent is a loop with a budget. Most agent projects fail because nobody wrote down the budget or what happens when the loop ends badly.

What an agent has to get right

The demo is easy. A model, some tools, a while-loop, and it books the meeting. Production is a different problem, and it is mostly about failure:

  • A step limit and a cost ceiling. Every loop needs a hard maximum on iterations and spend. Without one, a confused agent will happily retry the same failing call until someone notices the invoice.
  • Idempotent tools. The agent will call the same tool twice. If that tool sends an email or charges a card, that is now your problem. Tools that mutate state need an idempotency key.
  • A real failure path. “I was unable to complete that request” is not a failure path. Handing the task to a human, with the transcript and the reason attached, is.
  • Scoped credentials. An agent with your admin token is a breach waiting for a prompt injection. Tools get the narrowest permission that does the job.
  • An audit trail. Every tool call, its arguments, its result, and the model turn that requested it. When an agent does something surprising, this is the only thing that explains why.

Where MCP fits

The Model Context Protocol standardises how a model discovers and calls tools. Before it, every integration was bespoke glue between one model and one system, rewritten when either end changed. An MCP server exposes your systems once, with a declared interface, and any compatible client can use it.

The practical benefit is not novelty, it is maintenance. One server, one place to change a schema, one place to enforce permissions, one place to log. If you have written the same “let the model query our database” adapter three times, that is what MCP replaces.

The practical risk is the same as any API surface: an MCP server is a way for a model to reach your systems, and content it reads is not a source of instructions. Treat tool results as data, keep credentials narrow, and make destructive operations require an explicit confirmation step.

How I build them

I start from the task, backwards. What is the completed state? What tools does it take to reach it? What is the worst thing a confused loop could do with them? That last question usually reshapes the design more than the first two, and it is the one that rarely gets asked before a demo.

Then the loop gets its budget, the tools get their guardrails, and the whole thing gets an evaluation set: a fixed list of tasks with known outcomes, run on every change. Agents drift as models update. Without evals you find out from a user.

I run an agentic system of my own in production — LEM, whose source is public and MIT-licensed. It plans content, drafts posts, comments and replies, and holds everything for approval before anything sends. That approval gate exists because I have watched agents be confidently wrong, and its LLM bill is mine to pay.

When you do not need an agent

If the steps are known in advance, write the steps. A deterministic pipeline with one model call in the middle is cheaper, faster, easier to test, and correct more often. Agents earn their cost when the path genuinely varies with the input.