Skip to content

Returning an EmbeddedResourceBlock from a tool do not work with Claude Desktop #1261

@eng-marani

Description

@eng-marani

Describe the bug
I'm playing with tools attempting to return different ResultContent from an MCP server.

This works:

 ImageContentBlock imgResult = new ImageContentBlock() { Data = base64, MimeType = mimeType };
 result.Content[0] = imgResult;
 return result;

This do not work (mimetype is "application/pdf")

 BlobResourceContents resContent = new BlobResourceContents() { Blob = base64, MimeType = "application/pdf", Uri = $"file:///mypdf.pdf" };
 EmbeddedResourceBlock resResult = new EmbeddedResourceBlock() { Resource = resContent };
 result.Content[0] = resResult;
 return result;

To Reproduce
Steps to reproduce the behavior:

  1. Create an MCP server in c# with a tool that return a contentresult
  2. Setup Claude Desktop as a client

Expected behavior
The resource file should be available in LLM context

Observed result
Claude claims that the tool returned a BAD IMAGE with a wrong mimetype

Claude is basically interpreting the result as an image instead of the suggested mimetype

I do not know if this is a problem of SDK or possibly some wrong implementation in Claude Desktop.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions