PromptisePromptise
PlatformSoonEnterprise
DocsGitHub
Talk to usGet started
Promptise - AI Framework LogoPromptise

The full-stack framework for agentic systems. Build with the framework. Run it on the platform. Launch it with our engineers.

pip install promptise

[01] Product

  • Framework
  • Platform (coming soon)
  • Enterprise
  • How it works
  • Contact

[02] Framework

  • The Agent
  • The Interface
  • The Harness

[03] Resources

  • Documentation
  • GitHub
  • Why Promptise
  • Use cases
  • Roadmap
  • Guides
  • Learning Paths
  • Questions

[04] Company

  • About
  • Terms of Service
  • Privacy Policy
  • Cookie Policy
  • Subprocessors

© 2026 Promptise by Manser Ventures. All rights reserved.

hello@promptise.com
← Guides> Tools and the Model Context Protocol (MCP)

What Is Tool Calling? LLM Function Calling Explained

What tool calling (function calling) is: how an LLM asks your code to run a function, the JSON schema it sees, parallel calls, and how it differs from MCP.

Level
Beginner
Reading time
7 min
Published
Oct 18, 2026
Last updated
Oct 24, 2026
By
Promptise Team
  • Tool Calling
  • Model Context Protocol (MCP)
Contents · 7 sections↓
  1. 01What is tool calling?
  2. 02How does tool calling work?
  3. 03A tool calling example
  4. 04Tool calling vs function calling, MCP and structured outputs
  5. 05Common misconceptions about tool calling
  6. 06Frequently asked questions
  7. 07Next steps

Tool calling is how a language model asks your code to run a function, such as looking up an order or querying a database, and then uses the result in its answer. OpenAI calls it function calling, Anthropic calls it tool use, and most frameworks say tool calling. This page shows the request and response cycle with a real run, explains parallel calls, and separates tool calling from MCP, structured outputs and agents.

[01]

What is tool calling?

Tool calling (also called function calling) is an LLM API feature that lets a model ask your application to run a function. You send tools as names, descriptions and JSON schemas. When a tool would help, the model replies with a structured call instead of text. Your code runs it and returns the result.

Key takeaways:

  • The model never executes anything. It returns a tool name and JSON arguments. OpenAI's function calling guide puts it plainly: when the model calls a function, you must execute it and return the result.

  • The schema is the interface. The model only knows what the name, description and parameter schema tell it. Vague descriptions cause wrong calls.

  • One turn can contain several calls. Models can request parallel tool calls when the calls don't depend on each other.

  • Tool calling is the building block of agents. An agent is tool calling in a loop.


[02]

How does tool calling work?

Every provider follows the same cycle. OpenAI's guide lists five steps: send a request with the tools the model may call, receive a tool call, run your code with the call's arguments, send a second request with the tool output, and receive a final answer or more tool calls.

A sequence between your app and the model API: the app sends messages and tool schemas, the model returns a get_weather tool call, your code runs it, the app sends the tool result with the same call ID, and the model replies with a final answer or more tool calls.
FigureThe five steps of a tool call between your app and the model API

The details differ by provider. In the OpenAI API the reply carries tool_calls, and you return each result as a tool message with the matching call ID. In the Anthropic API the reply has stop_reason: "tool_use" and one or more tool_use blocks, and you answer with tool_result blocks, as its tool use docs describe. Anthropic also runs some server tools, such as web search, on its own infrastructure; for your own tools, your code still does the work.

Two options matter in practice. Parallel tool calls let the model ask for several calls in one turn; OpenAI's parallel_tool_calls: false limits it to zero or one. Strict mode (strict: true) makes the arguments match your schema exactly, which OpenAI recommends enabling. OpenAI introduced function calling in June 2023, and every major model API now supports some version of it.


[03]

A tool calling example

The script prints the schema the model receives for a small Python function, then asks a question that needs two lookups. Promptise Foundry's @tool decorator generates the schema from the function's signature and docstring, and the agent runs the call cycle for you.

