1- import { jsonSchemaToZod } from '@n8n/json-schema-to-zod'
21import { MCPClientManager } from 'agents/mcp/client'
3- import { streamText , tool } from 'ai'
2+ import { jsonSchema , streamText , tool } from 'ai'
43import { z } from 'zod'
54
6- import type { JsonSchemaObject } from '@n8n/json-schema-to-zod'
75import type { LanguageModelV1 , StreamTextResult , ToolCallPart , ToolSet } from 'ai'
86
97export async function initializeClient ( ) : Promise < MCPClientManager > {
@@ -23,10 +21,14 @@ export async function runTask(
2321} > {
2422 const tools = clientManager . listTools ( )
2523 const toolSet : ToolSet = tools . reduce ( ( acc , v ) => {
24+ if ( ! v . inputSchema . properties ) {
25+ v . inputSchema . properties = { }
26+ }
27+
2628 acc [ v . name ] = tool ( {
27- parameters : jsonSchemaToZod ( v . inputSchema as JsonSchemaObject ) ,
29+ parameters : jsonSchema ( v . inputSchema as any ) ,
2830 description : v . description ,
29- execute : async ( args , opts ) => {
31+ execute : async ( args : any , opts ) => {
3032 try {
3133 const res = await clientManager . callTool (
3234 {
@@ -47,6 +49,7 @@ export async function runTask(
4749 return acc
4850 } , { } as ToolSet )
4951
52+ console . log ( 'streaming res' )
5053 const res = streamText ( {
5154 model,
5255 system :
0 commit comments