MCPcopy Create free account
hub / github.com/coder/coder / TestConnectAll_ToolInfoParameters

Function TestConnectAll_ToolInfoParameters

coderd/x/chatd/mcpclient/mcpclient_test.go:476–502  ·  view source on GitHub ↗

TestConnectAll_ToolInfoParameters verifies that tool input schema parameters are propagated to the ToolInfo.

(t *testing.T)

Source from the content-addressed store, hash-verified

474// TestConnectAll_ToolInfoParameters verifies that tool input schema
475// parameters are propagated to the ToolInfo.
476func 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

Callers

nothing calls this directly

Calls 9

ConnectAllFunction · 0.92
newTestMCPServerFunction · 0.85
echoToolFunction · 0.85
makeConfigFunction · 0.85
CleanupMethod · 0.65
LenMethod · 0.45
InfoMethod · 0.45
MarshalMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected