@@ -53,7 +53,7 @@ describe('call (execute_tool)', () => {
5353 vi . restoreAllMocks ( ) ;
5454 } ) ;
5555
56- it ( 'should parse JSON params and call client.executeTool' , async ( ) => {
56+ it ( 'should pass object params and call client.executeTool' , async ( ) => {
5757 const mockResponse : ExecuteResponse = {
5858 execution_id : 'exec-123' ,
5959 tool_id : 'weather-tool' ,
@@ -67,13 +67,13 @@ describe('call (execute_tool)', () => {
6767
6868 const result = await executeExecuteTool (
6969 mockClient ,
70- {
71- tool_id : 'weather-tool' ,
72- search_id : 'search-123' ,
73- params_to_tool : '{" city": " Tokyo", " units": " metric"}' ,
74- } ,
75- 'default-session'
76- ) ;
70+ {
71+ tool_id : 'weather-tool' ,
72+ search_id : 'search-123' ,
73+ params_to_tool : { city : ' Tokyo' , units : ' metric' } ,
74+ } ,
75+ 'default-session'
76+ ) ;
7777
7878 expect ( executeToolMock ) . toHaveBeenCalledWith ( 'weather-tool' , {
7979 search_id : 'search-123' ,
@@ -96,13 +96,13 @@ describe('call (execute_tool)', () => {
9696
9797 await executeExecuteTool (
9898 mockClient ,
99- {
100- tool_id : 'tool-1' ,
101- search_id : 'search-123' ,
102- params_to_tool : '{}' ,
103- session_id : 'custom-session' ,
104- } ,
105- 'default-session'
99+ {
100+ tool_id : 'tool-1' ,
101+ search_id : 'search-123' ,
102+ params_to_tool : { } ,
103+ session_id : 'custom-session' ,
104+ } ,
105+ 'default-session'
106106 ) ;
107107
108108 expect ( executeToolMock ) . toHaveBeenCalledWith ( 'tool-1' , {
@@ -124,13 +124,13 @@ describe('call (execute_tool)', () => {
124124
125125 await executeExecuteTool (
126126 mockClient ,
127- {
128- tool_id : 'tool-1' ,
129- search_id : 'search-123' ,
130- params_to_tool : '{}' ,
131- max_response_size : 102400 ,
132- } ,
133- 'default-session'
127+ {
128+ tool_id : 'tool-1' ,
129+ search_id : 'search-123' ,
130+ params_to_tool : { } ,
131+ max_response_size : 102400 ,
132+ } ,
133+ 'default-session'
134134 ) ;
135135
136136 expect ( executeToolMock ) . toHaveBeenCalledWith ( 'tool-1' , {
@@ -141,35 +141,24 @@ describe('call (execute_tool)', () => {
141141 } ) ;
142142 } ) ;
143143
144- it ( 'should throw error for invalid JSON in params_to_tool' , async ( ) => {
145- await expect (
146- executeExecuteTool (
147- mockClient ,
148- {
149- tool_id : 'tool-1' ,
150- search_id : 'search-123' ,
151- params_to_tool : 'not valid json' ,
152- } ,
153- 'default-session'
154- )
155- ) . rejects . toThrow ( 'Invalid JSON in params_to_tool' ) ;
156- } ) ;
157-
158- it ( 'should include original params in JSON parse error message' , async ( ) => {
159- await expect (
160- executeExecuteTool (
161- mockClient ,
162- {
163- tool_id : 'tool-1' ,
164- search_id : 'search-123' ,
165- params_to_tool : '{broken' ,
166- } ,
167- 'default-session'
168- )
169- ) . rejects . toThrow ( 'Received: {broken' ) ;
170- } ) ;
171-
172- it ( 'should handle complex nested parameters' , async ( ) => {
144+ it . each ( [ 'not valid json' , null , [ 'city' ] ] ) (
145+ 'should reject non-object params_to_tool: %s' ,
146+ async ( paramsToTool ) => {
147+ await expect (
148+ executeExecuteTool (
149+ mockClient ,
150+ {
151+ tool_id : 'tool-1' ,
152+ search_id : 'search-123' ,
153+ params_to_tool : paramsToTool as unknown as Record < string , unknown > ,
154+ } ,
155+ 'default-session'
156+ )
157+ ) . rejects . toThrow ( 'params_to_tool must be a JSON object' ) ;
158+ }
159+ ) ;
160+
161+ it ( 'should handle complex nested parameters' , async ( ) => {
173162 const complexParams = {
174163 filters : {
175164 category : 'electronics' ,
@@ -189,12 +178,12 @@ describe('call (execute_tool)', () => {
189178
190179 await executeExecuteTool (
191180 mockClient ,
192- {
193- tool_id : 'search-products' ,
194- search_id : 'search-123' ,
195- params_to_tool : JSON . stringify ( complexParams ) ,
196- } ,
197- 'default-session'
181+ {
182+ tool_id : 'search-products' ,
183+ search_id : 'search-123' ,
184+ params_to_tool : complexParams ,
185+ } ,
186+ 'default-session'
198187 ) ;
199188
200189 expect ( executeToolMock ) . toHaveBeenCalledWith ( 'search-products' , {
@@ -212,13 +201,13 @@ describe('call (execute_tool)', () => {
212201 await expect (
213202 executeExecuteTool (
214203 mockClient ,
215- {
216- tool_id : 'tool-1' ,
217- search_id : 'search-123' ,
218- params_to_tool : '{}' ,
219- } ,
220- 'session'
221- )
204+ {
205+ tool_id : 'tool-1' ,
206+ search_id : 'search-123' ,
207+ params_to_tool : { } ,
208+ } ,
209+ 'session'
210+ )
222211 ) . rejects . toEqual ( error ) ;
223212 } ) ;
224213 } ) ;
0 commit comments