Librechat does not support image content from MCP tool's return #9961
Replies: 2 comments 5 replies
-
|
It's working as expected. Your MCP server is not returning the proper format for images as we can see in your output: {
"type": "text",
"text": "{\n "results": [\n {\n "text": "<PIL.Image.Image image mode=RGBA size=1000x500>",\n "png": Should be See the following for more information:
|
Beta Was this translation helpful? Give feedback.
-
|
This issue persists because the fix in #6951 addressed MCP image rendering but not the underlying token explosion. I've traced the root cause to This means a single MCP image that should cost ~1,200 native image tokens instead costs ~214,000 text tokens (174× amplification), immediately exceeding context limits. Workaround: Instruct the agent (via system prompt) to always produce a thinking block before tool calls and to avoid parallel tool calls when image tools are involved. This prevents the destructive code path from triggering. I've filed a detailed issue on danny-avila/agents with reproduction steps and a suggested fix. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
Although issue #6951 was marked as fixed, LibreChat still does not correctly render image content returned from MCP tools. When using the official E2B MCP server
with LibreChat, image outputs (e.g. PNG plots generated by Python code) are displayed as long base64 text blobs in the chat window rather than as images.
Expected behavior
or Markdown image, instead of dumping the raw base64 string.
LibreChat should detect image content (e.g. content: [{ type: "image_url", image_url: { url: "data:image/png;base64,..." } }] or similar) returned by MCP tools and render it inline as an
Version Information
{
"type": "text",
"text": "{\n "results": [\n {\n "text": "<PIL.Image.Image image mode=RGBA size=1000x500>",\n "png": "iVBORw0KGgoAAAANSUhEUgAAA+gAAAH0CAYAAACuKActAAC/P0lEQVR4Ae2dBZxdxdmH30124+4OCRI0wSG4ayluxQu0FHcKLV6gFCkUh2Jtv+KFFvcQnCBBEyQQ4u5u95v/7M5yd7N2dc+595nfb/fee86cmXeeuXLemVdKEq4YBQIQgAAEIAABCEAAAhCAAAQgAIFGJdCkUXuncwhAAAIQgAAEIAABCEAAAhCAAAQ8ARR03ggQgAAEIAABCEAAAhCAAAQgAIEIEEBBj8AkIAIEIAABCEAAAhCAAAQgAAEIQAAFnfcABCAAAQhAAAIQgAAEIAABCEAgAgRQ0CMwCYgAAQhAAAIQgAAEIAABCEAAAhBAQec9AAEIQAACEI.......
Steps to Reproduce
Connect LibreChat to the E2B MCP server.
Run Python code that generates a plot and saves it as PNG (the MCP server returns the PNG as base64).
Observe the LibreChat UI: the PNG is shown as a long base64 string instead of an image.
What browsers are you seeing the problem on?
Firefox
Relevant log output
Screenshots
No response
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions