feat(mcp): Add MCP logging support and refactor code
- Add logging consumer to MCP client specification - Implement logging notifications for sampling start/finish in WeatherService - Refactor WeatherService to use McpToolUtils and StringBuilder Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com>
This commit is contained in:
@@ -68,6 +68,11 @@ public class McpClientApplication {
|
||||
McpSyncClientCustomizer samplingCustomizer(Map<String, ChatClient> chatClients) {
|
||||
|
||||
return (name, mcpClientSpec) -> {
|
||||
|
||||
mcpClientSpec = mcpClientSpec.loggingConsumer(logingMessage -> {
|
||||
System.out.println("MCP LOGGING: [" + logingMessage.level() + "] " + logingMessage.data());
|
||||
});
|
||||
|
||||
mcpClientSpec.sampling(llmRequest -> {
|
||||
var userPrompt = ((McpSchema.TextContent) llmRequest.messages().get(0).content()).text();
|
||||
String modelHint = llmRequest.modelPreferences().hints().get(0).name();
|
||||
|
||||
Reference in New Issue
Block a user