web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Copilot Studio - Model Context Protocol
Unanswered

Capture MCP Tool output in variable for chart response - dynamically fill with AI issue

(1) ShareShare
ReportReport
Posted on by 2
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
 
 
I have the same question (0)
  • Suggested answer
    sannavajjala87 Profile Picture
    166 on at
    Capture MCP Tool output in variable for chart response - dynamically fill with AI issue
    Hi,
     

    Pipeline: MCP tool → (returns base64) → Flow converts base64 to a hosted image (SAS URL) → Flow posts Adaptive Card with url: https://….

     

    Why:

     

    • Adaptive Cards do support base64 Data URIs in the Image.url, but Teams payload size and renderer issues often break this in desktop/web clients. Hosting the image (e.g., Azure Blob SAS or Teams-file upload) eliminates mutation risk and client incompatibilities.


    •  
     

    Steps you can implement now:

     

    1. Flow input: define a Text parameter base64Input on the When an agent calls the flow trigger. (Copilot → Flow parameters only support Number/String/Boolean; max 1 MB from flow back to agent).

    2. Create file from base64: in the flow, decode base64Input to binary, Create blob (Azure Blob Storage) or Upload to Teams (Graph) to get a durable URL.

      • Blob path: create container charts, file name chart-<GUID>.png, generate a short‑lived SAS URL.

      • Teams path: upload to the chat/channel and use the Teams‑hosted URL for the card. 


      •  

    3. Post Adaptive Card: set the Image.url to that HTTPS URL (not base64).
       
       
       
       
      {
      "type": "AdaptiveCard",
      "version": "1.5",
      "body": [
      { "type": "TextBlock", "text": "Generated chart", "weight": "Bolder" },
      {
      "type": "Image",
      "url": "https://<storage>/<container>/chart-123.png?<sas>",
      "size": "Stretch",
      "altText": "generated graph"
      }
      ]
       
       
      This avoids the 25 KB Teams message payload limit and inconsistent rendering of data URIs in some clients.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Coming soon: forum hierarchy changes

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Copilot Studio

#1
Romain The Low-Code Bearded Bear Profile Picture

Romain The Low-Code... 321 Super User 2025 Season 2

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 252 Super User 2025 Season 2

#3
S-Venkadesh Profile Picture

S-Venkadesh 93 Moderator

Last 30 days Overall leaderboard