@@ -10,43 +10,76 @@ import {
1010import logger from "./logger.js" ;
1111
1212async function main ( ) : Promise < void > {
13+ logger . info ( `Starting e2e test with LOG_LEVEL=${ process . env . LOG_LEVEL || 'info' } ` ) ;
14+ logger . info ( `Node version: ${ process . version } ` ) ;
15+
1316 const config = new Configuration ( ) ;
1417 const serverConfig = Configuration . loadConfig ( "./servers_config.json" ) ;
1518
1619 const mcpClients = [ ] ;
1720
21+ logger . info ( "Initializing MCP clients..." ) ;
1822 for ( const [ name , srvConfig ] of Object . entries ( serverConfig . stdioServers || { } ) ) {
19- mcpClients . push ( await createStdioClient ( name , srvConfig ) ) ;
23+ try {
24+ mcpClients . push ( await createStdioClient ( name , srvConfig ) ) ;
25+ } catch ( error ) {
26+ logger . error ( `Failed to initialize stdio server ${ name } :` , error ) ;
27+ throw error ;
28+ }
2029 }
2130
2231 for ( const [ name , srvConfig ] of Object . entries ( serverConfig . lambdaFunctionServers || { } ) ) {
23- mcpClients . push ( await createLambdaFunctionClient ( name , srvConfig ) ) ;
32+ try {
33+ mcpClients . push ( await createLambdaFunctionClient ( name , srvConfig ) ) ;
34+ } catch ( error ) {
35+ logger . error ( `Failed to initialize lambda function server ${ name } :` , error ) ;
36+ throw error ;
37+ }
2438 }
2539
2640 for ( const [ name , srvConfig ] of Object . entries ( serverConfig . lambdaFunctionUrls || { } ) ) {
27- mcpClients . push ( await createLambdaFunctionUrlClient ( name , srvConfig ) ) ;
41+ try {
42+ mcpClients . push ( await createLambdaFunctionUrlClient ( name , srvConfig ) ) ;
43+ } catch ( error ) {
44+ logger . error ( `Failed to initialize lambda function URL server ${ name } :` , error ) ;
45+ throw error ;
46+ }
2847 }
2948
3049 for ( const [ name , srvConfig ] of Object . entries ( serverConfig . oAuthServers || { } ) ) {
31- mcpClients . push ( await createAutomatedOAuthClient ( name , srvConfig ) ) ;
50+ try {
51+ mcpClients . push ( await createAutomatedOAuthClient ( name , srvConfig ) ) ;
52+ } catch ( error ) {
53+ logger . error ( `Failed to initialize OAuth server ${ name } :` , error ) ;
54+ throw error ;
55+ }
3256 }
3357
58+ logger . info ( `Successfully initialized ${ mcpClients . length } MCP clients` ) ;
59+
3460 const userUtterances = Configuration . loadConfig ( "../test_questions.json" ) as string [ ] ;
61+ logger . info ( `Loaded ${ userUtterances . length } test questions` ) ;
3562
63+ logger . info ( "Initializing Bedrock model..." ) ;
3664 const model = new BedrockModel ( {
3765 region : config . bedrockClient . config . region as string ,
3866 modelId : config . modelId ,
3967 } ) ;
68+ logger . info ( `Using model: ${ config . modelId } in region: ${ config . bedrockClient . config . region } ` ) ;
4069
70+ logger . info ( "Creating agent..." ) ;
4171 const agent = new Agent ( {
4272 model,
4373 tools : mcpClients ,
4474 systemPrompt : "You are a helpful assistant." ,
4575 } ) ;
76+ logger . info ( "Agent created successfully" ) ;
4677
4778 const chatSession = new ChatSession ( agent , userUtterances , mcpClients ) ;
4879
80+ logger . info ( "Starting chat session..." ) ;
4981 await chatSession . start ( ) ;
82+ logger . info ( "Chat session completed successfully" ) ;
5083}
5184
5285process . on ( "unhandledRejection" , ( reason , promise ) => {
@@ -56,6 +89,8 @@ process.on("unhandledRejection", (reason, promise) => {
5689
5790main ( ) . catch ( ( error ) => {
5891 logger . error ( "Error in main:" , error ) ;
92+ if ( error . stack ) {
93+ logger . error ( "Stack trace:" , error . stack ) ;
94+ }
5995 process . exit ( 1 ) ;
6096} ) ;
61-
0 commit comments