Image not displaying in chat when returned from MCP server

I am building an MCP server using FastMCP. I’m trying to return an image from my tool that will be displayed in Cursor. I followed the steps in their documentation and have my tool return an Image object, by doing

@mcp.tool()
def visualize_tool() -> Image:
    image_path = get_path()
    return Image(path=image_path)

but Cursor just displays “<fastmcp.utilities.types.Image object at 0x158f57390>” instead of the actual image.

I then tried using the toImageContent method and returning an ImageContent object instead. This did display the image, but then the model would crash immediately after saying “The model returned an error. Try disabling MCP servers, or switch models.” Does anyone know how to properly display images?

As an update, I realized that this works fine for other models like Claude and gemini, but not for GPT models. If anyone knows how to make this work with GPT models please let me know!

1 Like