Class ToolListener
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
-
Field Summary
Fields inherited from class com.mulesoft.connectors.mcp.internal.server.source.AbstractRequestListener
messagingManager, serverConfig -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoStart(org.mule.sdk.api.runtime.source.SourceCallback<Map<String, Object>, RequestAttributes> sourceCallback) protected voiddoStop()voidonError(List<ToolResponseContent> onErrorResponses, org.mule.runtime.api.message.Error error, org.mule.sdk.api.runtime.source.SourceCallbackContext context) voidonSuccess(List<ToolResponseContent> responses, org.mule.sdk.api.runtime.source.SourceCallbackContext context) voidonTerminate(org.mule.sdk.api.runtime.source.SourceResult sourceResult) Methods inherited from class com.mulesoft.connectors.mcp.internal.server.source.AbstractRequestListener
getServer, getSink, onStart, onStop, setInContext
-
Constructor Details
-
ToolListener
public ToolListener()
-
-
Method Details
-
doStart
protected void doStart(org.mule.sdk.api.runtime.source.SourceCallback<Map<String, Object>, throws org.mule.runtime.api.exception.MuleExceptionRequestAttributes> sourceCallback) - Specified by:
doStartin classAbstractRequestListener<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 successfullycontext- 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 errorerror- the raised errorcontext- the callback context
-
onTerminate
@OnTerminate public void onTerminate(org.mule.sdk.api.runtime.source.SourceResult sourceResult) -
doStop
protected void doStop()- Specified by:
doStopin classAbstractRequestListener<Map<String,Object>, RequestAttributes>
-