Skip to content

Commit 9c412b7

Browse files
author
fangjie33
committed
fix: invalid check condition and use Utils.isEmpty instead of tool.outputSchema()!=null
Signed-off-by: fangjie <[email protected]>
1 parent 2ee5853 commit 9c412b7

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

mcp-core/src/main/java/io/modelcontextprotocol/client/McpAsyncClient.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,17 @@ public class McpAsyncClient {
300300
return Mono.empty();
301301
}
302302

303-
return this.listToolsInternal(init, McpSchema.FIRST_PAGE).doOnNext(listToolsResult -> {
304-
listToolsResult.tools()
305-
.forEach(tool -> logger.debug("Tool {} schema: {}", tool.name(), tool.outputSchema()));
306-
if (enableCallToolSchemaCaching && listToolsResult.tools() != null) {
307-
// Cache tools output schema
308-
listToolsResult.tools()
309-
.stream()
310-
.filter(tool -> tool.outputSchema() != null)
311-
.forEach(tool -> this.toolsOutputSchemaCache.put(tool.name(), tool.outputSchema()));
312-
}
313-
}).then();
303+
return this.listToolsInternal(init, McpSchema.FIRST_PAGE)
304+
.doOnNext(listToolsResult ->
305+
listToolsResult.tools()
306+
.stream()
307+
.filter(tool -> !Utils.isEmpty(tool.outputSchema()))
308+
.forEach(tool -> {
309+
logger.debug("Tool {} schema: {}", tool.name(), tool.outputSchema());
310+
// Put tool output schema to cache
311+
this.toolsOutputSchemaCache.put(tool.name(), tool.outputSchema());
312+
})
313+
).then();
314314
};
315315

316316
this.initializer = new LifecycleInitializer(clientCapabilities, clientInfo, transport.protocolVersions(),

0 commit comments

Comments
 (0)