Interface McpClientListener
public interface McpClientListener
Listener interface for monitoring MCP client operations.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidafterExecuteTool(McpCallContext context, ToolExecutionResult result, Map<String, Object> rawResult) Called after executing a tool if the execution was successful, or if it resulted in an application-level error (but not a protocol-level or communication error).default voidafterInitialize(McpCallContext context) Called after the initialize request completes successfully.default voidafterPing(McpCallContext context) Called after the ping request completes successfully (the server has responded with a pong).default voidafterPromptGet(McpCallContext context, McpGetPromptResult result, Map<String, Object> rawResult) Called after getting a prompt.default voidafterPromptsList(McpCallContext context, List<McpPrompt> prompts) Called after listing prompts from the MCP server completes successfully.default voidafterResourceGet(McpCallContext context, McpReadResourceResult result, Map<String, Object> rawResult) Called after getting a resource.default voidafterResourcesList(McpCallContext context, List<McpResource> resources) Called after listing resources from the MCP server completes successfully.default voidafterResourceSubscribe(McpCallContext context) Called after subscribing to a resource completes successfully.default voidafterResourceTemplatesList(McpCallContext context, List<McpResourceTemplate> templates) Called after listing resource templates from the MCP server completes successfully.default voidafterResourceUnsubscribe(McpCallContext context) Called after unsubscribing from a resource completes successfully.default voidafterToolsList(McpCallContext context, List<ToolSpecification> tools) Called after listing tools from the MCP server completes successfully.default voidbeforeExecuteTool(McpCallContext context) Called before executing a tool.default voidbeforeInitialize(McpCallContext context) Called before sending the initialize request to the MCP server.default voidbeforePing(McpCallContext context) Called before sending a ping request to the MCP server.default voidbeforePromptGet(McpCallContext context) Called before getting a prompt.default voidbeforePromptsList(McpCallContext context) Called before listing prompts from the MCP server.default voidbeforeResourceGet(McpCallContext context) Called before getting a resource.default voidbeforeResourcesList(McpCallContext context) Called before listing resources from the MCP server.default voidbeforeResourceSubscribe(McpCallContext context) Called before subscribing to a resource.default voidCalled before listing resource templates from the MCP server.default voidbeforeResourceUnsubscribe(McpCallContext context) Called before unsubscribing from a resource.default voidbeforeToolsList(McpCallContext context) Called before listing tools from the MCP server.default voidonExecuteToolError(McpCallContext context, Throwable error) Called when a tool execution fails due to a protocol-level or communication error.default voidonInitializeError(McpCallContext context, Throwable error) Called when the initialize request fails.default voidonNotificationMessage(McpLogMessage message) Called when the server sends anotifications/message(log message) notification.default voidonNotificationProgress(McpProgressNotification notification) Called when the server sends anotifications/progressnotification.default voidCalled when the server sends anotifications/prompts/list_changednotification.default voidCalled when the server sends anotifications/resources/list_changednotification.default voidCalled when the server sends anotifications/resources/updatednotification.default voidCalled when the server sends anotifications/tools/list_changednotification.default voidonPingError(McpCallContext context, Throwable error) Called when the ping request fails (the server didn't send a pong in time or some transport-level issue occurred).default voidonPromptGetError(McpCallContext context, Throwable error) Called when getting a prompt fails.default voidonPromptsListError(McpCallContext context, Throwable error) Called when listing prompts from the MCP server fails.default voidonResourceGetError(McpCallContext context, Throwable error) Called when getting a resource fails.default voidonResourcesListError(McpCallContext context, Throwable error) Called when listing resources from the MCP server fails.default voidonResourceSubscribeError(McpCallContext context, Throwable error) Called when subscribing to a resource fails.default voidonResourceTemplatesListError(McpCallContext context, Throwable error) Called when listing resource templates from the MCP server fails.default voidonResourceUnsubscribeError(McpCallContext context, Throwable error) Called when unsubscribing from a resource fails.default voidonRootsListChanged(McpCallContext context) Called after the client sends anotifications/roots/list_changednotification to the server.default voidCalled when the server sends apingrequest and the client responds.default voidCalled when the server sends aroots/listrequest and the client responds.default voidonToolsListError(McpCallContext context, Throwable error) Called when listing tools from the MCP server fails.
-
Method Details
-
beforeInitialize
Called before sending the initialize request to the MCP server. -
afterInitialize
Called after the initialize request completes successfully. -
onInitializeError
Called when the initialize request fails. -
beforeExecuteTool
Called before executing a tool. -
afterExecuteTool
default void afterExecuteTool(McpCallContext context, ToolExecutionResult result, Map<String, Object> rawResult) Called after executing a tool if the execution was successful, or if it resulted in an application-level error (but not a protocol-level or communication error). -
onExecuteToolError
Called when a tool execution fails due to a protocol-level or communication error. -
beforeToolsList
Called before listing tools from the MCP server. -
afterToolsList
Called after listing tools from the MCP server completes successfully. -
onToolsListError
Called when listing tools from the MCP server fails. -
beforeResourceGet
Called before getting a resource. -
afterResourceGet
default void afterResourceGet(McpCallContext context, McpReadResourceResult result, Map<String, Object> rawResult) Called after getting a resource. -
onResourceGetError
Called when getting a resource fails. -
beforeResourcesList
Called before listing resources from the MCP server. -
afterResourcesList
Called after listing resources from the MCP server completes successfully. -
onResourcesListError
Called when listing resources from the MCP server fails. -
beforeResourceTemplatesList
Called before listing resource templates from the MCP server. -
afterResourceTemplatesList
default void afterResourceTemplatesList(McpCallContext context, List<McpResourceTemplate> templates) Called after listing resource templates from the MCP server completes successfully. -
onResourceTemplatesListError
Called when listing resource templates from the MCP server fails. -
beforeResourceSubscribe
Called before subscribing to a resource. -
afterResourceSubscribe
Called after subscribing to a resource completes successfully. -
onResourceSubscribeError
Called when subscribing to a resource fails. -
beforeResourceUnsubscribe
Called before unsubscribing from a resource. -
afterResourceUnsubscribe
Called after unsubscribing from a resource completes successfully. -
onResourceUnsubscribeError
Called when unsubscribing from a resource fails. -
beforePromptGet
Called before getting a prompt. -
afterPromptGet
default void afterPromptGet(McpCallContext context, McpGetPromptResult result, Map<String, Object> rawResult) Called after getting a prompt. -
onPromptGetError
Called when getting a prompt fails. -
beforePromptsList
Called before listing prompts from the MCP server. -
afterPromptsList
Called after listing prompts from the MCP server completes successfully. -
onPromptsListError
Called when listing prompts from the MCP server fails. -
beforePing
Called before sending a ping request to the MCP server. -
afterPing
Called after the ping request completes successfully (the server has responded with a pong). -
onPingError
Called when the ping request fails (the server didn't send a pong in time or some transport-level issue occurred). -
onRootsListChanged
Called after the client sends anotifications/roots/list_changednotification to the server. -
onNotificationToolsListChanged
default void onNotificationToolsListChanged()Called when the server sends anotifications/tools/list_changednotification. -
onNotificationResourcesListChanged
default void onNotificationResourcesListChanged()Called when the server sends anotifications/resources/list_changednotification. -
onNotificationPromptsListChanged
default void onNotificationPromptsListChanged()Called when the server sends anotifications/prompts/list_changednotification. -
onNotificationResourceUpdated
Called when the server sends anotifications/resources/updatednotification. -
onNotificationMessage
Called when the server sends anotifications/message(log message) notification. -
onNotificationProgress
Called when the server sends anotifications/progressnotification. -
onServerPing
default void onServerPing()Called when the server sends apingrequest and the client responds. -
onServerRootsList
default void onServerRootsList()Called when the server sends aroots/listrequest and the client responds.
-