Hermes.Server.Handlers.Tools (hermes_mcp v0.10.0)

Handles MCP protocol tool-related methods.

This module processes:

  • tools/list - Lists available tools with optional pagination
  • tools/call - Executes a specific tool with given arguments

Pagination Support

The tools/list method supports pagination through cursor parameters:

# Request
%{"method" => "tools/list", "params" => %{"cursor" => "optional-cursor"}}

# Response with more results
%{
  "tools" => [...],
  "nextCursor" => "next-page-cursor"
}

# Response for last page
%{"tools" => [...]}

Summary

Functions

Handles the tools/call request to execute a specific tool.

Handles the tools/list request with optional pagination.

Functions

handle_call(map, frame, server_module)

@spec handle_call(map(), Hermes.Server.Frame.t(), module()) ::
  {:reply, map(), Hermes.Server.Frame.t()}
  | {:error, Hermes.MCP.Error.t(), Hermes.Server.Frame.t()}

Handles the tools/call request to execute a specific tool.

Parameters

  • request - The MCP request containing tool name and arguments
  • frame - The server frame
  • server_module - The server module implementing tool components

Returns

  • {:reply, result, frame} - Tool execution result
  • {:error, error, frame} - If tool not found or execution fails

handle_list(frame, server_module)

@spec handle_list(Hermes.Server.Frame.t(), module()) ::
  {:reply, map(), Hermes.Server.Frame.t()}
  | {:error, Hermes.MCP.Error.t(), Hermes.Server.Frame.t()}

Handles the tools/list request with optional pagination.

Parameters

  • request - The MCP request containing optional cursor in params
  • frame - The server frame
  • server_module - The server module implementing tool components

Returns

  • {:reply, result, frame} - List of tools with optional nextCursor
  • {:error, error, frame} - If pagination cursor is invalid