openai_hosted_mcp_tool: OpenAI hosted MCP tool

View source: R/openai_tools.R

openai_hosted_mcp_toolR Documentation

OpenAI hosted MCP tool

Description

Give the model access to a remote MCP server, executed server-side by OpenAI. This is independent of aisdk's local MCP client (R/mcp_client.R) — that one connects from R, this one tells OpenAI to connect on the model's behalf.

Usage

openai_hosted_mcp_tool(
  server_label,
  server_url = NULL,
  connector_id = NULL,
  server_description = NULL,
  allowed_tools = NULL,
  require_approval = NULL,
  authorization = NULL,
  headers = NULL
)

Arguments

server_label

Required label used to identify the server in tool calls.

server_url

URL of a custom MCP server. Exactly one of server_url or connector_id is required.

connector_id

OpenAI-managed connector ID (e.g. "connector_gmail").

server_description

Optional human-readable description.

allowed_tools

Optional character vector of tool names to expose, or a list filter (e.g. list(read_only = TRUE)).

require_approval

"always", "never", or a list filter (e.g. list(always = list(tool_names = c("send_email")))).

authorization

Optional OAuth access token.

headers

Optional named list of HTTP headers sent to the MCP server.

Value

A plain list ready to drop into tools = list(...).

Examples

## Not run: 
generate_text(
  model,
  "Roll 2d4+1",
  tools = list(openai_hosted_mcp_tool(
    server_label = "dmcp",
    server_url = "https://dmcp-server.deno.dev/sse",
    allowed_tools = "roll",
    require_approval = "never"
  ))
)

## End(Not run)

aisdk documentation built on May 29, 2026, 9:07 a.m.