Pythontool_calling.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import asyncio
import json

from langchain_core.utils.function_calling import convert_to_openai_tool
from promptise import build_agent, tool

FORECASTS = {"Paris": "14°C, light rain", "Tokyo": "22°C, clear"}


@tool
def get_weather(city: str) -> str:
    """Current weather for a city."""
    return FORECASTS.get(city, "No data")


async def main():
    # 1. What the model receives: a name, a description and a JSON schema.
    print(json.dumps(convert_to_openai_tool(get_weather), indent=2))

    # 2. What the model sends back, and what the agent does with it.
    agent = await build_agent(
        model="openai:gpt-5-mini",
        instructions="Answer briefly.",
        extra_tools=[get_weather],
    )
    try:
        result = await agent.ainvoke(
            {"messages": [{"role": "user", "content": "Is it warmer in Paris or Tokyo?"}]}
        )
        for msg in result["messages"][1:]:
            for call in getattr(msg, "tool_calls", None) or []:
                print(f"tool call  id={call['id'][:12]}...  {call['name']} {call['args']}")
            if msg.type == "tool":
                print(f"result     id={msg.tool_call_id[:12]}...  {msg.content}")
            elif msg.content:
                print(f"answer     {msg.content}")
    finally:
        await agent.shutdown()


asyncio.run(main())

Real output from one run with gpt-5-mini:

Output
{
  "type": "function",
  "function": {
    "name": "get_weather",
    "description": "Current weather for a city.",
    "parameters": {
      "properties": {
        "city": {
          "type": "string"
        }
      },
      "required": [
        "city"
      ],
      "type": "object"
    }
  }
}
tool call  id=call_6BqLkdr...  get_weather {'city': 'Paris'}
tool call  id=call_z6aZl8L...  get_weather {'city': 'Tokyo'}
result     id=call_6BqLkdr...  14°C, light rain
result     id=call_z6aZl8L...  22°C, clear
answer     Tokyo is warmer — 22°C (clear) vs Paris 14°C (light rain).

The first block is everything the model knows about the tool: its name, one sentence of description and a schema with one required string. The model then asked for both cities in a single turn, two parallel calls with different IDs. Each result goes back with the ID of the call it answers, which is how the model matches results to requests. The answer comes from the tool results, not from the model's training data.

Note what is missing from the schema: the city parameter has no description. For a tool this simple that's fine. For tools with dates, IDs or units, describe each parameter, or the model will guess the format. How LLM tool calling works has more design rules for tools and results.


[04]

Tool calling vs function calling, MCP and structured outputs

Term

What it is

Who runs the code

Use it for

Tool calling

Model API feature: the model returns a structured call to one of your tools

Your application

Letting a model use APIs, databases and code

Function calling

OpenAI's name for the same feature

Your application

Same as tool calling

MCP (Model Context Protocol)

A protocol for discovering and calling tools that live in a separate server

The MCP server, called by your app's MCP client

Reusing tools across agents and apps

Structured outputs

The model's final answer is forced to match a JSON schema

Nobody: it is just output

Extracting data in a fixed shape

AI agent

A loop that repeats tool calling until a goal is met

Your application, or a framework

Multi-step tasks

MCP and tool calling work together rather than compete. An agent connects to an MCP server, lists its tools, and passes their schemas to the model through the model's tool calling API. When the model asks for a tool, the agent forwards the call to the server. What is MCP explains the protocol, and MCP tools vs resources vs prompts covers what else a server can offer.


[05]

Common misconceptions about tool calling

"The model runs my function." It doesn't, and that is the most useful fact about tool calling. Because your code runs every call, you can validate the arguments, check permissions, ask a human, or refuse. Human approval for tool calls builds on exactly this.

"Tool call arguments can be trusted." The model fills in arguments from the conversation, which may include text from a user, a web page or another tool. Treat arguments as untrusted input: validate types and ranges, and never pass them straight to a shell or SQL query. Prompt injection defense for AI agents explains why.

