AI Foundations 5 - Tool Calling

On its own, a model can only produce text. It can’t check today’s date, read a file, or run your test suite — it can only describe what those things might look like. Tools close that gap: they let the model reach out and actually do something, then bring the result back into the conversation.

Basic tool-call flow

The pattern is always roughly the same. The model decides a tool would help, picks which one, and fills in the arguments it needs. Something outside the model — the application — actually runs it. Whatever comes back gets fed into the model’s context, and it decides what to do next based on that.

The model never runs anything itself. It only asks, and something else executes.

Coding tools

In a coding setup, the usual toolbox includes reading and writing files, searching across a codebase, running shell commands, running tests or a linter, and looking things up in documentation or on the web. Stack a handful of these together and a model can go from “here’s the bug” to “here’s a tested fix” without you typing every intermediate command.

Tool definition

Each tool the model can call needs three things spelled out: a name, a description of what it does and when to use it, and a schema for its parameters. The model never sees your actual implementation — it only sees this description, so a vague or misleading one leads to the tool getting picked at the wrong moment, or called with the wrong arguments.

Cost of tools

None of this is free. Every tool’s definition sits in the model’s context on every single call, whether or not it gets used. Every result that comes back adds more. Give a model twenty tools and a habit of calling five of them per step, and your token usage climbs fast — worth watching, especially in a long agent run.

MCP

Model Context Protocol is a shared standard for wiring up tools, so a client doesn’t need custom glue code for every service it wants to connect. Through MCP, a model can be hooked up to things like Figma, Linear, a database, or an internal company API, using the same connection pattern each time instead of a one-off integration per tool.


Previous: AI Foundations 4 - Context Next: AI Foundations 6 - Prompting and Evaluation