@@ -15,6 +15,7 @@ import type {
1515import { AgentEnvSpecSchema , CREDENTIAL_PROVIDERS , LIFECYCLE_TIMEOUT_MAX , LIFECYCLE_TIMEOUT_MIN } from '../../schema' ;
1616import type { AddAgentOptions as CLIAddAgentOptions } from '../commands/add/types' ;
1717import { validateAddAgentOptions } from '../commands/add/validate' ;
18+ import { parseAndNormalizeHeaders } from '../commands/shared/header-utils' ;
1819import type { VpcOptions } from '../commands/shared/vpc-utils' ;
1920import { VPC_ENDPOINT_WARNING , parseCommaSeparatedList } from '../commands/shared/vpc-utils' ;
2021import { getErrorMessage } from '../errors' ;
@@ -51,6 +52,7 @@ export interface AddAgentOptions extends VpcOptions {
5152 apiKey ?: string ;
5253 memory ?: MemoryOption ;
5354 protocol ?: ProtocolMode ;
55+ requestHeaderAllowlist ?: string [ ] ;
5456 codeLocation ?: string ;
5557 entrypoint ?: string ;
5658 bedrockAgentId ?: string ;
@@ -106,7 +108,10 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
106108 const project = await configIO . readProjectSpec ( ) ;
107109 const existingAgent = project . runtimes . find ( agent => agent . name === options . name ) ;
108110 if ( existingAgent ) {
109- return { success : false , error : `Agent "${ options . name } " already exists in this project.` } ;
111+ return {
112+ success : false ,
113+ error : `Agent "${ options . name } " already exists. To update its configuration, edit agentcore/agentcore.json directly.` ,
114+ } ;
110115 }
111116
112117 if ( options . type === 'import' ) {
@@ -224,6 +229,10 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
224229 . option ( '--custom-claims <json>' , 'Custom claim validations as JSON array (for CUSTOM_JWT) [non-interactive]' )
225230 . option ( '--client-id <id>' , 'OAuth client ID for agent bearer token [non-interactive]' )
226231 . option ( '--client-secret <secret>' , 'OAuth client secret [non-interactive]' )
232+ . option (
233+ '--request-header-allowlist <headers>' ,
234+ 'Comma-separated list of custom header names to allow (auto-prefixed with X-Amzn-Bedrock-AgentCore-Runtime-Custom-) [non-interactive]'
235+ )
227236 . option (
228237 '--idle-timeout <seconds>' ,
229238 `Idle session timeout in seconds (${ LIFECYCLE_TIMEOUT_MIN } -${ LIFECYCLE_TIMEOUT_MAX } ) [non-interactive]`
@@ -258,6 +267,11 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
258267 ? ( JSON . parse ( cliOptions . customClaims ) as CustomClaimValidation [ ] )
259268 : undefined ;
260269
270+ // Parse request header allowlist if provided
271+ const requestHeaderAllowlist = cliOptions . requestHeaderAllowlist
272+ ? parseAndNormalizeHeaders ( cliOptions . requestHeaderAllowlist )
273+ : undefined ;
274+
261275 const result = await this . add ( {
262276 name : cliOptions . name ! ,
263277 type : cliOptions . type ?? 'create' ,
@@ -271,6 +285,7 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
271285 networkMode : cliOptions . networkMode ,
272286 subnets : cliOptions . subnets ,
273287 securityGroups : cliOptions . securityGroups ,
288+ requestHeaderAllowlist,
274289 codeLocation : cliOptions . codeLocation ,
275290 entrypoint : cliOptions . entrypoint ,
276291 bedrockAgentId : cliOptions . agentId ,
@@ -378,6 +393,7 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
378393 customClaims : options . customClaims ,
379394 } ,
380395 } ) ,
396+ requestHeaderAllowlist : options . requestHeaderAllowlist ,
381397 idleRuntimeSessionTimeout : options . idleTimeout ,
382398 maxLifetime : options . maxLifetime ,
383399 } ;
@@ -520,6 +536,9 @@ export class AgentPrimitive extends BasePrimitive<AddAgentOptions, RemovableReso
520536 } ) ,
521537 // MCP uses mcp.run() which is incompatible with the opentelemetry-instrument wrapper
522538 ...( protocol === 'MCP' && { instrumentation : { enableOtel : false } } ) ,
539+ ...( options . requestHeaderAllowlist ?. length && {
540+ requestHeaderAllowlist : options . requestHeaderAllowlist ,
541+ } ) ,
523542 ...( authorizerType && { authorizerType } ) ,
524543 ...( authorizerConfiguration && { authorizerConfiguration } ) ,
525544 ...( lifecycleConfiguration && { lifecycleConfiguration } ) ,
0 commit comments