/*
* OpenAI API
*
* The OpenAI REST API. Please see https://platform.openai.com/docs/api-reference for more details.
*
* The version of the OpenAPI document: 2.3.0
*
* Generated by: https://openapi-generator.tech
*/
use crate::models;
use serde::{Deserialize, Serialize};
/// McpTool : Give the model access to additional tools via remote Model Context Protocol (MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct McpTool {
/// The type of the MCP tool. Always `mcp`.
#[serde(rename = "type")]
pub r#type: Type,
/// A label for this MCP server, used to identify it in tool calls.
#[serde(rename = "server_label")]
pub server_label: String,
/// The URL for the MCP server. One of `server_url` or `connector_id` must be provided.
#[serde(rename = "server_url", skip_serializing_if = "Option::is_none")]
pub server_url: Option<String>,
/// Identifier for service connectors, like those available in ChatGPT. One of `server_url` or `connector_id` must be provided. Learn more about service connectors [here](/docs/guides/tools-remote-mcp#connectors). Currently supported `connector_id` values are: - Dropbox: `connector_dropbox` - Gmail: `connector_gmail` - Google Calendar: `connector_googlecalendar` - Google Drive: `connector_googledrive` - Microsoft Teams: `connector_microsoftteams` - Outlook Calendar: `connector_outlookcalendar` - Outlook Email: `connector_outlookemail` - SharePoint: `connector_sharepoint`
#[serde(rename = "connector_id", skip_serializing_if = "Option::is_none")]
pub connector_id: Option<ConnectorId>,
/// An OAuth access token that can be used with a remote MCP server, either with a custom MCP server URL or a service connector. Your application must handle the OAuth authorization flow and provide the token here.
#[serde(rename = "authorization", skip_serializing_if = "Option::is_none")]
pub authorization: Option<String>,
/// Optional description of the MCP server, used to provide more context.
#[serde(rename = "server_description", skip_serializing_if = "Option::is_none")]
pub server_description: Option<String>,
/// Optional HTTP headers to send to the MCP server. Use for authentication or other purposes.
#[serde(
rename = "headers",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub headers: Option<Option<std::collections::HashMap<String, String>>>,
#[serde(
rename = "allowed_tools",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub allowed_tools: Option<Option<Box<models::McpToolAllowedTools>>>,
#[serde(
rename = "require_approval",
default,
with = "::serde_with::rust::double_option",
skip_serializing_if = "Option::is_none"
)]
pub require_approval: Option<Option<Box<models::McpToolRequireApproval>>>,
/// Whether this MCP tool is deferred and discovered via tool search.
#[serde(rename = "defer_loading", skip_serializing_if = "Option::is_none")]
pub defer_loading: Option<bool>,
}
impl McpTool {
/// Give the model access to additional tools via remote Model Context Protocol (MCP) servers. [Learn more about MCP](/docs/guides/tools-remote-mcp).
pub fn new(r#type: Type, server_label: String) -> McpTool {
McpTool {
r#type,
server_label,
server_url: None,
connector_id: None,
authorization: None,
server_description: None,
headers: None,
allowed_tools: None,
require_approval: None,
defer_loading: None,
}
}
}
/// The type of the MCP tool. Always `mcp`.
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum Type {
#[serde(rename = "mcp")]
Mcp,
}
impl Default for Type {
fn default() -> Type {
Self::Mcp
}
}
/// Identifier for service connectors, like those available in ChatGPT. One of `server_url` or `connector_id` must be provided. Learn more about service connectors [here](/docs/guides/tools-remote-mcp#connectors). Currently supported `connector_id` values are: - Dropbox: `connector_dropbox` - Gmail: `connector_gmail` - Google Calendar: `connector_googlecalendar` - Google Drive: `connector_googledrive` - Microsoft Teams: `connector_microsoftteams` - Outlook Calendar: `connector_outlookcalendar` - Outlook Email: `connector_outlookemail` - SharePoint: `connector_sharepoint`
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum ConnectorId {
#[serde(rename = "connector_dropbox")]
ConnectorDropbox,
#[serde(rename = "connector_gmail")]
ConnectorGmail,
#[serde(rename = "connector_googlecalendar")]
ConnectorGooglecalendar,
#[serde(rename = "connector_googledrive")]
ConnectorGoogledrive,
#[serde(rename = "connector_microsoftteams")]
ConnectorMicrosoftteams,
#[serde(rename = "connector_outlookcalendar")]
ConnectorOutlookcalendar,
#[serde(rename = "connector_outlookemail")]
ConnectorOutlookemail,
#[serde(rename = "connector_sharepoint")]
ConnectorSharepoint,
}
impl Default for ConnectorId {
fn default() -> ConnectorId {
Self::ConnectorDropbox
}
}
impl std::fmt::Display for McpTool {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}