(t *testing.T)
| 1385 | } |
| 1386 | |
| 1387 | func TestChatWithMCPServerIDs(t *testing.T) { |
| 1388 | t.Parallel() |
| 1389 | |
| 1390 | ctx := testutil.Context(t, testutil.WaitLong) |
| 1391 | client := newMCPClient(t) |
| 1392 | firstUser := coderdtest.CreateFirstUser(t, client) |
| 1393 | |
| 1394 | expClient := codersdk.NewExperimentalClient(client) |
| 1395 | |
| 1396 | // Create the chat model config required for creating a chat. |
| 1397 | _ = createChatModelConfigForMCP(t, expClient) |
| 1398 | |
| 1399 | // Create an enabled MCP server config. |
| 1400 | mcpConfig := createMCPServerConfig(t, client, "chat-mcp-server", true) |
| 1401 | |
| 1402 | // Create a chat referencing the MCP server. |
| 1403 | chat, err := expClient.CreateChat(ctx, codersdk.CreateChatRequest{ |
| 1404 | OrganizationID: firstUser.OrganizationID, |
| 1405 | Content: []codersdk.ChatInputPart{ |
| 1406 | { |
| 1407 | Type: codersdk.ChatInputPartTypeText, |
| 1408 | Text: "hello with mcp server", |
| 1409 | }, |
| 1410 | }, |
| 1411 | MCPServerIDs: []uuid.UUID{mcpConfig.ID}, |
| 1412 | }) |
| 1413 | require.NoError(t, err) |
| 1414 | require.NotEqual(t, uuid.Nil, chat.ID) |
| 1415 | require.Contains(t, chat.MCPServerIDs, mcpConfig.ID) |
| 1416 | |
| 1417 | // Fetch the chat and verify the MCP server IDs persist. |
| 1418 | fetched, err := expClient.GetChat(ctx, chat.ID) |
| 1419 | require.NoError(t, err) |
| 1420 | require.Contains(t, fetched.MCPServerIDs, mcpConfig.ID) |
| 1421 | } |
| 1422 | |
| 1423 | func createChatModelConfigForMCP(t testing.TB, client *codersdk.ExperimentalClient) codersdk.ChatModelConfig { |
| 1424 | t.Helper() |
nothing calls this directly
no test coverage detected