TestConnectAll_ToolInfoParameters verifies that tool input schema parameters are propagated to the ToolInfo.
(t *testing.T)
| 474 | // TestConnectAll_ToolInfoParameters verifies that tool input schema |
| 475 | // parameters are propagated to the ToolInfo. |
| 476 | func TestConnectAll_ToolInfoParameters(t *testing.T) { |
| 477 | t.Parallel() |
| 478 | ctx := context.Background() |
| 479 | logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true}) |
| 480 | |
| 481 | ts := newTestMCPServer(t, echoTool()) |
| 482 | |
| 483 | cfg := makeConfig("srv", ts.URL) |
| 484 | tools, cleanup := mcpclient.ConnectAll(ctx, logger, []database.MCPServerConfig{cfg}, nil, uuid.Nil, nil, nil) |
| 485 | t.Cleanup(cleanup) |
| 486 | require.Len(t, tools, 1) |
| 487 | |
| 488 | info := tools[0].Info() |
| 489 | // The echo tool has a required "input" string parameter. |
| 490 | require.NotNil(t, info.Parameters) |
| 491 | _, hasInput := info.Parameters["input"] |
| 492 | assert.True(t, hasInput, "parameters should contain 'input'") |
| 493 | |
| 494 | // The "input" field should also appear in Required. |
| 495 | inputProp, ok := info.Parameters["input"].(map[string]any) |
| 496 | assert.True(t, ok, "input parameter should be a map") |
| 497 | if ok { |
| 498 | propBytes, _ := json.Marshal(inputProp) |
| 499 | assert.Contains(t, string(propBytes), "string") |
| 500 | } |
| 501 | assert.Contains(t, info.Required, "input") |
| 502 | } |
| 503 | |
| 504 | // TestConnectAll_NilRequiredBecomesEmptySlice verifies that a tool |
| 505 | // whose inputSchema omits "required" produces an empty slice instead |
nothing calls this directly
no test coverage detected