Letting the Model Act
On its own, a model can’t act on anything outside itself. It can’t check today’s calendar, look up an order or add up a spreadsheet. Ask it anyway and it may guess. There are two places you’ll want to give a model more reach: in the app you’re shipping, so it can act on live data, and in the editor you’re building with, so it stops guessing about APIs. This lesson covers both:- Part 1: Tools in your app. With tool use (also called function calling), you describe functions your app can run. When the model needs one, it asks your app to run it, your app sends back the result, and the model uses that result in its answer. The model decides what to do; your code does it.
- Part 2: MCP in your editor. MCP is an open standard for connecting AI tools to outside sources. You’ll use it to give your coding assistant Gloo’s docs, so its answers about the API stay current.
Core Concepts
Part 1: Tools in Your App
The Tool Loop
In its simplest form, the loop has five steps and two requests:- You send the question and your tool definitions. Each tool has a
name, adescriptionandparameters, a JSON Schema for its inputs (the same kind of schema as in Lesson 3). - The model replies with a tool call instead of an answer: the tool’s name and the arguments it wants to use.
- Your app runs the function with those arguments.
- You send a second request with the conversation so far, the model’s tool call and your result.
- The model writes its answer using the result.
Writing Good Tool Definitions
The model chooses tools by reading your descriptions, so write them for the model:- Name says what it does:
get_service_times, nottool1. - Description says when to use it, in a sentence or two.
- Parameters are as specific as you can make them: use
enumfor a fixed set of values, and mark what’srequired.
Choosing When Tools Are Used
tool_choice controls whether the model must use a tool. Leave it out and the model decides. Set it to "required" to make the model call one, which is how Lesson 3 got structured output.
Part 2: MCP in Your Editor
What MCP Is
The Model Context Protocol (MCP) is an open standard that lets AI tools, such as Claude, Cursor, VS Code and ChatGPT, connect to outside data sources and search them directly. Gloo hosts an MCP server for its documentation athttps://docs.gloo.com/mcp. Connect your coding assistant to it, and when you ask how to call a Gloo endpoint, it looks up the current docs instead of relying on what it learned in training. So its answers about model IDs, fields and URLs come from the docs as they are today.
Get Started
Part 1: Run the Tool Loop
This example gives the model one tool, runs each function it asks for, and sends back the results until the model answers. It uses the guarded Responses endpoint (with Gloo’s guardrails, priced at the model’s rate plus 6.5%), as in the Tool Use guide.Python
function_call item like this:
call_id ties your function_call_output to the call it answers, so both items need the same one.
Part 2: Connect Your Coding Assistant to Gloo’s Docs
In Claude Code, one command adds the docs server:mcp.json:
Good to Know
- Use the nested tool schema. Define tools as
{"type": "function", "function": { ... }}on both the Responses and Chat Completions endpoints. The flat Responses tool schema isn’t reliably accepted across providers. In TypeScript, the SDK’s types expect the flat schema, so the Tool Use guide adds// @ts-ignore. - Pin the model. Tool calls behave most consistently when the same model handles every call. Avoid auto-routing for tool workflows.
- Check the model supports tools. The catalog’s
supports_toolsflag tells you. See Supported Models. - Validate arguments before acting. Treat the arguments like any user input. Check them before you query a database or send a message.
- Don’t repeat side effects. If a request is retried after a tool already ran, a tool that sends an email could send it twice. Give each tool run an ID so a repeat can be spotted and skipped. Handling Streaming Failures covers this.
Key Takeaway
Tool use lets the model ask your app to do things it can’t do alone: fetch live data, look things up, run exact calculations. You define the tools, the model asks for them, your code runs them and sends back the result. In your editor, MCP lets your coding assistant search Gloo’s docs, so its answers about the API stay current.Learn more
- Tool Use: tool definitions, tool calls and multi-turn results on each endpoint
- Completions with Tool Use: a complete tool-use project in several languages
- MCP Integration: connect Gloo’s docs to your AI tools
What’s next
Next, you’ll see how a coding agent runs this tool loop again and again to finish a whole task, and where a person approves what it does.Lesson 5: Coding Agents
How an agent plans, acts and checks its work.

