ExMCP.Client.Operations.Tools (ex_mcp v0.9.2)

View Source

Tool operations for ExMCP client.

This module handles all tool-related operations including listing available tools, calling specific tools, and finding tools by name or pattern.

Summary

Functions

Lists all available tools from the MCP server.

Functions

call_tool(client, tool_name, arguments, timeout_or_opts \\ 30000)

Calls a tool on the MCP server.

Options

  • :timeout - Request timeout (default: 30000)
  • :format - Response format (default: :map)

Examples

ExMCP.Client.Operations.Tools.call_tool(client, "my_tool", %{arg1: "value"})
ExMCP.Client.Operations.Tools.call_tool(client, "my_tool", %{arg1: "value"}, timeout: 60_000)

find_tool(client, name_or_pattern \\ nil, opts \\ [])

@spec find_tool(
  ExMCP.Client.Types.client(),
  String.t() | nil,
  ExMCP.Client.Types.request_opts()
) ::
  {:ok, map()} | {:error, :tool_not_found | any()}

Finds a tool by name or pattern.

If name_or_pattern is nil, it returns the first tool from the list.

Options

  • :fuzzy - If true, performs a fuzzy search (default: false)
  • :timeout - Request timeout (default: 5000)
  • :format - Response format (default: :map)

Examples

{:ok, tool} = ExMCP.Client.Operations.Tools.find_tool(client, "my_tool")
{:ok, tool} = ExMCP.Client.Operations.Tools.find_tool(client, "tool", fuzzy: true)

list_tools(client, opts \\ [])

Lists all available tools from the MCP server.

Options

  • :timeout - Request timeout (default: 5000)
  • :format - Response format (default: :map)

Examples

{:ok, tools} = ExMCP.Client.Operations.Tools.list_tools(client)
{:ok, tools} = ExMCP.Client.Operations.Tools.list_tools(client, timeout: 10_000)

tools(client, opts \\ [])

Alias for list_tools/2.