java.lang.Object
org.mule.sdk.api.runtime.source.Source<T,A>
com.mulesoft.connectors.mcp.internal.server.source.AbstractRequestListener<Map<String,Object>,RequestAttributes>
com.mulesoft.connectors.mcp.internal.server.source.tool.ToolListener

@DisplayName("MCP Server - Tool Listener") @EmitsResponse @MetadataScope(outputResolver=ToolListenerOutputResolver.class) public class ToolListener extends AbstractRequestListener<Map<String,Object>,RequestAttributes>
Exposes a tool which result is generated by the execution of the owning flow.

The flow will be executed for every received tools/call request.

When triggered, the flow will be executed with a message which payload is a Java map holding the input arguments. The tool response is generated when the flow finishes either successfully or with error. In both cases, the response can include several content items of different types. If no error response is defined, then a text content item holding the error's description will be generated automatically

Since:
0.1.0
  • Constructor Details

    • ToolListener

      public ToolListener()
  • Method Details

    • doStart

      protected void doStart(org.mule.sdk.api.runtime.source.SourceCallback<Map<String,Object>,RequestAttributes> sourceCallback) throws org.mule.runtime.api.exception.MuleException
      Specified by:
      doStart in class AbstractRequestListener<Map<String,Object>,RequestAttributes>
      Throws:
      org.mule.runtime.api.exception.MuleException
    • onSuccess

      @OnSuccess public void onSuccess(@Expression(NOT_SUPPORTED) @ParameterDsl(allowReferences=false) List<ToolResponseContent> responses, org.mule.sdk.api.runtime.source.SourceCallbackContext context)
      Parameters:
      responses - The response items when the flow finishes successfully
      context - the callback context
    • onError

      @OnError public void onError(@Expression(NOT_SUPPORTED) @ParameterDsl(allowReferences=false) @Optional List<ToolResponseContent> onErrorResponses, org.mule.runtime.api.message.Error error, org.mule.sdk.api.runtime.source.SourceCallbackContext context)
      Parameters:
      onErrorResponses - the content items when the flow finishes in error
      error - the raised error
      context - the callback context
    • onTerminate

      @OnTerminate public void onTerminate(org.mule.sdk.api.runtime.source.SourceResult sourceResult)
    • doStop

      protected void doStop()
      Specified by:
      doStop in class AbstractRequestListener<Map<String,Object>,RequestAttributes>