Commit 44d430a
committed
fix: MCP tool execution preserve message parts through Zod validation
Root cause: Zod's default .strip() mode on messageSchema silently
removed the 'parts' field from messages during request validation.
The AI SDK stores tool invocations in this field, so
processToolInvocations() never received any tool calls, causing
an infinite loop where the LLM kept proposing the same tool.
Fix: Added .passthrough() to messageSchema to preserve all AI SDK
fields including 'parts' for MCP tool invocation processing.
Also improved mcpService.ts:
- Added parts.length === 0 to early return guard
- Added debug logging for successful tool calls
- Added warning when tool has no execute function1 parent f918f53 commit 44d430a
2 files changed
Lines changed: 10 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
378 | 378 | | |
379 | 379 | | |
380 | 380 | | |
381 | | - | |
| 381 | + | |
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
416 | 417 | | |
417 | 418 | | |
| 419 | + | |
418 | 420 | | |
419 | 421 | | |
420 | 422 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
0 commit comments