@@ -240,23 +240,34 @@ testFiles.forEach(testFile => {
240240 const profileLoader = new ProfileLoader ( ) ;
241241 profile = await profileLoader . load ( fullProfilePath ) ;
242242 validateTestAgainstProfile ( testDef , profile ) ;
243- const fullSpecPath = resolveOpenApiSpecPath ( testDir , files , profile ) ;
244243
245- parser = new OpenAPIParser ( ) ;
246- await parser . load ( fullSpecPath ) ;
244+ const isUpstreamProxy =
245+ Array . isArray ( profile . upstream_mcp ) &&
246+ ( profile . upstream_mcp as unknown [ ] ) . length > 0 &&
247+ ! profile . openapi_spec_path ;
247248
248- const baseUrl = `https://mock-api-${ profileName . replace ( / [ ^ a - z A - Z 0 - 9 - ] / g, '-' ) } .com` ;
249- mockEngine = new DynamicMockEngine ( parser , baseUrl ) ;
250- mockEngine . start ( ) ;
249+ server = new MCPServer ( ) ;
251250
252- process . env . MCP4_API_TOKEN = 'test-token' ;
253- process . env . MCP4_API_BASE_URL = baseUrl ;
254- originalAllowPrivateNetwork = process . env . MCP4_SSRF_ALLOW_PRIVATE_NETWORK ;
255- process . env . MCP4_SSRF_ALLOW_PRIVATE_NETWORK = 'true' ;
256- configureProfileEnv ( profile , baseUrl ) ;
251+ if ( isUpstreamProxy ) {
252+ await server . initializeWithoutSpec ( fullProfilePath ) ;
253+ } else {
254+ const fullSpecPath = resolveOpenApiSpecPath ( testDir , files , profile ) ;
257255
258- server = new MCPServer ( ) ;
259- await server . initialize ( fullSpecPath , fullProfilePath ) ;
256+ parser = new OpenAPIParser ( ) ;
257+ await parser . load ( fullSpecPath ) ;
258+
259+ const baseUrl = `https://mock-api-${ profileName . replace ( / [ ^ a - z A - Z 0 - 9 - ] / g, '-' ) } .com` ;
260+ mockEngine = new DynamicMockEngine ( parser , baseUrl ) ;
261+ mockEngine . start ( ) ;
262+
263+ process . env . MCP4_API_TOKEN = 'test-token' ;
264+ process . env . MCP4_API_BASE_URL = baseUrl ;
265+ originalAllowPrivateNetwork = process . env . MCP4_SSRF_ALLOW_PRIVATE_NETWORK ;
266+ process . env . MCP4_SSRF_ALLOW_PRIVATE_NETWORK = 'true' ;
267+ configureProfileEnv ( profile , baseUrl ) ;
268+
269+ await server . initialize ( fullSpecPath , fullProfilePath ) ;
270+ }
260271 } , 30000 ) ;
261272
262273 afterAll ( ( ) => {
@@ -269,6 +280,7 @@ testFiles.forEach(testFile => {
269280 } ) ;
270281
271282 beforeEach ( ( ) => {
283+ if ( ! mockEngine ) return ;
272284 mockEngine . reset ( ) ;
273285 if ( testDef . global_mocks ) {
274286 const context = { ...testDef . variables } ;
@@ -277,6 +289,10 @@ testFiles.forEach(testFile => {
277289 }
278290 } ) ;
279291
292+ it ( 'server initializes successfully' , ( ) => {
293+ expect ( server [ 'profile' ] ) . toBeDefined ( ) ;
294+ } ) ;
295+
280296 testDef . scenarios . forEach ( scenario => {
281297 it ( scenario . name , async ( ) => {
282298 // Prepare context
0 commit comments