"The model picks the right tool every time." It picks based on names and descriptions. Overlapping tools, vague descriptions and long tool lists all cause wrong choices. Too many MCP tools shows what happens past a few dozen tools.

"Tool schemas are free." Every schema is sent as input tokens on every model call. Large tool lists add cost to each round of an agent.


[06]

Frequently asked questions

Is tool calling the same as function calling?

Yes. Function calling is OpenAI's name for the feature, and its docs say it is also known as tool calling. Anthropic calls it tool use. They all describe the same idea: the model returns a structured request to call a function you defined, and your application runs it.

Does the LLM execute the function?

No. The model only produces a tool name and arguments as JSON. Your application, or the framework you use, runs the function and sends the result back to the model in the next request. Some providers also host built-in server tools such as web search, which run on the provider's side.

What is parallel tool calling?

Parallel tool calling means the model asks for several tool calls in one reply, for example the weather in two cities. Your code can run them at the same time and return each result with its call ID. Disable it when calls must happen in order or when you want to approve them one at a time.

What is the difference between tool calling and MCP?

Tool calling is how a model asks for a tool. MCP is how an application finds tools and calls them in a separate server. An agent uses both: MCP to list and run the tools, tool calling to let the model choose them. You can use tool calling without MCP by passing plain functions.

Which models support tool calling?

All major model APIs support it, including OpenAI, Anthropic, Google and Mistral, and many open-weight models served through tools like Ollama or vLLM. Quality varies: smaller models are more likely to pick the wrong tool or produce invalid arguments, so test with the model you plan to use.


[07]

Next steps

  • See tool calling inside an agent loop: How to build an AI agent in Python.

  • Design tools the model uses well: How LLM tool calling works.

  • Put tools in a server: What is MCP?

  • All guides on the topic: the tools and MCP hub.

  • Reference: Building agents in the Promptise docs.

Contents

  1. 01What is tool calling?
  2. 02How does tool calling work?
  3. 03A tool calling example
  4. 04Tool calling vs function calling, MCP and structured outputs
  5. 05Common misconceptions about tool calling
  6. 06Frequently asked questions
  7. 07Next steps

Learning paths

Want more structure? Paths put guides in order, like a short course.

See the paths →

> Tools and the Model Context Protocol (MCP)

Related guides

All guides in this topic →
  • // 01Intermediate · 20 minMCP Tools vs Resources vs Prompts (With Python Examples)When to use an MCP tool, resource or prompt, and how to build each in Python: resource templates, prompt arguments, tests and feeding them to an agent.
  • // 02Beginner · 12 minHow to Connect MCP Servers to Your AI Agent in PythonGive your AI agent real tools with the Model Context Protocol. Connect local and remote MCP servers to a Python agent, step by step, with code you can run.
  • // 03Intermediate · 18 minBuild a Production MCP Server in Python (Step by Step)Build an MCP server in Python ready for real agents: typed tools, clear errors, API keys with roles, rate limits, a tamper-evident audit log and tests.
  • // 04Intermediate · 22 minMCP Transports: stdio vs Streamable HTTP vs SSE (Python)stdio vs Streamable HTTP vs SSE, shown on the wire with curl, then an MCP server over HTTP in production: Host checks, auth, health checks and scaling.
  • // 05Advanced · 22 minMCP 2026-07-28 Migration: Make Your MCP Server StatelessMigrate an MCP server to the stateless 2026-07-28 spec: what changed, how to replace sessions and elicitation, and a runnable before and after in Python.
  • // 06Intermediate · 15 minOpenAPI to MCP: Turn Any REST API into an MCP ServerTurn an OpenAPI spec into a working MCP server in minutes. Read-only by default, human approval on every write, and tested by a real agent.

Keep going.

Browse every guide by topic and level, or follow a learning path that puts them in order.

All guidesLearning paths