# `ExUtcp.Client`
[🔗](https://github.com/universal-tool-calling-protocol/elixir-utcp/blob/main/lib/ex_utcp/client.ex#L1)

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.

# `call_tool`

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

Calls a specific tool with the given arguments.

# `call_tool_stream`

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

Calls a tool with streaming support.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `convert_multiple_openapi`

```elixir
@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`

```elixir
@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`

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

Deregisters a tool provider.

# `find_similar_tools`

```elixir
@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`

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

Gets the client configuration.

# `get_health_status`

```elixir
@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`

```elixir
@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`

```elixir
@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`

```elixir
@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`

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

Gets repository statistics.

# `get_transports`

```elixir
@spec get_transports(GenServer.server()) :: %{required(String.t()) =&gt; module()}
```

Gets all available transports.

# `register_tool_provider`

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

Registers a tool provider and returns the discovered tools.

# `search_providers`

```elixir
@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`

```elixir
@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`

```elixir
@spec start_link(ExUtcp.Types.client_config()) :: GenServer.on_start()
```

Starts a new UTCP client with the given configuration.

# `start_link`

```elixir
@spec start_link(ExUtcp.Types.client_config(), GenServer.name()) ::
  GenServer.on_start()
```

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

# `validate_openapi`

```elixir
@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.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
