Claudio.MCP.Client behaviour (Claudio v0.5.0)
View SourceBehaviour for MCP client adapters.
Defines a common interface that abstracts over different Elixir MCP client libraries (hermes_mcp, ex_mcp, mcp_ex, or custom implementations).
Implementing an adapter
defmodule MyApp.MCPAdapter do
@behaviour Claudio.MCP.Client
@impl true
def list_tools(client, opts \\ []) do
# Call your MCP library and normalize the response
{:ok, [%Claudio.MCP.Client.Tool{name: "search", ...}]}
end
# ... implement other callbacks
endNormalized types
All adapters return the same normalized types regardless of the underlying
library. This ensures that Claudio.MCP.ToolAdapter and
Claudio.MCP.ResultMapper work consistently across implementations.
Summary
Callbacks
Execute a tool on the MCP server.
Get a prompt by name with optional arguments.
List available prompts from the MCP server.
List available resources from the MCP server.
List available tools from the MCP server.
Ping the MCP server to check connectivity.
Read a resource by URI from the MCP server.
Types
@type prompt() :: Claudio.MCP.Client.Prompt.t()
@type resource() :: Claudio.MCP.Client.Resource.t()
@type tool() :: Claudio.MCP.Client.Tool.t()
Callbacks
@callback call_tool( client :: term(), name :: String.t(), args :: map(), opts :: keyword() ) :: {:ok, term()} | {:error, term()}
Execute a tool on the MCP server.
@callback get_prompt( client :: term(), name :: String.t(), args :: map(), opts :: keyword() ) :: {:ok, term()} | {:error, term()}
Get a prompt by name with optional arguments.
List available prompts from the MCP server.
@callback list_resources(client :: term(), opts :: keyword()) :: {:ok, [resource()]} | {:error, term()}
List available resources from the MCP server.
List available tools from the MCP server.
Ping the MCP server to check connectivity.
@callback read_resource(client :: term(), uri :: String.t(), opts :: keyword()) :: {:ok, term()} | {:error, term()}
Read a resource by URI from the MCP server.