#3938·genkit

[JS] MCP inputs are never exposed in streamResponse toolRequest

Author: nicolaCreated Dec 13, 2025Updated Sep 23, 2026
Labelsbugjs

Describe the bug I am trying to log all the tool calls for my agent

typescript
const { stream: streamResponse, response: finalResponsePromise } = await ai.generateStream ...
for await (const chunk of streamResponse) {
  const toolRequests = chunk.content
        .map((part: any) => part.toolRequest)
        .filter((tr: any) => {
          // Filter out empty tool requests
          if (!tr || typeof tr !== 'object' || Object.keys(tr).length === 0) return false;
          // Only include complete tool requests with a valid name
          if (!tr.name || typeof tr.name !== 'string' || tr.name.trim().length === 0) return false;
          return true;
        })
        .map((tr: any) => {
          // NOTE: Genkit's streaming API has a limitation where tool request input
          // parameters are not included in the streaming chunks - they're always {}.
          // This appears to be a bug/limitation in Genkit/MCP streaming.
          // The input is only available in the final response, not in streaming chunks.
          const toolCall = {
            name: tr.name,
            input: tr.input || {}, // Will always be {} in streaming chunks
            ref: tr.ref,
          };
          
          // Store in map for potential matching with responses
          if (tr.ref) {
            toolRequestMap.set(tr.ref, toolCall);
          }
          
          return toolCall;
        });

toolCall.input always returns {}

Expected behavior I am expecting toolCall.input to return the inputs

Runtime (please complete the following information):

  • OS: MacOs

** Node version v23.6.1