(t *testing.T)
| 783 | } |
| 784 | |
| 785 | func TestExploreChatUsesPersistedMCPSnapshot(t *testing.T) { |
| 786 | t.Parallel() |
| 787 | |
| 788 | db, ps := dbtestutil.NewDB(t) |
| 789 | ctx := testutil.Context(t, testutil.WaitLong) |
| 790 | |
| 791 | externalMCP := mcpserver.NewMCPServer("external-snapshot-mcp", "1.0.0") |
| 792 | externalMCP.AddTools(mcpserver.ServerTool{ |
| 793 | Tool: mcpgo.NewTool("echo", |
| 794 | mcpgo.WithDescription("Echoes the input"), |
| 795 | mcpgo.WithString("input", |
| 796 | mcpgo.Description("The input string"), |
| 797 | mcpgo.Required(), |
| 798 | ), |
| 799 | ), |
| 800 | Handler: func(_ context.Context, req mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) { |
| 801 | input, _ := req.GetArguments()["input"].(string) |
| 802 | return mcpgo.NewToolResultText("echo: " + input), nil |
| 803 | }, |
| 804 | }) |
| 805 | externalMCPServer := httptest.NewServer(mcpserver.NewStreamableHTTPServer(externalMCP)) |
| 806 | defer externalMCPServer.Close() |
| 807 | |
| 808 | secondMCP := mcpserver.NewMCPServer("second-mcp", "1.0.0") |
| 809 | secondMCP.AddTools(mcpserver.ServerTool{ |
| 810 | Tool: mcpgo.NewTool("echo", |
| 811 | mcpgo.WithDescription("Echoes the input"), |
| 812 | mcpgo.WithString("input", |
| 813 | mcpgo.Description("The input string"), |
| 814 | mcpgo.Required(), |
| 815 | ), |
| 816 | ), |
| 817 | Handler: func(_ context.Context, req mcpgo.CallToolRequest) (*mcpgo.CallToolResult, error) { |
| 818 | input, _ := req.GetArguments()["input"].(string) |
| 819 | return mcpgo.NewToolResultText("echo: " + input), nil |
| 820 | }, |
| 821 | }) |
| 822 | secondMCPServer := httptest.NewServer(mcpserver.NewStreamableHTTPServer(secondMCP)) |
| 823 | defer secondMCPServer.Close() |
| 824 | |
| 825 | var ( |
| 826 | requestsMu sync.Mutex |
| 827 | requests []recordedOpenAIRequest |
| 828 | ) |
| 829 | openAIURL := chattest.NewOpenAI(t, func(req *chattest.OpenAIRequest) chattest.OpenAIResponse { |
| 830 | if !req.Stream { |
| 831 | return chattest.OpenAINonStreamingResponse("ok") |
| 832 | } |
| 833 | |
| 834 | requestsMu.Lock() |
| 835 | requests = append(requests, recordOpenAIRequest(req)) |
| 836 | requestsMu.Unlock() |
| 837 | |
| 838 | return chattest.OpenAIStreamingResponse( |
| 839 | chattest.OpenAITextChunks("done")..., |
| 840 | ) |
| 841 | }) |
| 842 |
nothing calls this directly
no test coverage detected