https://retellai.com/?utm_source=discord&utm_medium=seo logo
how can I get the return variable in MCP tool, if ...
# ❓・ai-evy-support
p
@AI Evy how can I get the return variable in MCP tool, if the return from MCP is "{"availableDates":[{"dateFrom":"2025-12-15T14:00:00.000Z","dateTo":"2025-12-15T15:00:00.000Z"},{"dateFrom":"2025-12-15T15:00:00.000Z","dateTo":"2025-12-15T16:00:00.000Z"},{"dateFrom":"2025-12-15T16:00:00.000Z","dateTo":"2025-12-15T17:00:00.000Z"},{"dateFrom":"2025-12-15T17:00:00.000Z","dateTo":"2025-12-15T18:00:00.000Z"},{"dateFrom":"2025-12-15T18:00:00.000Z","dateTo":"2025-12-15T19:00:00.000Z"}]}"
a
Thanks for tagging me @Paco. I'll look through relevant sources and get back to you shortly.
### Answer To extract values from your MCP tool response, you can use the response variables feature when configuring your MCP tool. [(1) ]() For a response like:
Copy code
json
{
  "availableDates": [
    {"dateFrom": "2025-12-15T14:00:00.000Z", "dateTo": "2025-12-15T15:00:00.000Z"},
    ...
  ]
}
You would set response variables to extract values and save them as dynamic variables for use later in the conversation. For example, you can reference a value like
{{available_dates}}
later in the flow. Important caveat: There's a known issue where MCP tools may return stringified responses (e.g.,
"{\"customer_id\": 12345}"
instead of
{"customer_id":"6229"}
) , which can cause variables to not be extracted properly. [(2) ]() If you're experiencing issues with variable extraction, check your MCP server's response format—it may be returning a stringified JSON rather than a proper JSON object.
​ To learn more, see the sources I considered: [[1] MCP](https://docs.retellai.com/build/single-multi-prompt/mcp) [[2] mcp tool variables not extracted](https://discord.com/channels/1186424376300679209/1426340769924382791) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.