I have an agent with custom MCP tool. The MCP tool generates a chart and responds with the base64 encoded version. I'm trying to send this image (utilizing an adaptive card with Image type), via Teams channel, as a response to a user's question to my agent.
User question to agent -> agent invokes Create Chart MCP tool -> agent invokes tool flow passing in response from Create Chart MCP tool -> tool flow responds with adaptive card with chart image
It's my understanding that you can't (yet?) call an MCP tool from a flow tool action (or topic) and capture the output of the MCP tool directly (it's not available as an environment/context variable?). To work around that I'm creating a tool flow that takes 1 input (base64code) that is filled using 'Dynamically fill with AI' and basically does nothing with it other than setting a variable base64codefromflow. It basically acts as a passthrough. Then in the flow tool completion, I set the adaptive card as such.
{
type: "Image",
url: "data:image/png;base64,{Topic.Output.base64codefromflow}",
size: "stretch",
altText: "generated graph"
}
The problem I'm having is with the input to my flow. The input variable gets set 'Dynamically fill with AI' but instead of getting the exact output from the previous step, I get a slightly manipulated base64code, rendering it useless, even when I provide an agent instruction to pass it on exactly as received.
1) Is there a better way to return an image to a question in a Teams channel when I have the base64 code provided by an MCP tool.
2) Is there another way to get the output of an MCP tool into a variable to use in a flow or in an adaptive card?
3) Is there a specific instruction I can use to ensure 'Dynamically fill with AI' does not alter the input to the flow when setting the input variable.
I could probably expose my chart generation service as a regular http endpoint connection which would allow me to use it as an action in a topic/flow and capture the output in a variable, but I'm trying to stick with the MCP tool approach.
Any suggestions/input are welcome. Thanks