https://retellai.com/?utm_source=discord&utm_medium=seo logo
Can I pass dynamic variables to the MCP headers
# ❓・ai-evy-support
s
@AI Evy Can I pass dynamic variables to the MCP headers? Like say {{token}} as part of the header. I see from the screenshot of the documentation that I can, but when I actually try it, it doesnt seem to work. I have already verified that the dynamic variable is being received by Retell as I can see from the call history.
a
Thanks for tagging me @Sam. I'll look through relevant sources and get back to you shortly.
### Answer Based on the documentation, dynamic variables can be used in MCP headers [(1) ]() [(2) ]() . The MCP documentation shows that you can define custom headers and that dynamic variables are supported for use in various parts of the agent including tool descriptions . For MCP setup, you can set request headers as optional configuration when adding an MCP server . Dynamic variables use the
{{variable_name}}
syntax and can be referenced in prompts, tool descriptions, and other areas [(3) ]() . However, there are some common issues with dynamic variables that could explain why your
{{token}}
isn't working: 1. **Variable naming and case sensitivity**: Dynamic variables must match exact names and are case-sensitive [(4) ]() 2. **String format requirement**: All values in
retell_llm_dynamic_variables
must be strings [(3) ]() [(5) ]() [(6) ]() [(7) ]() 3. **Proper API payload**: The variables need to be sent correctly in the
retell_llm_dynamic_variables
field [(4) ]() Since you've verified the dynamic variable appears in call history, the issue might be with how it's being referenced in the MCP header configuration. Make sure: - The variable name in the header exactly matches what you're sending (case-sensitive) - The variable is being passed as a string value - There are no extra spaces or formatting issues in the header configuration If the issue
persists, you might want to test with a simple dynamic variable first to isolate whether it's a header-specific issue or a broader dynamic variable problem.
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
s
retell_llm_dynamic_variables ? The documentation says something else https://docs.retellai.com/features/inbound-call-webhook#inbound-call-webhook res.status(200).json({ call_inbound: { // Dynamic variables that will be available during the call dynamic_variables: sanitizedVariables } }); @AI Evy
the variable is exactly the same
@AI Evy pls help
a
Thanks for the follow-up, @Sam. I'll get back to you soon.
### Answer You're absolutely correct about the field name difference. For inbound calls using the inbound call webhook, you use
dynamic_variables
in the webhook response [(1) ]() :
Copy code
javascript
{
 "call_inbound": {
 "override_agent_id": "agent_12345",
 "override_agent_version": 1,
 "dynamic_variables": {
 "customer_name": "John Doe"
 },
 "metadata": {
 "random_id": "12345"
 }
 }
}
However, for outbound calls using the Create Phone Call API, you would use
retell_llm_dynamic_variables
[(2) ]() . The field name depends on the context: - **Inbound calls**: Use
dynamic_variables
in the inbound webhook response [(1) ]() - **Outbound calls**: Use
retell_llm_dynamic_variables
in the Create Phone Call API [(2) ]() According to the documentation, dynamic variables can be used in various places including tool call descriptions and custom tool call properties descriptions . All values in dynamic variables must be strings . If your
{{token}}
variable is appearing correctly in the call history but not working in MCP headers, and you've verified the variable name matches exactly, this could be a specific issue with MCP header processing that might require further investigation.
​ To learn more, see the sources I considered: [[1] Inbound call webhook](https://docs.retellai.com/features/inbound-call-webhook) [[2] Dynamic Variables](https://docs.retellai.com/build/dynamic-variables) ​
Feel free to tag @AI Evy with additional questions. I also appreciate feedback, it helps me improve.
s
thanks
you are right
works
i had to check my validation system for headers @heavenly_parrot_01625