Skip to content

How do I return file in current implementation? #127

Description

@vshapenko

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?

Activity

  1. stephentoub commented on Mar 28, 2025

    @stephentoub
    Contributor

    There are a variety of ways, but probably the easiest is to just return a Microsoft.Extensions.AI.DataContent, e.g.

    [McpServerTool]
    public static DataContent GetMyImage()
    {
        byte[] bytes = File.ReadAllBytes("path/to/my/image.png");
        return new DataContent(bytes, "image/png");
    }
  2. vshapenko commented on Mar 28, 2025

    @vshapenko
    Author

    Thanks a lot, will try

  3. locked and limited conversation to collaborators on Mar 28, 2025
  4. converted this issue into a discussion #129 on Mar 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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