https://retellai.com/?utm_source=discord&utm_medium=seo logo
How to ensure that MCP Tools use the correct dynam...
# ❓・ai-evy-support
t
@AI Evy How to ensure that MCP Tools use the correct dynamic variable when calling the tool?
a
Thanks for tagging me @thilo_34107. I'll look through relevant sources and get back to you shortly.
### Answer To ensure MCP Tools use the correct dynamic variables, you can configure them through query parameters and response variables in your MCP setup [(1) ]() . Setting Up Dynamic Variables for MCP Tools: 1. **Pass Dynamic Variables as Query Parameters**: You can map dynamic variables (like customer names, form inputs, or prior responses) into query parameters for your MCP calls . This allows you to send user-specific data to your external tools. 2. **Configure Response Variables**: You can extract values from the MCP tool response and save them as dynamic variables for use later in the conversation . For example, you can extract a user's name from the response and reference it later using
{{user_name}}
. Example Response Handling:
Copy code
json
{
 "properties": {
 "user": {
 "name": "John Doe",
 "age": 26
    }
  }
}
You can save
properties.user.name
as a variable like
user_name
, and use it in follow-ups . **Dynamic Variable Syntax**: Dynamic variables use double curly braces syntax like
{{user_name}}
,
{{product_name}}
, etc., and can be used in prompts, begin messages, tool call URLs, and tool call descriptions [(2) ]() . **For Outbound Calls**: When using the Create Phone Call API, set your variables in the
retell_llm_dynamic_variables
field, with all values as strings . **Note**: There are some reported stability issues with MCP tool calls where subsequent calls may fail if the session ID isn't properly maintained [(3) ]() . If you experience issues with MCP tools not receiving the correct variables, this could be related to session management problems.
​ To learn more, see the sources I considered: [[1] Connect any AI Voice Agent to MCP with Retell AI MCP Node (Guide) | Retell AI](https://www.retellai.com/blog/connect-any-ai-voice-agent-to-mcp-with-retell-ai-mcp-node) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) [[3] MCP Server tool calls not stable](https://discord.com/channels/1186424376300679209/1409520321450479656) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
t
How to use dynamic variables in function "book cal.com" - I see no option to custom map variables
@AI Evy How to use dynamic variables in function "book cal.com" - I see no option to custom map variables
a
Thanks for the follow-up, @thilo_34107. I'll get back to you soon.
### Answer The Cal.com book calendar function in Retell AI works with dynamic variables through the agent's conversation flow, but there isn't direct variable mapping within the function configuration itself [(1) ]() . To use dynamic variables with the Cal.com booking function, you need to first extract the necessary information using the Extract Dynamic Variables tool [(2) ]() . Here's how to set it up: Step 1: Extract Dynamic Variables Create an Extract Dynamic Variables tool to capture user information like name, email, and phone number . You can define variables with these types : - Text - Any word or sentence (e.g., "John Smith") - Number - Numeric values - Enum - Predefined list options - Boolean - True or false Step 2: Configure the Cal.com Function Set up your Cal.com book calendar function with [(1) ]() : - Tool name (must be unique within the agent) - API Key from Cal.com - Event Type ID - Tool description - Optional timezone Step 3: Update Your Prompt Include explicit instructions in your prompt about when to extract variables and when to book appointments [(1) ]() [(2) ]() :
Copy code
When user states his name and phone number, please extract the information by calling the `extract_user_details` function.
Copy code
When user selected a slot, please book the appointment by calling the `book_appointment` function.
The Cal.com function will automatically use the extracted dynamic variables during the booking process. As shown in the video tutorial, the agent can collect name, email, and phone number, then successfully book appointments with that information passed to Cal.com [(3) ](

▾

) . There's a known issue where email variables sometimes don't make it to the Cal.com book function, defaulting to "user_name@example.com" [(4) ]() . If you encounter this, check your tool invocation logs in the call history dashboard to troubleshoot the variable passing.
​ To learn more, see the sources I considered: [[1] Book Calendar](https://docs.retellai.com/build/book-calendar) [[2] Extract Dynamic Variables](https://docs.retellai.com/build/single-multi-prompt/extract-dv) [[3] Retell AI - How to use Cal.com Custom Field](

https://www.youtube.com/watch?v=b59o1YCcvjc▾

) [[4] Email variable not making it to Cal.com book function](https://discord.com/channels/1186424376300679209/1358927987193413853) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.