# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.unchecked_base_model import UncheckedBaseModel
from .mcp_approval_policy import McpApprovalPolicy
from .mcp_server_config_input_auth_connection import McpServerConfigInputAuthConnection
from .mcp_server_config_input_request_headers_value import McpServerConfigInputRequestHeadersValue
from .mcp_server_config_input_secret_token import McpServerConfigInputSecretToken
from .mcp_server_config_input_url import McpServerConfigInputUrl
from .mcp_server_transport import McpServerTransport
from .mcp_tool_approval_hash import McpToolApprovalHash
from .mcp_tool_config_override_input import McpToolConfigOverrideInput
from .pre_tool_speech_mode import PreToolSpeechMode
from .tool_call_sound_behavior import ToolCallSoundBehavior
from .tool_call_sound_type import ToolCallSoundType
from .tool_execution_mode import ToolExecutionMode
from .tool_interruption_mode import ToolInterruptionMode


class McpServerConfigInput(UncheckedBaseModel):
    approval_policy: typing.Optional[McpApprovalPolicy] = None
    tool_approval_hashes: typing.Optional[typing.List[McpToolApprovalHash]] = pydantic.Field(default=None)
    """
    List of tool approval hashes for per-tool approval when approval_policy is REQUIRE_APPROVAL_PER_TOOL
    """

    transport: typing.Optional[McpServerTransport] = pydantic.Field(default=None)
    """
    The transport type used to connect to the MCP server
    """

    url: McpServerConfigInputUrl = pydantic.Field()
    """
    The URL of the MCP server, if this contains a secret please store as a workspace secret, otherwise store as a plain string. Must use https
    """

    secret_token: typing.Optional[McpServerConfigInputSecretToken] = pydantic.Field(default=None)
    """
    The secret token (Authorization header) stored as a workspace secret or in-place secret
    """

    request_headers: typing.Optional[typing.Dict[str, McpServerConfigInputRequestHeadersValue]] = pydantic.Field(
        default=None
    )
    """
    The headers included in the request
    """

    auth_connection: typing.Optional[McpServerConfigInputAuthConnection] = pydantic.Field(default=None)
    """
    Optional auth connection to use for authentication with this MCP server
    """

    name: str
    description: typing.Optional[str] = None
    force_pre_tool_speech: typing.Optional[bool] = pydantic.Field(default=None)
    """
    DEPRECATED: use `pre_tool_speech` instead. If true, all tools from this MCP server will require pre-tool execution speech.
    """

    pre_tool_speech: typing.Optional[PreToolSpeechMode] = pydantic.Field(default=None)
    """
    Controls whether the agent speaks before this tool is called. 'auto' (default) decides based on recent tool latency, 'force' always asks the agent to speak, 'off' fully opts out regardless of latency. Applies to every tool from this MCP server unless overridden per tool.
    """

    disable_interruptions: typing.Optional[bool] = pydantic.Field(default=None)
    """
    DEPRECATED: use `interruption_mode` instead. If true, the user will not be able to interrupt the agent while any tool from this MCP server is running.
    """

    interruption_mode: typing.Optional[ToolInterruptionMode] = pydantic.Field(default=None)
    """
    Controls whether the user can interrupt the agent around this tool call. 'allow' (default) lets the user interrupt at any time, 'disable_during_tool' suppresses interruptions only while the tool is running, 'disable_during_tool_and_turn' suppresses interruptions while the tool runs and for the agent response that follows it. Applies to every tool from this MCP server unless overridden per tool.
    """

    tool_call_sound: typing.Optional[ToolCallSoundType] = pydantic.Field(default=None)
    """
    Predefined tool call sound type to play during tool execution for all tools from this MCP server
    """

    tool_call_sound_behavior: typing.Optional[ToolCallSoundBehavior] = pydantic.Field(default=None)
    """
    Determines when the tool call sound should play for all tools from this MCP server
    """

    execution_mode: typing.Optional[ToolExecutionMode] = pydantic.Field(default=None)
    """
    Determines when and how all tools from this MCP server execute: 'immediate' executes the tool right away when requested by the LLM, 'post_tool_speech' waits for the agent to finish speaking before executing, 'async' runs the tool in the background without blocking - best for long-running operations.
    """

    response_timeout_secs: typing.Optional[int] = pydantic.Field(default=None)
    """
    The maximum time in seconds to wait for each MCP tool call to complete. Must be between 5 and 300 seconds (inclusive).
    """

    tool_config_overrides: typing.Optional[typing.List[McpToolConfigOverrideInput]] = pydantic.Field(default=None)
    """
    List of per-tool configuration overrides that override the server-level defaults for specific tools
    """

    disable_compression: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether to disable HTTP compression for this MCP server. Enable this if the server does not support compressed responses.
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
