AI, explained simply

How LLMs work, and what the heck are tool calls and MCP?

An AI app just made Riya a PDF. But AI can't make files: all it can do is guess the next word. So how? Let's solve the puzzle, one picture at a time.

Riya is in class 10, she's crazy about cricket, and she uses an AI app for almost everything. Today she types one line: "Make my exam timetable into a PDF." A few seconds later, a real PDF appears, ready to download.

What Riya sees on her screen.

But here's the strange part. The AI that did this can't make files. It can't open apps. It can't even do big sums reliably. All it can do is guess the next word. So how did a word-guesser just make a PDF?

Let's solve this puzzle together. By the end, you'll know exactly how it happened, and you'll never look at an AI app the same way again.

1The guessing machine

Let's start with a quick game. Finish this sentence: "The sun rises in the…"

You said "east", didn't you? You didn't look it up. You guessed, from everything you've ever read. Hold on to that feeling, because that guess is the whole trick.

Ever noticed your phone playing the same game? Type "see you" and the keyboard guesses "tomorrow", "soon" or "later".

Your keyboard guesses the next word, from the little text it has seen.

But your keyboard could never write an essay. It has seen far too little text. So to build a better guesser, we need it to read much, much more: books, websites, stories, questions and answers. More text than one person could read in a hundred thousand years.

But reading alone doesn't make it smart. So while it reads, it plays our game billions of times. It hides the next word and guesses. Say it guesses "west" for our sentence. The real word is "east". Wrong! So it adjusts itself, just a tiny bit, so that next time "east" is a little more likely.

Adjusts what, exactly? Picture a giant music mixer with billions of tiny knobs. Every wrong guess nudges a few knobs. After billions of rounds, they're set so well that the guesses become amazing. That giant guesser with its billions of knobs is what we call a large language model, or LLM.

But there's a catch: it doesn't see words the way we do. It chops text into pieces called tokens. Common words stay whole; long words get split. And each piece becomes a number, because numbers are all a computer can work with.

"unbreakable" becomes three tokens. The numbers are just examples: every AI has its own list of tokens.

That explains a famous mistake. Ask an AI how many r's are in "strawberry" and it can get it wrong. It never sees the letters, only chunks like "str", "aw" and "berry".

So how does it actually answer? Give it "The capital of France is…". It looks back at the words that matter, "capital" and "France", and scores every possible next piece. "Paris" wins. It adds "Paris" to the end, then guesses again, and again. That's how a whole answer appears, piece by piece, and why you see the AI "typing".

The blue words are the ones it pays most attention to. Then it scores the options and picks one.

But if it always picked the top word, every answer would come out exactly the same, like a robot. So it rolls loaded dice: the best word usually wins, but sometimes the second best gets a turn. That's why the same question can get two different answers.

But a guesser trained on the internet has a funny problem. Ask it "What's a good name for my cricket team?" and it might reply with more questions: "What's a good name for my football team? What's a good name for my…". So it gets a second round of training on example conversations, with people grading the answers like a teacher marking homework. Now the most likely next words are a helpful answer: "How about the Thunder Strikers?"

2The whiteboard

Here's a second puzzle. Riya's app seems to remember her, but the model remembers nothing at all. She says "Hi, I'm Riya." Next message: "What's my name?" On its own, the model has no idea. Every message starts fresh, like a goldfish.

So how does the app fake a memory? With a whiteboard. Before every reply, the app writes the whole chat onto the whiteboard, and the model reads all of it. Now it knows her name. That whiteboard has a name too: the context.

Apps can also keep notes about you, called memory. Riya's say: class 10, exams next week, loves cricket, vegetarian. When she asks "Plan my Sunday", the app quietly copies those notes onto the whiteboard too.

The app copies her notes, the chat and her new message onto the whiteboard. The blue words in the answer came straight from it.

Her friend Kabir asks the same thing, but his notes say football and pizza, so he gets football and a pizza night. Same model, different whiteboard, different answer.

But the whiteboard has a size limit, called the context window. So good apps choose carefully what to keep: the most useful notes and the latest messages.

3The order slip

So now we have a word-guesser with a whiteboard. Back to our puzzle. It still can't check today's cricket score. It still can't do big sums reliably. And it still can't make a file. So how did it make that PDF?

Let's think about a restaurant. The waiter can't cook, but nobody leaves hungry. Why? Because the waiter does one simple thing: writes your order on a slip, and the kitchen does the cooking.

What if our word-guesser could write an order slip? It can. It just has to guess one special word, <tool_call>, followed by the name of a tool and the details. That's the whole secret: the model never made the PDF. It guessed the words of an order. That order is called a tool call.

Blue tokens are the order. The yellow token is the result the app hands back. Riya never sees the blue ones.

Meanwhile, the app is watching every word the model writes. Normal words go to Riya's screen. But the moment that special word appears, the app catches it and runs the PDF tool. Then it writes the result back on the whiteboard, and the model says: your file is ready.

Let's replay that PDF, slowly:

  1. Riya asks for her timetable as a PDF.
  2. The model writes the timetable, then an order for the PDF tool.
  3. The app catches the order and makes the file.
  4. The model tells Riya it's ready. Mystery solved!

But how does the model know when to write an order? Practice, like everything else. It was trained on lots of examples where a tool was the right move: a calculator for big sums, a search for today's news, a PDF maker for files. So now, when a tool would help, that special word is simply its best guess.

Let's test it. Riya asks "What's 4,839 × 27?" The model doesn't guess the digits. It writes an order for the calculator. The app runs it, gets 130,653, and the model reads it out. Exactly right.

The model writes the order, the app runs the calculator, and the result goes back to the model.

And notice: the model only ever writes orders. It never runs anything itself. So the app can stop and ask Riya first, before anything serious, like sending an email.

5One menu for every app

But now we hit a new problem. There are thousands of kitchens (Gmail, Calendar, Notion, Spotify) and lots of AI apps. If every AI app wrote its own menu for every kitchen by hand, ten AI apps and a hundred services would need a thousand connections.

We've seen this problem before. Every phone used to need a different charger. Then USB-C arrived: one plug for everything. So AI needed the same thing: one standard way to share menus.

Here's the idea. Each kitchen publishes its own menu of orders on its own server. Any AI app can connect, copy the menu onto its whiteboard, and start placing orders. That standard is called the Model Context Protocol, or MCP. Anthropic introduced it in November 2024, and now it's used all over the AI world.

  1. The AI app, where Riya chats.
  2. The MCP server, which holds a kitchen's menu.
  3. The service itself, like Notion, where the cooking really happens.
Each MCP server holds its own menu. The app copies the menus onto the whiteboard, and the model picks the order it needs.

And the wiring problem disappears. Each AI app learns MCP once, and each service publishes one menu. Instead of a thousand connections, we need about a hundred and ten.

6The big picture

Now, look at that PDF again. Here's everything it took:

  • A word-guesser (the LLM) that writes one token at a time.
  • A whiteboard (the context) that holds the chat and your notes.
  • A special word that's really an order (a tool call), which the app catches and carries out.
  • A menu that any app can publish (MCP), so AI can plug into almost anything.

That's all it took. No magic. So the next time an AI books a ticket, sends an email or edits your notes, you'll know: it's still just guessing the next word. The magic is in what we let those words do.

Comments