What is function calling?
Function calling, also called tool calling, is how a language model asks your code to do something. You describe each function with a name, a description and a JSON Schema for its arguments. The model replies with a structured call instead of prose, your program runs it and sends the result back, and the model continues with that information.
Part of Glossary: the terms behind MCP, coding agents and shared pages, defined plainly.
You send the model your messages plus a list of tools. Each tool has a name, a description and a JSON Schema for its parameters.
The model decides a tool is needed and answers with a call: the tool's name and its arguments as JSON, not a sentence.
{ "name": "get_weather", "arguments": { "location": "Lisbon" } }Your code runs the function. The model never executes anything; it only asks, and it can ask for several calls in one turn.
You send the output back tagged with the call's id, so the model knows which request the result belongs to.
The model reads the result and either answers in words or asks for another call. That loop is the base of every agent.
Function calling versus tool calling and MCP
Three names, one idea. OpenAI's API calls it function calling: you pass a tools array where each entry has type: "function", a name, a description and parameters as JSON Schema, and the model returns function_call items carrying a call_id and arguments as a JSON string. Anthropic calls it tool use: the tool has an input_schema, the model stops with stop_reason: "tool_use", and you answer with a tool_result block that names the tool_use_id. Different field names, same loop.
MCP sits one level up. A Model Context Protocol server publishes its tools through tools/list with the same kind of inputSchema, and the client invokes them with tools/call. The client's job is to turn that list into whatever its model's API expects. So when Claude Code or Codex uses an MCP tool, function calling is still what happens between the client and the model; MCP just means the tool was defined once, on a server, for every client.
Example: a weather lookup
Your app gives the model one tool, get_weather, whose schema has a required location string. You ask "What's it like in Lisbon?" The model doesn't guess. It replies with a call to get_weather and {"location": "Lisbon"}. Your code hits a weather API, gets back "17 degrees, light rain", and sends that string to the model as the result for that call. The model then writes the sentence you see. Two round trips, and the model never touched the network.
Why it matters
Function calling is the seam between a model that writes text and an agent that does things. Everything an agent can do, from editing a file to publishing a board, is a function somebody described in a schema. That has two consequences worth holding on to.
First, the description is the interface. The model picks tools by reading their descriptions, so a vague one gets called at the wrong times and a clear one, saying when to use it and what each argument means, gets called well. Second, your code sits between the call and the effect. That is where you check arguments, ask the person, or refuse. The MCP spec says there should always be a human in the loop able to deny a tool call; function calling is what makes that possible, because the model can only request.
Common mistakes
- Treating arguments as trusted. They are model output. Validate them like any other user input before you act on them.
- Returning nothing for a side-effect function. Send a short success or failure string back. A model told nothing will often call the tool again.
- Assuming one call per turn. Models return zero, one or several calls. Loop over them, and match each result to its call id.
- Loading every tool every time. Definitions cost tokens on each request. Keep the set small, or use the providers' tool search to defer the rest.
FAQ
- Is function calling the same as tool calling or tool use?
- Yes. OpenAI's docs say function calling, Anthropic's say tool use, and most people say tool calling. The mechanism is the same: schemas in, a structured call out, a result back in. MCP tools are the portable version, defined once on a server for any client.
- Does the model run the function during function calling?
- No. The model only produces the call: a name and JSON arguments. Your program decides whether to run it, runs it, and returns whatever you choose as the result. That gap is where permission prompts and sandboxes live.
- How many functions can I give a model for function calling?
- There is no hard limit, but every definition counts as input tokens. OpenAI's guide suggests aiming for fewer than 20 functions available at the start of a turn, and both OpenAI and Anthropic offer tool search to load large sets on demand.
Stop sending HTMLover Slack.
Create an account in a minute, connect your coding agent, and make your first board.