Function Calling (Tools)
Learn about the relationship between Function Calling (Tools) and MCP (Model Context Protocol).
What Is Function Calling (Tool Calling)?
Function Calling is a feature that allows an LLM not only to generate text, but also to directly call external functions or APIs.
For example, the function_call feature provided by the OpenAI API is a representative case.
How It Works
- User input: “Tell me today’s weather in Seoul”
- LLM judgment: “This needs a weather API call”
- Tool call: Executes a predefined function, such as
getWeather(location: string) - Receive result:
{ "location": "Seoul", "temp": 28, "condition": "Sunny" } - Generate final response: “Today in Seoul, it is sunny and 28 degrees.”
In other words, the LLM plays the role of converting natural language into function input, while the actual calculation or search is handled by external functions or tools.
Advantages
- Use of real-time data
- The LLM itself does not know information after its training point. Function calls can connect it to up-to-date APIs.
- Accurate calculation
- LLMs are weak at mathematical operations. Calling a calculator API instead returns accurate results.
- Work automation
- “Send an email” -> calls an email API
- “Get the customer list from the DB” -> executes a DB query
Difference Between MCP and Function Calling
-
Function Calling
- A method where an LLM directly calls individual tools
- Requires call definitions at the API or function level
- Examples:
getWeather(),searchStockPrice()
-
MCP (Model Context Protocol)
- A protocol that connects multiple tools, such as functions and resources, in a standardized way
- Abstracts each tool as a “provider,” allowing the LLM to access them consistently
- A higher-level concept that systematically manages “tool calling,” including function calls
Practical Examples
1. Using Function Calling Alone
-
OpenAI Function Call example:
{ "name": "getWeather", "description": "Check current weather", "parameters": { "type": "object", "properties": { "location": { "type": "string" } }, "required": ["location"] } }The model maps
"Seoul"tolocationand runs the API.
2. MCP-Based Function Calling
- MCP groups functions into a Resource Registry for management
- The LLM does not need to know the “weather API” directly; MCP provides an abstracted interface such as
tools.weather - Multiple tools are connected through a standard protocol, reducing confusion and duplication in function calls
Analogy
- Function Calling = individual “instructions for using a tool” (a single tool such as scissors, a hammer, or a screwdriver)
- MCP = “toolbox/workbench” (a system that organizes tools in a standardized way)
Summary
Function Calling is a technology for calling individual APIs, while MCP is a higher-level layer that manages and connects multiple functions or tools in a standardized way.