@@ -15,7 +15,7 @@ export type GatewayTargetType = z.infer<typeof GatewayTargetTypeSchema>;
1515// Gateway Authorization Schemas
1616// ============================================================================
1717
18- export const GatewayAuthorizerTypeSchema = z . enum ( [ 'NONE' , 'CUSTOM_JWT' ] ) ;
18+ export const GatewayAuthorizerTypeSchema = z . enum ( [ 'NONE' , 'AWS_IAM' , ' CUSTOM_JWT'] ) ;
1919export type GatewayAuthorizerType = z . infer < typeof GatewayAuthorizerTypeSchema > ;
2020
2121/** OIDC well-known configuration endpoint suffix (per OpenID Connect Discovery 1.0 spec) */
@@ -44,6 +44,7 @@ export const CustomJwtAuthorizerConfigSchema = z.object({
4444 allowedAudience : z . array ( z . string ( ) . min ( 1 ) ) ,
4545 /** List of allowed client IDs */
4646 allowedClients : z . array ( z . string ( ) . min ( 1 ) ) . min ( 1 ) ,
47+ allowedScopes : z . array ( z . string ( ) . min ( 1 ) ) . optional ( ) ,
4748} ) ;
4849
4950export type CustomJwtAuthorizerConfig = z . infer < typeof CustomJwtAuthorizerConfigSchema > ;
@@ -57,6 +58,19 @@ export const GatewayAuthorizerConfigSchema = z.object({
5758
5859export type GatewayAuthorizerConfig = z . infer < typeof GatewayAuthorizerConfigSchema > ;
5960
61+ export const OutboundAuthTypeSchema = z . enum ( [ 'OAUTH' , 'API_KEY' , 'NONE' ] ) ;
62+ export type OutboundAuthType = z . infer < typeof OutboundAuthTypeSchema > ;
63+
64+ export const OutboundAuthSchema = z
65+ . object ( {
66+ type : OutboundAuthTypeSchema . default ( 'NONE' ) ,
67+ credentialName : z . string ( ) . min ( 1 ) . optional ( ) ,
68+ scopes : z . array ( z . string ( ) ) . optional ( ) ,
69+ } )
70+ . strict ( ) ;
71+
72+ export type OutboundAuth = z . infer < typeof OutboundAuthSchema > ;
73+
6074export const McpImplLanguageSchema = z . enum ( [ 'TypeScript' , 'Python' ] ) ;
6175export type McpImplementationLanguage = z . infer < typeof McpImplLanguageSchema > ;
6276
@@ -262,10 +276,38 @@ export const AgentCoreGatewayTargetSchema = z
262276 . object ( {
263277 name : z . string ( ) . min ( 1 ) ,
264278 targetType : GatewayTargetTypeSchema ,
265- toolDefinitions : z . array ( ToolDefinitionSchema ) . min ( 1 ) ,
279+ /** Tool definitions. Required for Lambda targets. Optional for MCP Server (discovered via tools/list). */
280+ toolDefinitions : z . array ( ToolDefinitionSchema ) . optional ( ) ,
281+ /** Compute configuration. Required for Lambda/Runtime scaffold targets. */
266282 compute : ToolComputeConfigSchema . optional ( ) ,
283+ /** MCP Server endpoint URL. Required for external MCP Server targets. */
284+ endpoint : z . string ( ) . url ( ) . optional ( ) ,
285+ /** Outbound auth configuration for the target. */
286+ outboundAuth : OutboundAuthSchema . optional ( ) ,
267287 } )
268- . strict ( ) ;
288+ . strict ( )
289+ . refine (
290+ data => {
291+ // External MCP Server: needs endpoint, no compute
292+ if ( data . targetType === 'mcpServer' && ! data . compute && ! data . endpoint ) {
293+ return false ;
294+ }
295+ // Lambda target: needs compute and tool definitions
296+ if ( data . targetType === 'lambda' ) {
297+ if ( ! data . compute ) return false ;
298+ if ( ! data . toolDefinitions || data . toolDefinitions . length === 0 ) return false ;
299+ }
300+ // Outbound auth with credential needs a credential name
301+ if ( data . outboundAuth && data . outboundAuth . type !== 'NONE' && ! data . outboundAuth . credentialName ) {
302+ return false ;
303+ }
304+ return true ;
305+ } ,
306+ {
307+ message :
308+ 'Invalid target configuration. MCP Server targets need an endpoint or compute. Lambda targets need compute and tool definitions. OAuth/API_KEY auth needs a credential name.' ,
309+ }
310+ ) ;
269311
270312export type AgentCoreGatewayTarget = z . infer < typeof AgentCoreGatewayTargetSchema > ;
271313
0 commit comments