AI Nexus

Try it yourself

Try asking

Chapter 4

AI Agents and Tool Use

Even with retrieval, a language model still only produces text: it cannot perform a precise calculation, take an action or reach out to another system to check something in real time. It also can't decide partway through answering that it needs to do one of those things; at best, it can only respond with whatever it's already been given.

An AI agent extends a language model with the ability to take actions, by giving it a defined set of tools it's allowed to call (a calculator, a search function, a request to another system) along with a description of what each tool does. Instead of only producing a final answer, the model can produce a request to use one of these tools. That request is carried out outside the model, and the result is fed back into the conversation as something the model just observed. The model then decides, based on that new information, whether it can answer now or needs to call another tool. Think, act, observe and repeat until ready to answer: this cycle is often called the ReAct pattern, short for "reason and act," and it's the mechanism behind every AI system capable of doing more than talking.

AnalogyA plain chatbot is like asking someone a question and only getting an answer from whatever they already remember. An agent is like sending someone to actually go find the answer: they might do a calculation, check a source or make a call, and only report back once they've gathered what's actually needed, adjusting their next step based on what they learn along the way, rather than committing to one fixed plan up front.

Tool use raises a practical problem, though: every application that wants to give a model access to a tool would otherwise need its own custom, one-off integration for that specific tool. The Model Context Protocol (MCP) is an open standard that solves this by defining one common format for describing tools and exchanging tool calls and results, independent of which AI model or application is using them. A program exposing tools over MCP can be reached by any MCP-compatible agent, and an agent that speaks MCP can use tools from any MCP-compatible source; neither side needs to know anything specific about the other beyond the shared protocol.

AnalogyMCP plays a similar role for AI tools that a standard electrical outlet plays for appliances. Without a shared standard, every appliance would need its own uniquely shaped plug matched to a uniquely shaped outlet. Because manufacturers build to one shared standard instead, any compliant appliance works in any compliant outlet. MCP defines one shared "plug shape" for AI tools, so an agent and a tool server that have never seen each other before can still connect.

In this demo

This agent can currently:

  • Do exact arithmetic with a real calculator, instead of guessing at numbers
  • Answer questions about AI concepts (LLMs, RAG, agents, MCP, vector databases, and more) by searching the same knowledge base used in the previous chapter
  • With "extra tools" switched on above: check the current time, look up the real current weather for a city (via WeatherAPI.com), or list the topics this tutorial covers, reaching those tools over MCP, described above

The weather tool specifically is worth calling out: it calls WeatherAPI.com's real current-conditions endpoint, not a canned demo value, which is exactly the point MCP's "any tool source" pitch above is making concretely instead of abstractly. A tool server exposed over MCP isn't limited to illustrative data; it can just as easily be a thin wrapper around a real external system, and the agent calling it neither knows nor cares which, only that it asked for a city's weather and got back a real answer. Try the "Check the weather" sample below and look at the tool result step in the trace: it says outright that the number came from a live WeatherAPI.com call just now, not a demo value dressed up to look real.

Above, you could try a sample prompt or write your own: anything that needs a calculation or a factual lookup works well. The reasoning trace it produced lists every tool the agent called, exactly what it sent, what came back and finally its answer, so you can see its thinking instead of just the result.

AI Nexus: An Interactive TutorialPage 4