To Openai Tool • AI Agent SDK
to_openai_tool: Convert the MCP tool to an OpenAI-compatible tool definition.
to_openai_tool
Method
</div>
Convert the MCP tool to an OpenAI-compatible tool definition.
This method is specifically invoked by the Agent class when using provider/model format (e.g., “openai/gpt-4o-mini”).
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
agent["Agent"] -- "uses" --> tool["Tool: to_openai_tool"]
tool -- "returns" --> result["Result"]
style tool fill:#189AB4,color:#fff
style agent fill:#8B0000,color:#fff
style result fill:#8B0000,color:#fffSignature
def to_openai_tool() -> AnyReturns
ResponseField
AnyOpenAI-compatible tool definition(s)
Uses
to_openai_toolslogging.warning
Source
View on GitHubpraisonaiagents/mcp/mcp.py at line 1383