Deutsch
Agent protocols

Tool calling

Also known as: function calling, tool use

Tool calling, also called function calling or tool use, is the ability of a language model to answer with a structured request to run a function instead of plain text. The functions are ones that developers or providers make available, such as a database query or an API call. The model does not run the function itself. Your application or the model provider does.

At a glance

Type
ability of language models to output structured function calls
Used in
OpenAI API, Anthropic API and others
Flow
request with tools, tool call, execution by the application, result, answer

Last checked:

How does a tool call work?

OpenAI describes five steps. The application sends the model a request that includes the available tools. The model returns a tool call with arguments. The application runs the code with that input and sends the output back. The model then writes its final answer or makes further tool calls.

Each tool is defined with a name, a description and a JSON schema for its parameters. Anthropic distinguishes client tools, which run in your application, from server tools such as web search, which run on Anthropic’s infrastructure. For a client tool, the response carries stop_reason: "tool_use" and a tool_use block, and the application replies with a tool_result. Tool definitions count as input tokens.

Example

An application defines this tool:

JSON
{
  "name": "get_weather",
  "description": "Get the current weather for a given location.",
  "input_schema": {
    "type": "object",
    "properties": {
      "location": { "type": "string" }
    },
    "required": ["location"]
  }
}

A user asks about the weather in San Francisco. The model responds with a tool_use block that names get_weather and the argument San Francisco, CA. The application looks up the weather and returns the result, and the model phrases the answer.

Tool calling and MCP

Tool calling describes how a model expresses a function call. The Model Context Protocol (MCP) describes how an AI application finds and calls tools on external servers. In an MCP setup, the host takes a tool call produced by the model and forwards it to the right MCP server.

MCP: host, clients and servers, plus WebMCPAn AI application acting as host starts one MCP client per server. Each server offers tools, resources and prompts. Local servers connect via stdio, remote servers via Streamable HTTP. Below, WebMCP: a web page registers tools in JavaScript, and an agent in the browser calls them.HOSTMCP SERVERSHostAI application, e.g. a chat appMCP client 1stdioServer 1 · fileslocalToolsResourcesPromptsMCP client 2stdioServer 2 · databaselocalToolsResourcesPromptsMCP client 3Streamable HTTPServer 3 · external APIremoteToolsResourcesPromptsWEBMCP · DRAFT OF THE W3C WEB MACHINE LEARNING COMMUNITY GROUPAgent in the browsere.g. the browser’s agentcalls a toolWeb pageregisters JavaScript tools that run in the browserSchematic. As of MCP specification 2026-07-28 and WebMCP draft of Oct 2, 2026.
According to the MCP specification, a host starts one client per server. Servers offer tools, resources and prompts and run locally (stdio) or remotely (Streamable HTTP). WebMCP is a draft by a W3C community group, not a W3C standard. Here the web page provides its tools inside the browser. Sources: Model Context Protocol: Specification 2026-07-28; Model Context Protocol: Architecture; Model Context Protocol: Transports; W3C Web Machine Learning Community Group: WebMCP (draft of Oct 2, 2026).

Common mistakes

  • Vague names and descriptions. OpenAI advises clear, detailed function names, parameter descriptions and instructions.
  • Too many tools at once. OpenAI gives fewer than 20 initially available functions as a guideline. Tool definitions also count as input tokens.
  • Leaving required inputs open. If a required parameter is missing, the model may infer a plausible value instead of asking, according to Anthropic’s documentation.

FAQ

Does the model run the function? For client tools the application runs it. For server tools the provider does.

Is function calling the same as tool calling? Providers use the terms for the same technique. Anthropic’s documentation calls tool use “also called function calling”.

Sources

  1. Function calling – OpenAI Developersdevelopers.openai.com
  2. Tool use with Claude – Anthropicplatform.claude.com
  3. Architecture overview – modelcontextprotocol.iomodelcontextprotocol.io

Last updated: