Learn about how LLMs make use of tools and MCP Servers.
Large Language Models (LLMs) can answer most user questions but they can’t access or affect the real world.
With access to tools and APIs, LLMs can perform tasks and actions that impact the real world such as booking a flight, sending an email, or updating a database.In this section, we will learn about how LLMs make use of tools and what MCP Servers are. You can skip to the next section to learn about tool use with Agentor.
LLMs first need to know the details of the tool to call it.
This is done by providing a to the LLM.In the following example, we define a tool schema for a weather API function that retrieves the current weather for a given location.
Copy
from openai import OpenAIweather_tool_schema = { "type": "function", "name": "get_weather", "description": "Retrieves the current weather for the given location.", "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "City and country, e.g. London, United Kingdom", }, "units": { "type": "string", "enum": ["celsius", "fahrenheit"], "description": "The units in which the temperature will be returned.", }, }, "required": ["location", "units"], "additionalProperties": False, }, "strict": True,}client = OpenAI()response = client.responses.create( model="gpt-5-nano", input="What is the weather in London?", tools=[weather_tool_schema], )print(response.content)
The LLM will respond with a JSON containing the tool name and the arguments to call the tool.
It’s the job of the developer to implement the tool and call it with the arguments.
The tool result is then fed back to the LLM to answer the user question.
MCP (Model Context Protocol) is a standard for communicating with LLMs that allows them to access external tools, APIs, and other resources.Let’s understand the “why” behind MCP with a comparison between MCP and without MCP.
Without MCP
MCP
Developers need to implement the tool calling logic in the application.
A prebuilt MCP Server can be plugged into the LLM to provide tools and APIs.
Developers need to implement integrations logic for all external tools such as weather API, email API, etc.
Think of MCP like a USB-C port for AI applications.