Class: ElevenlabsClient::Endpoints::AgentsPlatform::McpServers

Inherits:
Object
  • Object
show all
Defined in:
lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb

Overview

MCP Servers endpoint - refactored for better maintainability

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ McpServers

Returns a new instance of McpServers.



8
9
10
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 8

def initialize(client)
  @client = client
end

Instance Method Details

#create(config:) ⇒ Hash

POST /v1/convai/mcp-servers Create a new MCP server configuration in the workspace Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/create

Parameters:

  • config (Hash)

    Configuration details for the MCP Server (required)

Options Hash (config:):

  • :url (String)

    MCP server URL

  • :name (String)

    MCP server name

  • :approval_policy (String)

    Approval policy ("auto_approve_all", "require_approval_all", "require_approval_per_tool")

  • :tool_approval_hashes (Array)

    Tool approval configurations

  • :transport (String)

    Transport method (default: "SSE")

  • :secret_token (Hash)

    Secret token configuration

  • :request_headers (Hash)

    Request headers

  • :description (String)

    MCP server description

Returns:

  • (Hash)

    JSON response containing created MCP server details

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 26

def create(config:)
  validate_required!(:config, config)
  raise ArgumentError, "config cannot be empty" if config.empty?

  body = { config: config }

  @client.post("/v1/convai/mcp-servers", body)
end

#create_tool_approval(mcp_server_id, tool_name:, tool_description:, **options) ⇒ Hash Also known as: approve_tool

POST /v1/convai/mcp-servers/:mcp_server_id/tool-approvals Add approval for a specific MCP tool when using per-tool approval mode Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/create-tool-approval

Parameters:

  • mcp_server_id (String)

    ID of the MCP Server (required)

  • tool_name (String)

    The name of the MCP tool (required)

  • tool_description (String)

    The description of the MCP tool (required)

  • options (Hash)

    Optional parameters

Options Hash (**options):

  • :input_schema (Hash)

    The input schema of the MCP tool

  • :approval_policy (String)

    Tool-level approval policy ("auto_approved", "requires_approval")

Returns:

  • (Hash)

    JSON response containing updated MCP server details



91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 91

def create_tool_approval(mcp_server_id, tool_name:, tool_description:, **options)
  validate_required!(:mcp_server_id, mcp_server_id)
  validate_required!(:tool_name, tool_name)
  validate_required!(:tool_description, tool_description)

  body = {
    tool_name: tool_name,
    tool_description: tool_description
  }.merge(options.compact)

  @client.post("/v1/convai/mcp-servers/#{mcp_server_id}/tool-approvals", body)
end

#delete_tool_approval(mcp_server_id, tool_name) ⇒ Hash Also known as: remove_tool_approval

DELETE /v1/convai/mcp-servers/:mcp_server_id/tool-approvals/:tool_name Remove approval for a specific MCP tool when using per-tool approval mode Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/delete-tool-approval

Parameters:

  • mcp_server_id (String)

    ID of the MCP Server (required)

  • tool_name (String)

    Name of the MCP tool to remove approval for (required)

Returns:

  • (Hash)

    JSON response containing updated MCP server details



111
112
113
114
115
116
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 111

def delete_tool_approval(mcp_server_id, tool_name)
  validate_required!(:mcp_server_id, mcp_server_id)
  validate_required!(:tool_name, tool_name)

  @client.delete("/v1/convai/mcp-servers/#{mcp_server_id}/tool-approvals/#{tool_name}")
end

#get(mcp_server_id) ⇒ Hash Also known as: get_server

GET /v1/convai/mcp-servers/:mcp_server_id Retrieve a specific MCP server configuration from the workspace Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/get

Parameters:

  • mcp_server_id (String)

    ID of the MCP Server (required)

Returns:

  • (Hash)

    JSON response containing MCP server details



50
51
52
53
54
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 50

def get(mcp_server_id)
  validate_required!(:mcp_server_id, mcp_server_id)

  @client.get("/v1/convai/mcp-servers/#{mcp_server_id}")
end

#listHash Also known as: servers

GET /v1/convai/mcp-servers Retrieve all MCP server configurations available in the workspace Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/list

Returns:

  • (Hash)

    JSON response containing list of MCP servers



40
41
42
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 40

def list
  @client.get("/v1/convai/mcp-servers")
end

#update_approval_policy(mcp_server_id, approval_policy:) ⇒ Hash Also known as: update_policy

PATCH /v1/convai/mcp-servers/:mcp_server_id/approval-policy Update the approval policy configuration for an MCP server Documentation: https://elevenlabs.io/docs/api-reference/convai/mcp-servers/update-approval-policy

Parameters:

  • mcp_server_id (String)

    ID of the MCP Server (required)

  • approval_policy (String)

    The approval mode to set for the MCP server (required)

    • "auto_approve_all": Automatically approve all tools
    • "require_approval_all": Require approval for all tools
    • "require_approval_per_tool": Require approval per individual tool

Returns:

  • (Hash)

    JSON response containing updated MCP server details



66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/elevenlabs_client/endpoints/agents_platform/mcp_servers.rb', line 66

def update_approval_policy(mcp_server_id, approval_policy:)
  validate_required!(:mcp_server_id, mcp_server_id)
  validate_required!(:approval_policy, approval_policy)

  valid_policies = %w[auto_approve_all require_approval_all require_approval_per_tool]
  unless valid_policies.include?(approval_policy.to_s)
    raise ArgumentError, "approval_policy must be one of: #{valid_policies.join(', ')}"
  end

  body = { approval_policy: approval_policy }

  @client.patch("/v1/convai/mcp-servers/#{mcp_server_id}/approval-policy", body)
end