ExMCP.Client.DefaultHandler (ex_mcp v0.9.0)

View Source

This module provides ExMCP extensions beyond the standard MCP specification.

Default implementation of the ExMCP.Client.Handler behaviour.

This handler provides a basic implementation that can be extended or replaced by applications. It includes support for human-in-the-loop approval through the ExMCP.Approval behaviour.

Options

  • :approval_handler - Module implementing ExMCP.Approval behaviour (required for createMessage)
  • :roots - List of root directories to expose (default: current directory)
  • :model_selector - Function to select which model to use for sampling

Example

# Start a client with the default handler
{:ok, client} = ExMCP.Client.start_link(
  transport: {:stdio, "my-server"},
  handler: {ExMCP.Client.DefaultHandler, [
    approval_handler: MyApprovalHandler,
    roots: [%{uri: "file:///home/user", name: "Home"}]
  ]}
)