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

Function TestModelIntent_Info_WrapsSchema

coderd/x/chatd/mcpclient/mcpclient_test.go:1291–1325  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1289}
1290
1291func TestModelIntent_Info_WrapsSchema(t *testing.T) {
1292 t.Parallel()
1293 ctx := context.Background()
1294 logger := slogtest.Make(t, &slogtest.Options{IgnoreErrors: true})
1295
1296 ts := newTestMCPServer(t, echoTool())
1297
1298 cfg := makeConfig("intent-srv", ts.URL)
1299 cfg.ModelIntent = true
1300
1301 tools, cleanup := mcpclient.ConnectAll(ctx, logger, []database.MCPServerConfig{cfg}, nil, uuid.Nil, nil, nil)
1302 t.Cleanup(cleanup)
1303 require.Len(t, tools, 1)
1304
1305 info := tools[0].Info()
1306
1307 // Top-level schema should have model_intent and properties.
1308 _, hasModelIntent := info.Parameters["model_intent"]
1309 _, hasProperties := info.Parameters["properties"]
1310 assert.True(t, hasModelIntent, "schema should contain model_intent")
1311 assert.True(t, hasProperties, "schema should contain properties")
1312
1313 // Required should include both.
1314 assert.Contains(t, info.Required, "model_intent")
1315 assert.Contains(t, info.Required, "properties")
1316
1317 // The original "input" parameter should be nested under
1318 // properties.properties.
1319 propsObj, ok := info.Parameters["properties"].(map[string]any)
1320 require.True(t, ok)
1321 innerProps, ok := propsObj["properties"].(map[string]any)
1322 require.True(t, ok)
1323 _, hasInput := innerProps["input"]
1324 assert.True(t, hasInput, "original 'input' param should be nested")
1325}
1326
1327func TestModelIntent_Info_NoWrapWhenDisabled(t *testing.T) {
1328 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected