AI Engineering · Module 06
Tool use and the Model Context Protocol
- Lessons
- 10
- Free
- 1
- Reading
- ~3 h
Your progress
0 / 10 lessons done
Sign in to trackLessons
- Function calling: letting models use toolsFreeMost useful AI features need data the model can’t know: an order, a booking, today’s stock. Function calling is how a model asks your code for that data, and every AI agent in this course runs on the same loop.
- Designing tools a model can use wellA model can only use a tool as well as its definition explains it. Most wrong tool calls in production come from names that overlap, parameters the model can’t know and results it can’t read, and all three are fixed in your code, not in the model.
- Handling tool results and tool errorsA tool-using feature spends most of its life with tools that time out, return nothing or return far too much. What your code puts in each tool result decides whether the model recovers, guesses, leaks another customer’s data or follows instructions a stranger wrote.
- Parallel and sequential tool callsMost tool-using features need more than one lookup per answer. How you order those calls decides whether a reply takes 5 seconds or 10, and whether a busy hour trips a partner’s rate limit.
- Model Context Protocol: one standard for toolsYour users already work inside AI apps you didn’t build. MCP is how your product shows up in those apps, and its security rules decide whether that is safe.
- Building an MCP server in PythonOnce your product has an MCP server, any AI app your customers already use can work with their data. The server is also a new front door to that data, so what it trusts, checks and records decides whether one customer can read another’s.
- Code execution: running model-written code safelySooner or later someone asks your AI feature for a number that must be right: a total, a trend, a chart for a decision. A model that writes and runs code can give it, and the same feature can leak data or run forever if the code runs in the wrong place.
- Computer use: models operating browsers and appsSooner or later a feature needs data from a system with no API, only a screen. Knowing what it costs to let a model drive that screen, and how to fence it in, keeps a clever demo from becoming a slow, expensive and unsafe feature.
- Design: a meeting booking assistantMany useful AI features end in an action: a booking, a refund, a sent message. The model is good at reading what the customer wants. Making the action happen once, at the right time and only after a person approves it is ordinary engineering that you design around the model.
- Lab: give a model a weather and maps toolMost useful AI features need data the model doesn’t have, such as today’s forecast or an order’s status. Wiring two real APIs into the tool loop yourself shows how many calls one answer takes, what each costs, and what the model sees when a tool fails.
Practise with
Terms this module teaches 52
Open glossaryBrowser use tool
A Claude toolset for tasks inside web pages: your app runs the browser, and the model reads pages through their structure and text as well as screenshots.
Client tool
A tool that runs in your own application: the model returns a tool_use block, your code runs it and sends back a tool_result.
Code execution tool
A provider-run tool that lets a model write code and have it run in an isolated container during the same API request, with the output returned to the model.
Computer use
A tool-use loop in which your app runs a machine, sends the model screenshots of it, and performs the mouse and keyboard actions the model asks for.
Container
An isolated environment on a Linux machine with its own files, processes and resource limits. Ordinary containers share the host’s kernel.
Daylight saving time
Moving a region’s clocks forward in summer and back in winter, on dates its own rules set, so the gap between two time zones can change during the year.
Domain allowlist
A network rule that lets a machine reach only the listed hosts and blocks every other address.
Elicitation (MCP)
An MCP client feature that lets a server ask the user for input, such as a confirmation or a form, through the host’s own interface.
Exclusion constraint
A PostgreSQL constraint that rejects a row if any existing row matches it under the operators you choose, such as equal specialist and overlapping time.
Free/busy query
A calendar API request that returns only the time ranges when each calendar is busy, without the events’ details.
Geocoding
Turning a place name or address into map coordinates: a latitude and a longitude.
Haversine formula
A formula for the shortest distance between two points on a sphere from their latitudes and longitudes: the straight-line distance over the Earth’s surface, not the road distance.
IANA time zone
A named region in the IANA time zone database, such as Europe/Lisbon, that records every past and planned change to that region’s clocks.
JSON-RPC
A small protocol for calling a remote method with JSON: a request has a method, params and an id, and the reply carries the same id with a result or an error.
MCP client
The part of an MCP host that talks to exactly one MCP server, sending its requests and reading its replies.
MCP connector (Claude API)
A Claude API beta feature where the API itself connects to a remote MCP server named in the request and runs its tools.
MCP host
The AI app the user works in. It holds the conversation, calls the model, asks the user for consent and starts one MCP client per server.
MCP Inspector
A browser tool for connecting to an MCP server by hand: list its tools, call them with your own arguments and read the raw results.
MCP prompt
A reusable prompt template an MCP server offers, which the user picks from a menu in their app and fills with arguments.
MCP resource
Data an MCP server makes readable by URI, such as a file or an article. The app, not the model, usually decides when to attach it.
MCP server
A program that offers tools, resources or prompts to AI apps through the Model Context Protocol, locally over stdio or remotely over HTTP.
MCP tool
A function an MCP server offers, with a name, a description and an input schema. The model decides when to call it.
MCP transport
The way MCP messages travel between client and server. The specification defines stdio and Streamable HTTP.
Middleware (MCP server)
A function the server runs around every incoming request, before and after the handler, for work every call needs such as logging.
Model Context Protocol (MCP)
An open protocol that lets an AI app connect to servers offering tools, data and prompt templates, so one server works in every app that supports it.
Model turn
One call to the model, from sending the request until its reply ends. In a tool loop, every reply that asks for tools is one turn, and the next turn starts after your code sends the results back.
Multi round-trip request (MCP)
The MCP pattern where a server that needs more input returns a result asking for it, and the client retries the original request with the answer and any state the server returned.
Parallel tool use
A model asking for several tool calls in one reply. Your code can run them at the same time and returns all their results in one message.
Programmatic tool calling
A Claude API feature where the model writes code that calls your tools inside Anthropic’s code execution container, so several calls run without a model turn between them and their intermediate results stay out of the model’s context.
Proposal tool
A tool whose call records an action for a person to approve instead of performing it.
Protected resource metadata
A JSON document (RFC 9728) a protected server publishes at a well-known URL, telling clients which authorization server issues its tokens and which scopes exist.
Range type
A database type that stores an interval, such as a start and end time, as one value that can be tested for overlap.
Reconciliation job
A scheduled job that compares your own records with an outside system’s and reports any difference.
Sandbox
An environment for running untrusted code that can reach nothing it was not given: no network, limited files, and limits on CPU, memory and time.
Server tool
A tool the model provider runs on its own infrastructure within the same request, with no handler code in your application.
Side effect
A change an operation makes beyond returning data, such as writing a record or sending a message.
stdio transport (MCP)
The MCP transport where the host starts the server as a local process and they exchange one JSON message per line over its standard input and output.
Streamable HTTP
The MCP transport for remote servers: each message is an HTTP POST to one endpoint, and the reply is a JSON object or a server-sent events stream for that request.
Token audience
The service an access token was issued for. A server must reject a valid token whose audience is a different service.
Tool annotations
Hints an MCP server attaches to a tool, such as read-only or destructive. Clients may use them to decide what to confirm, but must not trust them from servers they don’t trust.
Tool call
A request from the model, in a tool_use block, for your code to run one named tool with the given input.
Tool definition
The name, description and input schema an application sends to a model for each tool. It is all the model knows about the tool when deciding whether and how to call it.
Tool runner
A helper in the Anthropic SDKs, in beta, that runs the tool-use loop for you: it calls the model, runs the requested functions and sends their results back until the model finishes.
Tool use
A model API feature where the model replies with a request to run a named function with given inputs; your code runs it and sends back the result.
tool_choice
A request setting that controls whether the model may call a tool (auto), must call one (any), must call a named one (tool) or must not call any (none).
tool_result block
A content block in the next user message that returns a tool’s output to the model, linked to the request by the tool_use_id of the matching tool_use block.
tool_use block
A content block in a model reply that names a tool, gives an id for the call and holds the input for it; the reply’s stop_reason is tool_use.
Tool-call round
One model turn plus the tool calls it asks for. A call that needs another call’s output has to wait for a later round.
Toolset
One entry in a request’s tools list that gives the model a family of related tools at once; each call names one member tool and the toolset it belongs to.
User-Agent
An HTTP request header that names the program making the request.
UTC
Coordinated Universal Time, the world’s reference time. It has no daylight saving, so storing instants in UTC keeps them unambiguous.
Write tool
A tool that changes something outside the conversation, such as an order, a payment or a message to a customer, as opposed to a read tool that only fetches data.