What actually happens between typing a question and reading the answer, message by message: the host sends the model your prompt and the list of tools, the model asks for a tool, the host runs it, and the raw result goes back to the model, which either answers or asks for another tool. This part explains why the result goes back instead of straight to the screen, why the model needs the whole conversation every time, and who pays for which piece.
Part 1 named the roles: the model decides, the host carries messages, the MCP server runs tools. This part puts them in motion. It follows one question all the way through, and by the end the word "agent" should feel less like magic and more like a loop you could write yourself.
Take PhotoDrop, the photo service from Part 0, and imagine its MCP server offers two tools:
list_albums: lists the signed-in user's albums, with their ids and names;count_photos: counts the photos in one album between two dates.The user types: "How many photos did I add to my Holiday album this month?"
In detail:
1. The host sends the model everything it needs. That is the user's message, the conversation so far, and the tool list: every available tool's name, description and input schema. The model has no other way of knowing which tools exist.
2. The model replies with a request, not an answer. Instead of writing text for the user, it replies, in effect, "please call list_albums with no arguments". It chose that tool because its description matched what it needed: it cannot count photos in "Holiday" without first finding out which album that is.
3. The host runs the tool. It may first ask the user for permission; the MCP specification says there should always be a human able to refuse a tool call, and hosts usually ask before anything that changes data. Then it sends the call to the MCP server, the server runs its code, and the raw result comes back:
[
{ "id": 41, "name": "Pets" },
{ "id": 42, "name": "Holiday" },
{ "id": 43, "name": "Receipts" }
]4. The host sends that result back to the model, added to the conversation.
5. The model reads it and decides the next step. Now it knows Holiday is album 42, so it asks for count_photos with album 42 and this month's dates. The host runs that tool too and sends back a single number: 37.
6. The model writes the answer: "You added 37 photos to your Holiday album this month."
Two trips through "model asks, host runs, result goes back", then one final reply. That repetition is the agent loop:
prompt + history + tool list → model picks a tool → host runs it → raw result back to the model → the model picks another tool, or answers.
This step is the most puzzling one. The host already has the result in step 3. Why not just show it?
Because a tool returns data, not an answer. The user asked a question in plain language. The tool returned a JSON list of albums. Someone has to read that list, find the right album and work out what to do next, and the host cannot: it carries messages, it does not understand them. Only the model can.
Because the next step depends on it. The model could not have called count_photos without first reading the id from list_albums. Real tasks are chains like this: look something up, use what you found to look something else up, combine the pieces.
Because things fail. If a tool returns an error, such as "the date range is too long", the model can read the message and try again with a shorter range, or explain the problem to the user. A raw error on the screen helps nobody.
The raw result is not hidden, though. Most hosts let you expand each step of the conversation and see exactly what each tool was sent and what it returned. When you are building a server, that view is how you check your tool did what you think it did.
Here is a fact that changes how you think about everything above: between two requests, the model remembers nothing. Each time the host sends a request, the model starts from a blank page.
So the host sends the whole conversation, every time: the system instructions, every earlier message, the tool list, and every earlier tool call and its result. In the example, the request in step 5 contains everything from step 1 plus the album list. A conversation with many tool calls means every new request is longer than the last.
That makes size matter, which leads to tokens.
Models do not read text letter by letter or word by word. They read it in chunks called tokens; a token is very roughly three quarters of an English word. Two numbers follow from that:
Everything a tool returns becomes tokens in the conversation, and is sent again on every later request. Imagine a tool that returns ten thousand photo records when the user only wanted a count. That one result can fill much of the context window, push out what came before, cost money on every subsequent round, and leave the model hunting for a number in a wall of JSON.
That is the single biggest reason good tools return small, focused results: a count instead of a list, one page instead of everything, the fields that matter instead of every column. A later part is all about designing tools that way.
Once a server is public, and people elsewhere connect their own AI assistants to it, the costs split cleanly in two.
The person using the AI assistant pays for the AI. The model, the context window and the token usage all belong to their subscription: their Copilot licence, their Claude plan, their own agent's API key. The MCP server has no model, so it has no context window and no AI bill.
The server's owner pays for the server. And that is more than just "running a process somewhere":
| Cost | Why a big result makes it worse |
|---|---|
| Compute | More CPU and memory to build and serialize large responses |
| The database | A tool that reads ten thousand rows is a heavy query, and agents may call it again and again |
| Data transfer | Cloud providers charge for data leaving their network |
| Logging | Monitoring services bill by the volume stored; logging large responses gets expensive |
And the AI side is still the server owner's problem in practice. If your tool floods the context window, the user's assistant gives worse answers, and they will blame your service, not their AI. Agents also loop: a confused agent can call the same tool dozens of times in a row. That is why public servers set limits: caps on date ranges, page sizes, and how many calls one account can make per minute.
One more consequence of the loop, easy to miss: everything a tool returns is sent to the model, which runs on the AI provider's servers. If a tool returns a user's name, email address or location, that data leaves your system and goes to whichever AI provider the user's assistant uses.
So deciding which fields a tool returns is not only a size question, it is a privacy question. Return what the task needs, and nothing that it does not.
So the model's job is just to pick the right tool? That is one of its jobs. Its main job is understanding and writing language: it understands the request, picks tools when it needs them, reads what they return, and turns it into an answer. Many questions need no tool at all.
Why does the host send the result back to the model instead of showing it? Because the result is data, not an answer. The model has to interpret it, often decide another step based on it, and handle errors. The host only carries messages.
Does the model remember earlier messages? No. The host resends the whole conversation on every request. The memory lives in the host, not the model.
Whose context window does a big tool result fill? The user's: it lives in the conversation inside their assistant. The server has no context window. But a server that returns huge results makes its users' assistants worse, so it is still the server's problem.
If users pay for their own AI, is the server free to run? No. You pay for hosting, the database load your tools create, data transfer and logging, and large or frequent calls make all of those grow.
When a tool returns data, where does that data travel? From your server to the host, and from the host to the AI provider, as part of the conversation. Treat every field a tool returns as something you are sending to a third party.