@@ -283,6 +283,19 @@ async function executePuts(
283283 results
284284 ) ;
285285 }
286+ } else if ( tier === 2 ) {
287+ const { mcpApis, regularTier2 } = await splitMcpApis (
288+ store ,
289+ config . sourceDir ,
290+ descriptors
291+ ) ;
292+
293+ await publishAndOutput ( client , store , context , config , regularTier2 , results ) ;
294+
295+ if ( mcpApis . length > 0 ) {
296+ logger . debug ( `Publishing ${ mcpApis . length } MCP API resource(s) after regular tier 2 resources` ) ;
297+ await publishAndOutput ( client , store , context , config , mcpApis , results ) ;
298+ }
286299 } else {
287300 // For tiers 3/4, exclude child resources whose parent is being published
288301 // in tier 2 (publishApi/publishProduct handle their children internally).
@@ -421,6 +434,31 @@ async function splitPoolBackends(
421434 return { poolBackends, regularTier1 } ;
422435}
423436
437+ async function splitMcpApis (
438+ store : IArtifactStore ,
439+ sourceDir : string ,
440+ descriptors : ResourceDescriptor [ ]
441+ ) : Promise < { mcpApis : ResourceDescriptor [ ] ; regularTier2 : ResourceDescriptor [ ] } > {
442+ const mcpApis : ResourceDescriptor [ ] = [ ] ;
443+ const regularTier2 : ResourceDescriptor [ ] = [ ] ;
444+
445+ for ( const descriptor of descriptors ) {
446+ if ( descriptor . type === ResourceType . Api ) {
447+ const json = await store . readResource ( sourceDir , descriptor ) ;
448+ const props = json ?. properties as Record < string , unknown > | undefined ;
449+ const mcpTools = props ?. mcpTools ;
450+ if ( Array . isArray ( mcpTools ) && mcpTools . length > 0 ) {
451+ mcpApis . push ( descriptor ) ;
452+ continue ;
453+ }
454+ }
455+
456+ regularTier2 . push ( descriptor ) ;
457+ }
458+
459+ return { mcpApis, regularTier2 } ;
460+ }
461+
424462/**
425463 * Publish a single tier of resources in parallel.
426464 */
0 commit comments