Skip to content
AI Agent How-To

Home ›Start here

What Is an AI Agent? LLMs, Tools, MCP

Beginner ~4 min read Last tested November 2026

Updated 2026-11-03

An AI agent is a program that uses a large language model (LLM) to decide what to do next, takes actions through tools, looks at the results, and repeats until a goal is met. A chatbot answers; an agent acts.

An AI agent drawn as a machine: the LLM core decides, tool arms act, memory stores context, the agent loop repeats, and MCP ports plug in outside tools.
LLM core · the engine
Reads the conversation and the tool list, then decides: answer now, or ask for a tool call. 1. The LLM (the “brain”)
Tools · the arms
Functions you expose with a name, a description and a JSON Schema. The model asks; your code runs them. 2. Tools (the “hands”)
Memory · the storage
Short-term: the message history you resend. Long-term: a database or vector store you query when needed. 3. Memory
Agent loop · the gear
Call the model, run the tools it asks for, append the results, repeat. Stop on a plain answer or a step cap. 4. Planning (the loop)
MCP ports · the connectors
A standard socket for tools. Write one MCP server and any MCP client can plug into it. 5. MCP (Model Context Protocol)
Diagram style inspired by Anatomy by Ryan (MIT).

The five core concepts

1. The LLM (the “brain”)

The model reads the conversation so far plus a list of available tools and returns either a final answer or a request to call a tool. Models from OpenAI, Anthropic, Google and open-weight models (via Ollama, vLLM, etc.) all support this “tool calling” pattern.

2. Tools (the “hands”)

A tool is a function you expose to the model with a name, a description and a JSON Schema for its arguments: send_email, query_database, search_web. The model never runs code itself. It asks your code to run the function and you send back the result. For read-only SQL from an agent, see Connect an AI agent to a database.

3. Memory

  • Short-term memory is the message history you resend on each call. It is limited by the model’s context window, so long conversations are trimmed or summarized.
  • Long-term memory is anything you store outside the model (a database, a vector store) and retrieve when relevant.

4. Planning (the loop)

The simplest planner is a loop: call the model, run any requested tools, append the results, call the model again. Stop when the model returns a plain answer or when you hit a maximum number of steps. Frameworks like LangGraph, CrewAI (Fix: CrewAI tool not found when the model calls a missing tool), and the OpenAI Agents SDK add structure (graphs, multiple agents, handoffs) on top of this same loop.

5. MCP (Model Context Protocol)

MCP is an open protocol, introduced by Anthropic in November 2024, that standardizes how agents discover and call tools. Instead of writing a custom integration for every app in every framework, a developer writes one MCP server (for example, for Postgres, Notion, or Jira) and any MCP client (Claude Desktop, Cursor, VS Code, your own agent) can use it. For Notion without MCP, you can still connect a Python agent to Notion over the REST API. Chat bots on Telegram or WhatsApp use each platform’s HTTP API instead of MCP. Servers run locally over stdio or remotely over HTTP. When a client will not connect, start with Fix: MCP server not connecting.

The agent loop in 15 lines

messages = [{"role": "user", "content": goal}]
for step in range(10):                      # hard cap on steps
    reply = llm(messages, tools=TOOLS)
    if not reply.tool_calls:
        print(reply.content)                # final answer
        break
    messages.append(reply)
    for call in reply.tool_calls:
        result = run_tool(call.name, call.arguments)
        messages.append({"role": "tool", "tool_call_id": call.id, "content": result})

Every agent framework, however fancy, is a variation of this loop.

When you should not use an agent

If the steps are fixed and known in advance (“every morning, fetch X and email it”), a plain script or workflow is cheaper, faster and more reliable. Use an agent when the next step genuinely depends on what the model finds.

FAQ

What is an AI agent?

An AI agent uses a large language model to decide the next action, calls a tool, reads the result, and repeats until the goal is met. A chatbot answers. An agent acts.

When should I skip an agent?

Skip an agent when the steps are already fixed, such as a morning job that always fetches the same data and sends the same email. A script or a workflow is cheaper and more reliable for that.

Does the model run the tool?

No. The model returns a request to call a tool. Your code runs the function and sends the result back.