I’ve been trying to bypass the MCP client limitations of not accepting variables as tool inputs. My most recent attempt was to use a regular AI Agent with a stateful tool that takes a generic json as input. The tool state would then cause the tool description and input schema to change.
All very exciting until I learned the hard way that I cannot pass variables to the $fromAI function. There’s a subtle hint to this in the documentation:
The
key
parameter and other arguments to the$fromAI()
function aren’t references to existing values. Instead, think of these arguments as hints that the AI model will use to populate the right data.
But I’d appreciate if this was written clearer. Oddly enough this function doesn’t work with string interpolation either. Any reason why that’s the case? What’s evaluated first?
In my next attempt, which is really the scrappiest of them all, I’ll generate temporary session workflows to which user messages can be routed. Hopefully that will hold the strings until some upgrades are made to these tools.
Any suggestions, tips or success cases in passing sensitive variables reliably to gated/stateful tools?
Information on your n8n setup
- n8n version: 1.94.1
- Database (default: SQLite): Postgres 16
- n8n EXECUTIONS_PROCESS setting: main I believe
- Running n8n via: docker
- Operating system: OSArch on the container, Windows 11 on my end