modelcontextprotocol / modelcontextprotocol/java-sdk
set loggingConsumer after client initialization
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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