[3.3] Adapt MCP integration to sdk 0.18.2 APIs#16267
Conversation
Agent-Logs-Url: https://github.com/zrlw/dubbo/sessions/95ee4292-fa33-47c2-8947-6be0a474bb31 Co-authored-by: zrlw <40652892+zrlw@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16267 +/- ##
============================================
+ Coverage 60.78% 60.79% +0.01%
+ Complexity 11763 11762 -1
============================================
Files 1953 1953
Lines 89186 89181 -5
Branches 13454 13454
============================================
+ Hits 54209 54218 +9
+ Misses 29400 29386 -14
Partials 5577 5577
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adapts the Dubbo MCP integration to the Model Context Protocol SDK 0.18.2 API changes (JSON mapping, schema/tool representations).
Changes:
- Bumps MCP SDK dependency from
0.11.2to0.18.2. - Migrates transports to use
McpJsonMapper/TypeRefinstead of JacksonObjectMapper/TypeReference. - Updates tool/schema construction to use
McpSchema.Tool.builder()andMcpSchema.JsonSchema(and adjusts tests accordingly).
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| dubbo-plugin/dubbo-mcp/pom.xml | Bumps MCP SDK version to 0.18.2. |
| dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/core/McpApplicationDeployListener.java | Wires JacksonMcpJsonMapper into transport providers. |
| dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/transport/DubboMcpStreamableTransportProvider.java | Switches JSON handling to McpJsonMapper/TypeRef and updates init parsing. |
| dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/transport/DubboMcpSseTransportProvider.java | Switches JSON handling to McpJsonMapper/TypeRef. |
| dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/tool/DubboServiceToolRegistry.java | Builds tools via builder and returns JsonSchema objects instead of JSON strings. |
| dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/tool/DubboOpenApiToolConverter.java | Builds tools via builder and returns JsonSchema objects instead of JSON strings. |
| dubbo-plugin/dubbo-mcp/src/test/java/org/apache/dubbo/mcp/transport/DubboMcpStreamableTransportProviderTest.java | Updates tests to pass JacksonMcpJsonMapper. |
| dubbo-plugin/dubbo-mcp/src/test/java/org/apache/dubbo/mcp/transport/DubboMcpSseTransportProviderTest.java | Updates tests to pass JacksonMcpJsonMapper. |
| dubbo-plugin/dubbo-mcp/src/test/java/org/apache/dubbo/mcp/tool/DubboServiceToolRegistryTest.java | Updates tests to use Tool.builder() + JsonSchema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/transport/DubboMcpSseTransportProvider.java:80
- The public constructors now require
McpJsonMapper, which is a source/binary breaking change for any external code instantiating this transport provider. If backward compatibility is a goal for the 3.3 line, consider keeping an overload that accepts a JacksonObjectMapper(deprecated) and wraps it withJacksonMcpJsonMapperinternally.
public DubboMcpSseTransportProvider(McpJsonMapper mcpJsonMapper, Integer expireSeconds) {
if (expireSeconds != null) {
if (expireSeconds < 60) {
expireSeconds = 60;
}
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (2)
dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/transport/DubboMcpStreamableTransportProvider.java:562
- In this sendMessage(...) implementation you guard responseObserver for onNext, but the catch path below still calls responseObserver.onError(e) unconditionally. If responseObserver is null (which this method already anticipates), this will throw an NPE and mask the original error. Please null-check before calling onError/onCompleted, or return a Mono.error(...) so the error is propagated without dereferencing a null observer.
String jsonText = mcpJsonMapper.writeValueAsString(message);
responseObserver.onNext(ServerSentEvent.<byte[]>builder()
.event("message")
.data(jsonText.getBytes(StandardCharsets.UTF_8))
.build());
dubbo-plugin/dubbo-mcp/src/main/java/org/apache/dubbo/mcp/transport/DubboMcpStreamableTransportProvider.java:580
- Same issue as the other overload: responseObserver is checked before onNext, but the catch path calls responseObserver.onError(e) without a null check. If responseObserver can be null, this will throw NPE during error handling. Please guard onError similarly or propagate errors via Mono.error(...).
String jsonText = mcpJsonMapper.writeValueAsString(message);
ServerSentEvent<byte[]> event = ServerSentEvent.<byte[]>builder()
.event("message")
.data(jsonText.getBytes(StandardCharsets.UTF_8))
.id(messageId)
.build();
What is the purpose of the change?
Adapt MCP integration to sdk 0.18.2 APIs
Checklist