File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
core/src/main/java/com/google/adk/tools/mcp Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 2424
2525class McpServerLogConsumer implements Consumer <LoggingMessageNotification > {
2626
27+ private static final Logger LOG = LoggerFactory .getLogger (McpServerLogConsumer .class );
28+
2729 @ Override
2830 public void accept (LoggingMessageNotification notif ) {
29- Logger log = LoggerFactory .getLogger (notif .logger ());
30- log .atLevel (convert (notif .level ())).log ("{}" , notif .data ());
31+ LOG .atLevel (convert (notif .level ())).log ("{}" , notif .data ());
3132 }
3233
3334 private Level convert (McpSchema .LoggingLevel level ) {
Original file line number Diff line number Diff line change 2020import io .modelcontextprotocol .client .McpClient ;
2121import io .modelcontextprotocol .client .McpSyncClient ;
2222import io .modelcontextprotocol .spec .McpClientTransport ;
23+ import io .modelcontextprotocol .spec .McpSchema ;
2324import io .modelcontextprotocol .spec .McpSchema .ClientCapabilities ;
2425import io .modelcontextprotocol .spec .McpSchema .InitializeResult ;
2526import java .time .Duration ;
2627import java .util .Optional ;
28+ import java .util .function .Function ;
2729import org .slf4j .Logger ;
2830import org .slf4j .LoggerFactory ;
31+ import reactor .core .publisher .Mono ;
2932
3033/**
3134 * Manages MCP client sessions.
@@ -113,6 +116,16 @@ public static McpAsyncClient initializeAsyncSession(
113116 initializationTimeout == null ? Duration .ofMinutes (5 ) : initializationTimeout )
114117 .requestTimeout (requestTimeout == null ? Duration .ofMinutes (5 ) : requestTimeout )
115118 .capabilities (ClientCapabilities .builder ().build ())
119+ .loggingConsumer (asyncMcpServerLogConsumer ())
116120 .build ();
117121 }
122+
123+ private static Function <McpSchema .LoggingMessageNotification , Mono <Void >>
124+ asyncMcpServerLogConsumer () {
125+ var syncConsumer = new McpServerLogConsumer ();
126+ return message -> {
127+ syncConsumer .accept (message );
128+ return Mono .empty ();
129+ };
130+ }
118131}
You can’t perform that action at this time.
0 commit comments