ExUtcp.Client (ex_utcp v0.2.8)

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.

Gets the client configuration.

Gets repository statistics.

Gets all available transports.

Registers a tool provider and returns the discovered tools.

Searches for tools matching the given query.

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.

get_config(client)

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

Gets the client configuration.

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_tools(client, query \\ "", limit \\ 10)

@spec search_tools(GenServer.server(), String.t(), integer()) ::
  ExUtcp.Types.search_result()

Searches for tools matching the given query.

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.