Skip to main content

Overview

A built-in tool that allows models to connect to and use tools from MCP (Model Context Protocol) servers. This enables your agent to interact with external services, databases, and local applications that expose an MCP-compatible endpoint.

Usage

1. Using Public MCP Server (Anthropic)

Run this example as is to test connection to a public MCP server.

2. Using Public MCP Server (OpenAI)

Same example using OpenAI Responses model.

Parameters

  • id (str): Unique identifier for the MCP server
  • url (str): URL of the MCP server
    • For OpenAI connectors, use x-openai-connector:<connector_id>
  • authorization_token (str, optional): Authorization header value (e.g., Bearer <token>)
    • Supported by: OpenAI Responses, Anthropic
  • description (str, optional): Description of the MCP server’s capabilities
    • Supported by: OpenAI Responses
  • allowed_tools (List[str], optional): specific list of tools to enable from the server
    • Supported by: OpenAI Responses, Anthropic
  • headers (Dict[str, str], optional): Custom HTTP headers for the connection
    • Supported by: OpenAI Responses