Skip to content

MCP ImageContent not passed to VLM + no working directory placeholder in prompts #1596

Description

@sunasaji

Which version of LM Studio?
LM Studio 0.4.6

Which operating system?
Windows11

What is the bug?
When an MCP tool returns ImageContent, LM Studio stores the image in the per-conversation working directory, but the VLM does not receive the image as a model input. The model reports it cannot see the image.
Additionally, the per-conversation working directory (or conversation ID) is not exposed to the model via prompt template placeholders, so the model cannot discover the correct path on its own.

Screenshots
Image

Logs
1772465710308.conversation.json

Observed behavior:

  • The image returned by the MCP tool is saved under LM Studio’s working directory, e.g.
    C:\Users\USER\.lmstudio\working-directories\1772465710308
  • LM Studio logs contain 1772465710308, but there is no evidence of this value being passed into the model prompt.
    As a result, the model has no way to determine the active conversation’s working directory, and it cannot “see” the image it just retrieved.

To Reproduce
Steps to reproduce the behavior:

  1. Create a minimal MCP server that returns ImageContent:
# minimal_image_mcp.py
import base64
import asyncio
from mcp.server import Server
from mcp.server.stdio import stdio_server
from mcp.types import ImageContent, Tool

app = Server("minimal-image")

@app.list_tools()
async def list_tools():
    return [Tool(
        name="return_image",
        description="Return a local image as ImageContent.",
        inputSchema={"type":"object","properties":{"path":{"type":"string"}}, "required":["path"]},
    )]

@app.call_tool()
async def call_tool(name, arguments):
    path = arguments["path"]
    with open(path, "rb") as f:
        data = base64.b64encode(f.read()).decode("utf-8")
    mime = "image/png" if path.lower().endswith(".png") else "image/jpeg"
    return [ImageContent(type="image", data=data, mimeType=mime)]

async def run():
    async with stdio_server() as (r, w):
        await app.run(r, w, app.create_initialization_options())

if __name__ == "__main__":
    asyncio.run(run())
  1. Add to mcp.json:
{
  "mcpServers": {
    "minimal-image": {
      "command": "C:\\Windows\\py.exe",
      "args": ["-3", "C:\\Users\\USER\\minimal_image_mcp.py"]
    }
  }
}
  1. Start LM Studio, enable the MCP server, and run:
Get the image at "C:\path\to\the\image.jpg" by using the return_image tool in mcp/minimal-image and transcribe it using the model's Vision function.
  1. The tool returns ImageContent and LM Studio saves it in the working directory, but the model replies it cannot see the image.

Expected behavior

  1. Provide template placeholders (e.g., {workingDirectory} or {conversationId}) so the system prompt can include the current conversation’s working directory or ID.
  2. If the model can discover the working directory path, it can use mcp-filesystem or mcp-local-vision to access and interpret the images it just retrieved.

Related issue
Similar report for reference:
modelcontextprotocol/servers#2389

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions