Agent Tools and MCPs
Now that we’ve built our first working AI agent, it’s time to give it some real capabilities. In this chapter, we’ll go beyond the basics and dive deep into one of the most important elements of OpenAI Agents SDK: tools. Tools are what enable agents to interact with the outside world, such as querying databases, calling APIs, performing calculations, generating content, and even calling other agents.
Here is what you will learn as part of this chapter:
- Custom tools: Learn how to define Python functions and register them as tools using the
@function_tool
decorator. We’ll explore how to configure tool metadata, validate inputs using Pydantic, and control how tools are described to the agent. - Agent-tool behavior: Understand how to influence when and how an agent uses a tool by leveraging parameters such as
tool_choice
andtool_use_behavior
. - OpenAI-hosted tools: Use OpenAI’s pre-built tools, such as
WebSearchTool...