Annotation Interface McpLogging


@Target({METHOD,ANNOTATION_TYPE}) @Retention(RUNTIME) @Documented public @interface McpLogging
Annotation for methods that handle logging message notifications from MCP servers. This annotation is applicable only for MCP clients.

Methods annotated with this annotation can be used to consume logging messages from MCP servers. The methods can have one of two signatures:

  • A single parameter of type LoggingMessageNotification
  • Three parameters of types LoggingLevel, String (logger), and String (data)

For synchronous consumers, the method must have a void return type. For asynchronous consumers, the method can have either a void return type or return Mono<Void>.

Example usage:


 &#64;McpLogging
 public void handleLoggingMessage(LoggingMessageNotification notification) {
     // Handle the notification
 }



&#64;McpLogging
 public void handleLoggingMessageWithParams(LoggingLevel level, String logger, String data) {
     // Handle the logging message
 }
 
Author:
Christian Tzolov
See Also:
  • McpSchema.LoggingMessageNotification
  • McpSchema.LoggingLevel
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Used as connection or clients identifier to select the MCP clients, the logging consumer is associated with.
  • Element Details

    • clients

      String[] clients
      Used as connection or clients identifier to select the MCP clients, the logging consumer is associated with. At least one client identifier must be specified.