What is function calling?
On its own, a language model can only produce text. Function calling lets that text be a request: run this query, look up this ad, start this workflow. The model writes the request in a fixed format, the application checks and runs it, and the result goes back to the model to use in its answer.
It's the basic mechanism behind every AI agent. An agent is, in large part, a model calling tools in a loop until the job is done.
How does function calling work?
- Describe the tools. The application gives the model a schema for each tool: a name, a description of what it does, and the inputs it takes, with their types.
- Choose. Given a request, the model decides whether a tool would help, and which one.
- Fill in the inputs. The model returns a structured call, such as a tool name plus a date range and an account ID.
- Check and run. The application validates the call, checks permissions, and runs it. The model never touches the system directly.
- Use the result. The output goes back to the model, which answers or calls the next tool.
What makes a good tool schema
- A specific name. A name like get_campaign_spend tells the model more than query_data.
- A description of when to use it. The model chooses from the description alone, so say what the tool is for and what it shouldn't be used for.
- Typed, limited inputs. Dates as dates, and a fixed list of allowed values where there is one, so bad inputs fail early.
- Errors that explain. An error that says what was wrong lets the model fix its own call.
What is an example of function calling?
Answering a cost question with two tools
A strategist asks an agent why cost per acquisition rose last week. The agent calls a spend tool for the account and dates, sees that one campaign's spend doubled, then calls an ad-details tool for that campaign.
Each call runs with the strategist's own permissions. The agent combines both results into one answer and shows the data behind it.
Function calling vs. MCP vs. a plain API
| Plain API | Function calling | MCP | |
|---|---|---|---|
| Who calls it | Code a developer wrote | A model, through the application | A model, through any MCP-compatible client |
| How tools are described | API docs written for people | A schema per tool, set up in each app | A standard format any client can read |
| Works across AI tools | Needs custom code each time | Needs setup in each app | Yes |
Why does function calling matter, and how do you keep it safe?
Tool use is what turns an assistant that explains into an agent that does. That also makes it where most of an agent's risk sits.
- Run with the user's permissions. An agent should reach only what the person using it could reach on their own.
- Start read-only. Let teams build trust with tools that read, then add tools that change things.
- Approve consequential calls. Spending money, publishing, and deleting should wait for a person.
- Keep the tool list short. The more tools a model can see, the more often it picks the wrong one.
How does Alli do this?
Alli by PMG's MCP Server turns the Alli API into tools any MCP-ready agent can call, such as querying governed data, building dashboards, managing datasources, and triggering workflows. Tool definitions update as Alli's API specifications change, so there's no wrapper code to maintain.
Teams turn each tool on or off and keep the count where the agent works best. Every request carries the signed-in user's own authorization through OAuth 2.1, so agents only reach the tools and data that person can use, and teams can start with read-only questions before moving to actions.
Explore Alli MCP ServerFunction calling (tool use) FAQ
Is function calling the same as tool use?
Yes. Function calling is the term some model providers use, and tool use or tool calling is the more general one. All three describe a model asking software to run an action.
Does the AI run the function itself?
No. The model only returns a request. The application decides whether to run it, runs it, and sends back the result.
How many tools should an agent have?
As few as the job needs. Each extra tool is another option to choose wrongly, so teams group related actions and turn off tools a given agent doesn't use.
What is the difference between function calling and MCP?
Function calling is the mechanism: the model requests a tool. MCP is a standard for publishing tools, so one set of tools works across many AI clients without custom setup in each.
Last updated Back to the glossary
