How do I return file in current implementation? #129
-
Hello! Just checked the docs and tests and did not find any sample on how I can return file as tool answer, for example. Could anyone shed some light on it? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
There are a variety of ways, but probably the easiest is to just return a [McpServerTool]
public static DataContent GetMyImage()
{
byte[] bytes = File.ReadAllBytes("path/to/my/image.png");
return new DataContent(bytes, "image/png");
} |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot, will try |
Beta Was this translation helpful? Give feedback.
-
Depending on the client not alle mimetypes and data sizes are supported though, i.e. Claude AI doesn't like Excel files (even if they are small) and produces weird errors when trying to return zip files. Finding out what exactly works and what not is a challenge right now as it is constantly changing ... |
Beta Was this translation helpful? Give feedback.
There are a variety of ways, but probably the easiest is to just return a
Microsoft.Extensions.AI.DataContent
, e.g.