@@ -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,17 @@ 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 . object ( {
65+ type : OutboundAuthTypeSchema . default ( 'NONE' ) ,
66+ credentialName : z . string ( ) . min ( 1 ) . optional ( ) ,
67+ scopes : z . array ( z . string ( ) ) . optional ( ) ,
68+ } ) . strict ( ) ;
69+
70+ export type OutboundAuth = z . infer < typeof OutboundAuthSchema > ;
71+
6072export const McpImplLanguageSchema = z . enum ( [ 'TypeScript' , 'Python' ] ) ;
6173export type McpImplementationLanguage = z . infer < typeof McpImplLanguageSchema > ;
6274
@@ -262,10 +274,37 @@ export const AgentCoreGatewayTargetSchema = z
262274 . object ( {
263275 name : z . string ( ) . min ( 1 ) ,
264276 targetType : GatewayTargetTypeSchema ,
265- toolDefinitions : z . array ( ToolDefinitionSchema ) . min ( 1 ) ,
277+ /** Tool definitions. Required for Lambda targets. Optional for MCP Server (discovered via tools/list). */
278+ toolDefinitions : z . array ( ToolDefinitionSchema ) . optional ( ) ,
279+ /** Compute configuration. Required for Lambda/Runtime scaffold targets. */
266280 compute : ToolComputeConfigSchema . optional ( ) ,
281+ /** MCP Server endpoint URL. Required for external MCP Server targets. */
282+ endpoint : z . string ( ) . url ( ) . optional ( ) ,
283+ /** Outbound auth configuration for the target. */
284+ outboundAuth : OutboundAuthSchema . optional ( ) ,
267285 } )
268- . strict ( ) ;
286+ . strict ( )
287+ . refine (
288+ data => {
289+ // External MCP Server: needs endpoint, no compute
290+ if ( data . targetType === 'mcpServer' && ! data . compute && ! data . endpoint ) {
291+ return false ;
292+ }
293+ // Lambda target: needs compute and tool definitions
294+ if ( data . targetType === 'lambda' ) {
295+ if ( ! data . compute ) return false ;
296+ if ( ! data . toolDefinitions || data . toolDefinitions . length === 0 ) return false ;
297+ }
298+ // Outbound auth with credential needs a credential name
299+ if ( data . outboundAuth && data . outboundAuth . type !== 'NONE' && ! data . outboundAuth . credentialName ) {
300+ return false ;
301+ }
302+ return true ;
303+ } ,
304+ {
305+ message : '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.' ,
306+ }
307+ ) ;
269308
270309export type AgentCoreGatewayTarget = z . infer < typeof AgentCoreGatewayTargetSchema > ;
271310
0 commit comments