@@ -177,7 +177,24 @@ func RunMCPCustomToolCallMethod(t *testing.T, toolName string, arguments map[str
177177 if len (mcpResp .Result .Content ) == 0 {
178178 t .Fatalf ("%s returned empty content field" , toolName )
179179 }
180- got := mcpResp .Result .Content [0 ].Text
180+
181+ // Gather all the text blocks
182+ var blocks []string
183+ for _ , content := range mcpResp .Result .Content {
184+ if content .Type == "text" {
185+ blocks = append (blocks , strings .TrimSpace (content .Text ))
186+ }
187+ }
188+
189+ var got string
190+ // If the test is expecting a JSON array, format the stitched blocks as a JSON array
191+ if want != "" && strings .HasPrefix (strings .TrimSpace (want ), "[" ) {
192+ got = "[" + strings .Join (blocks , "," ) + "]"
193+ } else {
194+ // Otherwise, just concatenate them normally (for single responses or errors)
195+ got = strings .Join (blocks , "" )
196+ }
197+
181198 if ! strings .Contains (got , want ) {
182199 t .Fatalf (`expected %q to contain %q` , got , want )
183200 }
@@ -278,7 +295,24 @@ func RunMCPToolInvokeTest(t *testing.T, select1Want string, options ...InvokeTes
278295 if len (mcpResp .Result .Content ) == 0 {
279296 t .Fatalf ("%s returned empty content field" , tc .toolName )
280297 }
281- got := mcpResp .Result .Content [0 ].Text
298+
299+ // Gather all the text blocks
300+ var blocks []string
301+ for _ , content := range mcpResp .Result .Content {
302+ if content .Type == "text" {
303+ blocks = append (blocks , strings .TrimSpace (content .Text ))
304+ }
305+ }
306+
307+ var got string
308+ // If the test is expecting a JSON array, format the stitched blocks as a JSON array
309+ if tc .wantResult != "" && strings .HasPrefix (strings .TrimSpace (tc .wantResult ), "[" ) {
310+ got = "[" + strings .Join (blocks , "," ) + "]"
311+ } else {
312+ // Otherwise, just concatenate them normally (for single responses or errors)
313+ got = strings .Join (blocks , "" )
314+ }
315+
282316 if ! strings .Contains (got , tc .wantResult ) {
283317 t .Fatalf (`expected %q to contain %q` , got , tc .wantResult )
284318 }
@@ -370,7 +404,7 @@ func GetExecuteSQLMCPExpectedTools() []MCPToolManifest {
370404 Description : "Tool to execute sql" ,
371405 InputSchema : map [string ]any {
372406 "type" : "object" ,
373- "properties" : map [string ]any {"sql" : map [string ]any {"type" : "string" , "description" : "A valid SQL statement to execute." }},
407+ "properties" : map [string ]any {"sql" : map [string ]any {"type" : "string" , "description" : "The sql to execute." }},
374408 "required" : []any {"sql" },
375409 },
376410 },
@@ -379,7 +413,7 @@ func GetExecuteSQLMCPExpectedTools() []MCPToolManifest {
379413 Description : "Tool to execute sql" ,
380414 InputSchema : map [string ]any {
381415 "type" : "object" ,
382- "properties" : map [string ]any {"sql" : map [string ]any {"type" : "string" , "description" : "A valid SQL statement to execute." }},
416+ "properties" : map [string ]any {"sql" : map [string ]any {"type" : "string" , "description" : "The sql to execute." }},
383417 "required" : []any {"sql" },
384418 },
385419 },
0 commit comments