ExUtcp.Client (ex_utcp v0.3.2)

Copy Markdown View Source

Main UTCP client implementation.

This module provides the primary interface for interacting with UTCP providers and tools. It manages provider registration, tool discovery, and tool execution.

Summary

Functions

Calls a specific tool with the given arguments.

Calls a tool with streaming support.

Returns a specification to start this module under a supervisor.

Converts multiple OpenAPI specifications to UTCP tools and registers them.

Converts an OpenAPI specification to UTCP tools and registers them.

Finds similar tools based on a reference tool.

Gets the client configuration.

Gets health status for the client and its components.

Gets monitoring metrics for the client.

Gets performance summary for client operations.

Gets search suggestions based on partial query.

Gets repository statistics.

Gets all available transports.

Registers a tool provider and returns the discovered tools.

Searches for providers using advanced search algorithms.

Searches for tools using advanced search algorithms.

Starts a new UTCP client with the given configuration.

Starts a new UTCP client with the given configuration and name.

Validates an OpenAPI specification.

Functions

call_tool(client, tool_name, args \\ %{})

@spec call_tool(GenServer.server(), String.t(), map()) :: ExUtcp.Types.call_result()

Calls a specific tool with the given arguments.

call_tool_stream(client, tool_name, args \\ %{})

@spec call_tool_stream(GenServer.server(), String.t(), map()) ::
  {:ok, ExUtcp.Types.stream_result()} | {:error, any()}

Calls a tool with streaming support.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

convert_multiple_openapi(client, specs, opts \\ [])

@spec convert_multiple_openapi(GenServer.server(), list(), keyword()) ::
  ExUtcp.Types.register_result()

Converts multiple OpenAPI specifications to UTCP tools and registers them.

Parameters

  • client: UTCP client
  • specs: List of OpenAPI specifications
  • opts: Conversion options

Returns

{:ok, tools} on success, {:error, reason} on failure.

convert_openapi(client, spec, opts \\ [])

@spec convert_openapi(GenServer.server(), map() | String.t(), keyword()) ::
  ExUtcp.Types.register_result()

Converts an OpenAPI specification to UTCP tools and registers them.

Parameters

  • client: UTCP client
  • spec: OpenAPI specification (map, URL, or file path)
  • opts: Conversion options

Returns

{:ok, tools} on success, {:error, reason} on failure.

deregister_tool_provider(client, provider_name)

@spec deregister_tool_provider(GenServer.server(), String.t()) ::
  ExUtcp.Types.deregister_result()

Deregisters a tool provider.

find_similar_tools(client, tool_name, opts \\ [])

@spec find_similar_tools(GenServer.server(), String.t(), keyword()) :: [map()]

Finds similar tools based on a reference tool.

Parameters

  • client: UTCP client
  • tool_name: Name of the reference tool
  • opts: Similarity search options

Returns

List of similar tools with similarity scores.

get_config(client)

@spec get_config(GenServer.server()) :: ExUtcp.Types.client_config()

Gets the client configuration.

get_health_status(client)

@spec get_health_status(GenServer.server()) :: map()

Gets health status for the client and its components.

Parameters

  • client: UTCP client

Returns

Map containing health status information.

get_monitoring_metrics(client)

@spec get_monitoring_metrics(GenServer.server()) :: map()

Gets monitoring metrics for the client.

Parameters

  • client: UTCP client

Returns

Map containing current metrics and performance data.

get_performance_summary(client)

@spec get_performance_summary(GenServer.server()) :: map()

Gets performance summary for client operations.

Parameters

  • client: UTCP client

Returns

Map containing performance statistics and alerts.

get_search_suggestions(client, partial_query, opts \\ [])

@spec get_search_suggestions(GenServer.server(), String.t(), keyword()) :: [
  String.t()
]

Gets search suggestions based on partial query.

Parameters

  • client: UTCP client
  • partial_query: Partial search query
  • opts: Suggestion options

Returns

List of suggested search terms.

get_stats(client)

@spec get_stats(GenServer.server()) :: map()

Gets repository statistics.

get_transports(client)

@spec get_transports(GenServer.server()) :: %{required(String.t()) => module()}

Gets all available transports.

register_tool_provider(client, provider)

@spec register_tool_provider(GenServer.server(), ExUtcp.Types.provider()) ::
  ExUtcp.Types.register_result()

Registers a tool provider and returns the discovered tools.

search_providers(client, query, opts \\ %{})

@spec search_providers(GenServer.server(), String.t(), map()) :: [map()]

Searches for providers using advanced search algorithms.

Parameters

  • client: UTCP client
  • query: Search query string
  • opts: Search options

Returns

List of search results with providers, scores, and match information.

search_tools(client, query, opts \\ %{})

@spec search_tools(GenServer.server(), String.t(), map()) :: [map()]

Searches for tools using advanced search algorithms.

Parameters

  • client: UTCP client
  • query: Search query string
  • opts: Search options including algorithm, filters, and limits

Options

  • :algorithm - Search algorithm (:exact, :fuzzy, :semantic, :combined)
  • :filters - Map with provider, transport, and tag filters
  • :limit - Maximum number of results (default: 20)
  • :threshold - Minimum similarity threshold (default: 0.1)
  • :security_scan - Enable security scanning (default: false)
  • :filter_sensitive - Filter out tools with sensitive data (default: false)

Returns

List of search results with tools, scores, and match information.

start_link(config)

Starts a new UTCP client with the given configuration.

start_link(config, name)

Starts a new UTCP client with the given configuration and name.

validate_openapi(client, spec)

@spec validate_openapi(GenServer.server(), map()) :: {:ok, map()} | {:error, term()}

Validates an OpenAPI specification.

Parameters

  • client: UTCP client
  • spec: OpenAPI specification

Returns

{:ok, validation_result} on success, {:error, reason} on failure.