-
Notifications
You must be signed in to change notification settings - Fork 8
Closed
Labels
enhancementNew feature or requestNew feature or requestfixed and releasedThis issue has been fixed and included in the latest releaseThis issue has been fixed and included in the latest releasewaiting for userWaiting for user feedback or more detailsWaiting for user feedback or more details
Milestone
Description
For tools that return void or null, it results in an NPE; since the output of the tool method is processed without checking for null.
In class McpServerTool (refer to NPE comment),
@Override
public McpSchema.CallToolResult apply(McpSyncServerExchange ex, McpSchema.CallToolRequest req) {
Object result;
boolean isError = false;
try {
Map<String, Object> arguments = req.arguments();
List<Object> convertedParams = converter.convertAllParameters(methodCache, arguments);
// Use cached method for invocation
result = methodCache.getMethod().invoke(instance, convertedParams.toArray());
} catch (Exception e) {
log.error("Error invoking tool method: {}", methodCache.getMethodSignature(), e);
result = e + ": " + e.getMessage();
isError = true;
}
McpSchema.Content content = new McpSchema.TextContent(result.toString()); // NPE : result, can be null
return new McpSchema.CallToolResult(List.of(content), isError);
}
I am fairly new to this library (and to MCP). Apologies in case I have made a mistake in reporting this issue.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestfixed and releasedThis issue has been fixed and included in the latest releaseThis issue has been fixed and included in the latest releasewaiting for userWaiting for user feedback or more detailsWaiting for user feedback or more details