https://retellai.com/?utm_source=discord&utm_medium=seo logo
why mcp tools invent variable values
# ❓・ai-evy-support
p
@AI Evy why mcp tools invent variable values?
a
Thanks for tagging me @Paco. I'll look through relevant sources and get back to you shortly.
### Answer Based on community reports, there's a known issue where MCP tool response variables may not be extracted correctly in Conversation Flow agents. [(1) ]() One community member identified a potential cause: MCP tools return stringified JSON responses rather than parsed objects. For example: - A regular custom function returns:
{"customer_id":"6229"}
- An MCP tool returns:
"{\"customer_id\": 12345}"
(stringified) This stringified response format may prevent the response variable extraction from working properly, causing the variable to not appear in
collected_dynamic_variables
and transitions based on that variable to fail. What you can try: 1. Verify your MCP server is returning properly formatted JSON (not double-stringified) 2. Check your response variable mapping in the MCP node configuration—you can extract values from the MCP tool response and save them as dynamic variables for use later in the conversation [(2) ]() 3. Ensure the variable name matches exactly what you're using in your prompts or transitions (case-sensitive) [(3) ]() If the agent is speaking the variable name (like
{{first_name}}
) instead of the actual value, this typically indicates the variable wasn't properly extracted before being referenced. [(4) ]() This appears to be a known issue that may require adjustment on the MCP server side or a fix from Retell. You may want to reach out to support for further assistance.
​ To learn more, see the sources I considered: [[1] mcp tool variables not extracted](https://discord.com/channels/1186424376300679209/1426340769924382791) [[2] MCP](https://docs.retellai.com/build/single-multi-prompt/mcp) [[3] Custom function failure to substitute dynamic variable](https://community.retellai.com/t/custom-function-failure-to-substitute-dynamic-variable/231) [[4] Discord message from @sajjadalgburi on 2025-05-27](https://discord.com/channels/1186424376300679209/1186462578310910112/1377059550443606048) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.