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? |
Answered by
stephentoub
Mar 28, 2025
Replies: 3 comments 2 replies
|
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");
} |
2 replies
Answer selected by
eiriktsarpalis
|
Thanks a lot, will try |
0 replies
|
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 ... |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
There are a variety of ways, but probably the easiest is to just return a
Microsoft.Extensions.AI.DataContent, e.g.