agentscope-java
agentscope-java copied to clipboard
Bug: McpContentConverter incorrectly converts URL image data to Base64Source
Describe the bug
McpContentConverter always converts McpSchema.ImageContent.data() to Base64Source.
However, when the MCP server returns an image URL instead of Base64-encoded data, the URL is incorrectly treated as Base64 data. This produces an invalid ImageBlock and prevents downstream consumers from loading the image correctly.
Relevant code:
https://github.com/agentscope-ai/agentscope-java/blob/main/agentscope-core/src/main/java/io/agentscope/core/tool/mcp/McpContentConverter.java#L143-L153
private static ImageBlock convertImageContent(McpSchema.ImageContent imageContent) {
String base64Data = imageContent.data();
String mimeType = imageContent.mimeType();
if (base64Data == null || base64Data.isEmpty()) {
return null;
}
Base64Source source = new Base64Source(mimeType, base64Data);
return new ImageBlock(source);
}