Next.js Discord

Discord Forum

Add middleware for tool calling

Unanswered
English Angora posted this in #help-forum
Open in Discord
English AngoraOP
I'm using Vercel AI SDK's streamText with tool calling and structured output. I'm also connecting to an MCP client using experimental_createMCPClient, and have maxSteps set to 3.

I want to add middleware that sets certain parameter values of the tools parameters before the tool is executed. These values shouldn't be generated by the LLM, but rather injected programmatically.

What's the best way to achieve this while keeping maxSteps: 3?

0 Replies