To Openai Tool • AI Agent SDK

to_openai_tool: Convert the MCP tool to an OpenAI-compatible tool definition.

to_openai_tool

Method

</div>

This is a method of the MCP class in the mcp module.

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”).

Diagram

uses

returns

Agent

Tool: to_openai_tool

Result

Signature

python
def to_openai_tool() -> Any

Returns

ResponseField Any

OpenAI-compatible tool definition(s)

Uses

  • to_openai_tools
  • logging.warning

Source

View on GitHub

praisonaiagents/mcp/mcp.py at line 1383


Related Documentation