Skip to content

set loggingConsumer after client initialization #938

@haifengl

Description

@haifengl

Expected Behavior

We should be able to set a loggingConsumer on McpClient after querying its capabilities.

var capabilities = client.getServerCapabilities();
if (capabilities.logging() != null) {
    client.setLoggingLevel(McpSchema.LoggingLevel.INFO);
    client.setLoggingConsumer(consumer);
}

Current Behavior

Currently, we can set a loggingConsumer with McpClientTransport before client initialization. For example,

McpClient.sync(server.transport())
                .loggingConsumer(consumer)
                .build();

Context

However, many MCP servers' logging capabilities are not enabled. But we cannot query if the server has this capability before client initialization. Such a poor design makes it impossible to register a logging consumer safely.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions