Function

call-tool

Execute a tool call

This function is called when a client invokes a tool. The component should:

  1. Check if the tool name matches one of its tools
  2. If yes, execute the tool and return Some(result)
  3. If no, return None to indicate this capability doesn't handle this tool

Returning None allows the middleware to delegate the call to the next capability in the pipeline. This enables automatic composition of multiple tool providers without manual routing logic.

The middleware handles all error cases:

  • Tool not found (when all capabilities return None)
  • Invalid arguments (component returns error in result)
  • Execution failures (component returns error in result)

https://spec.modelcontextprotocol.io/specification/server/tools#tools-call

call-tool: func(request: call-tool-request, client: client-context) -> option​<call-tool-result>;