Describe the problem/error/question
My openai agent is not using the correct supabase or mcp client tool when it should.
I have an mcp server that describes the api endpoint params correctly, and I have provided resources or tools with schemas so it knows how to query it, but it always screws up the parameters and never returns a good result.
For example: if I want to get information on one user ‘john doe’, instead of using the api schema definition and saying “I need a user with firstname=john, lastname=doe” it will try to get the user with username=john, or the firstName=john, or name=john. It has no context into my mcp server parameters, even though they are defined.
I have a similar problem when I tried to access tools for sql querying. I have supabase tools attached to the agent, and it will call the wrong tool, or pull the entire table, regardless of the prompt I give.
Information on your n8n setup
- n8n version: cloud
- Database (default: SQLite): postgres
- n8n EXECUTIONS_PROCESS setting (default: own, main):
- Running n8n via (Docker, npm, n8n cloud, desktop app): cloud
- Operating system: mac
Can you share a workflow with reproducible example?
I would suggest to make sure that:
- Your nodes are named correctly. The node name is the tool name and can help AI distinguish the tools.
- Your tools have a clear description.
- Your parameters have a description.
If all of these are set, the LLM should have no trouble calling the right tool.
Here is the workflow with a simple example with user supabase tool.
I just added an ai defined parameter with a description for ‘firstname’ and it doesn’t even use that correctly. Am I missing something ?
I am able to use this a bit better, although it is still not perfect.
A couple questions:
Is there a way to skip a parameter when the value isn’t there?
For example, asking for a whole name will work correctly: ‘give me info on John Doe’ will query supabase with firstname=eq.John&lastname=eq.Doe
, but if I ask ‘give me info on John’ it tries to query supabase with firstname=eq.John&lastname=eq.
and ends up not returning anything.
Along the same lines, is there a way to make these case insensitive?
Ok because I’m not getting any replies to this thread. I will post my solution that I found to work just by troubleshooting and banging rocks together. I hope this helps someone trying to do something similar.
Instead of using the supabase tool, I switch over to using an http request tool and filled out a lot of my prompt with the table names, and the schema of a table that needed to be joined.
Here is my flow now:
This works very well so far, and I have been able to answer most of my questions through chat that I need.