Skip to main content

mcp_kit.adapters.openai

OpenAI Agents SDK adapter for MCP targets.

OpenAIMCPServerAdapter

class OpenAIMCPServerAdapter()

Adapter class to convert MCP targets to OpenAI Agents SDK compatible interface.

This adapter provides compatibility with OpenAI's Agents SDK by implementing the expected interface for MCP server connections.

__init__

def __init__(target: Target)

Initialize the OpenAI MCP server adapter.

Arguments:

  • target: The MCP target to adapt

connect

async def connect() -> None

Connect to the server.

This might involve spawning a subprocess or opening a network connection. The server is expected to remain connected until cleanup() is called.

name

@property
def name() -> str

Get a readable name for the server.

Returns:

The server name

cleanup

async def cleanup() -> None

Cleanup the server.

This might involve closing a subprocess or closing a network connection.

list_tools

async def list_tools() -> list[Tool]

List the tools available on the server.

Returns:

List of available MCP tools

call_tool

async def call_tool(tool_name: str,
arguments: dict[str, Any] | None) -> CallToolResult

Invoke a tool on the server.

Arguments:

  • tool_name: Name of the tool to invoke
  • arguments: Arguments to pass to the tool

Returns:

Result of the tool call with error handling