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?