Hi!
I have a simple mcp tool in python (see MWE below) in which I try to get the image (similar to the one shown here.
The mcp client receives a dictionary style response and doesn’t render the image. On the other hand, if i call image-server.js
, I do see the image rendered in the chat window
I was wondering if anyone can help on what i may be doing wrong here? Thank you in advance.
PS: I have tried to return a simple dictionary as well as to_image_content()
as mentioned here, but i wasn’t successful.
from typing import Dict
from fastmcp import FastMCP
from fastmcp.utilities.types import Image
mcp = FastMCP("Simple Server")
@mcp.tool()
def get_image(random_number: int) -> Dict:
RED_CIRCLE_BASE64 = "/9j/4AAQSkZJRgABAgEASABIAAD/..."
result = Image(data=bytes(RED_CIRCLE_BASE64, "utf-8"), format="jpeg").to_image_content()
return {
"content": [
result
]
}
if __name__ == "__main__":
mcp.run()