modelcontextprotocol / modelcontextprotocol/java-sdk

set loggingConsumer after client initialization

Open
#938 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

waiting for triage
Dominant language
Java
Stars
3.7k
Forks
1.1k
Avg merge
1d 15h
Merged PRs (30d)
9

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading McpClient initialization and capability-query flow, then compare it with McpClientTransport's loggingConsumer configuration. Verify how setLoggingLevel and setLoggingConsumer behave before initialization. Done means a consumer can be registered after getServerCapabilities() confirms logging support, without breaking the existing pre-initialization builder usage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.