feat(gateway): add Custom JWT inbound auth for MCP gateways#596
Closed
aidandaly24 wants to merge 1 commit into
Closed
feat(gateway): add Custom JWT inbound auth for MCP gateways#596aidandaly24 wants to merge 1 commit into
aidandaly24 wants to merge 1 commit into
Conversation
Add CUSTOM_JWT authorizer support to the gateway creation flow:
- TUI wizard for JWT configuration (discovery URL, audiences, clients,
scopes, custom claim validations with string/string-array match types)
- CLI flags for non-interactive gateway creation with JWT auth
- Schema validation with OIDC discovery URL HTTPS enforcement,
XOR validation for claim match values, and .strict() on config
- Fix gateway output key comment to match Gateway{Name} pattern
(CDK fix in companion agentcore-cdk PR)
00845c0 to
1a7a386
Compare
6cdbf0b to
1a7a386
Compare
This was referenced Mar 23, 2026
Contributor
Author
|
This PR has been split into 3 smaller, independently reviewable PRs:
Plus the existing CDK PR: Merge order: #597 (independent) → #598 (independent) → #599 (rebase onto main after #598 merges) → CDK #93 (independent) Closing this in favor of the split PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Add full Custom JWT inbound authorization support for MCP gateways, including custom claim validations matching the CFN
CustomClaimValidationTypestructure.Summary
--custom-claims <json>,--client-id,--client-secretCLI flags (renaming from--agent-client-id/--agent-client-secret)allowedClientsis no longer required — at least one ofallowedAudience,allowedClients,allowedScopes, orcustomClaimsmust be providedClaimMatchOperatorSchema,ClaimMatchValueSchema,InboundTokenClaimValueTypeSchema,CustomClaimValidationSchemaChanges by Category
Schema
src/schema/schemas/mcp.ts— Custom claims Zod schemas; refactorCustomJwtAuthorizerConfigSchemawith optional fields,.strict(),.superRefine()enforcing at-least-one constraint, HTTPS enforcementsrc/schema/schemas/deployed-state.ts— MakeallowedAudience/allowedClientsoptional; addallowedScopesandcustomClaimsfieldsCLI Flags / Validation
src/cli/commands/add/types.ts— ReplaceagentClientId/agentClientSecretwithclientId/clientSecret; addcustomClaimssrc/cli/commands/add/validate.ts— At-least-one-constraint validation,--custom-claimsJSON parsing, HTTPS check, renamed flagssrc/cli/primitives/GatewayPrimitive.ts— Renamed flags, custom claims JSON parsing, conditional field spreadingTUI Wizard
src/cli/tui/screens/mcp/AddGatewayScreen.tsx— Major rewrite: typedJwtSubStepunion, constraint picker multi-select,CustomClaimsManagercomponent with add/edit/delete,CustomClaimFormtabbed form (Tab cycles, Left/Right cycles selects), HTTPS validation, disable raw Escape exitsrc/cli/tui/screens/mcp/types.ts— UpdatedjwtConfigtype for optional fields and custom claimssrc/cli/tui/screens/mcp/useAddGatewayWizard.ts— UpdatedsetJwtConfigparameter typessrc/cli/tui/hooks/useCreateMcp.ts— PasscustomClaimsdirectly; rename credential fieldssrc/cli/tui/App.tsx— Remove deadPlaceholderScreenroutesrc/cli/tui/screens/PlaceholderScreen.tsx— Deleted (unused)src/cli/tui/screens/index.ts— RemovePlaceholderScreenre-exportTests
src/schema/schemas/__tests__/mcp.test.ts—ClaimMatchValueSchema,CustomClaimValidationSchema, HTTPS, strict, scope-only, all-empty-constraints testssrc/cli/commands/add/__tests__/validate.test.ts— Rewritten JWT validation: at-least-one-constraint, custom claims JSON, renamed flagssrc/cli/commands/add/__tests__/add-gateway.test.ts— Updated flag namessrc/cli/primitives/__tests__/GatewayPrimitive.test.ts—customClaims pipelinetest suite (4 tests)src/cli/tui/screens/mcp/__tests__/AddGatewayJwtConfig.test.tsx— New 652-line test: 7 groups covering full JWT wizard TUI interactionssrc/cli/tui/screens/mcp/__tests__/finishJwtConfig.test.ts— New: validates TUI data mapping produces shapes accepted byCustomJwtAuthorizerConfigSchemasrc/cli/tui/screens/mcp/__tests__/useAddGatewayWizard.test.tsx— Extended wizard hook tests for JWT flow, navigation, targetsinteg-tests/tui/add-gateway-jwt.test.ts— New 415-line TUI integration test: full JWT wizard pathinteg-tests/tui/setup.ts— New TUI integration test setupBug Fix
src/cli/cloudformation/outputs.ts— Updated comment documenting hash-suffixed output key pattern (companion CDK PR fixes the actual CfnOutput scope)Screenshots
TUI Custom JWT Gateway Wizard Flow (13 screenshots)
Main Menu
Auth Type Selection
Discovery URL Input
Allowed Audience Input
Allowed Clients Input
Allowed Scopes Input
Custom Claims Prompt
Custom Claim Form — Claim Name
Custom Claim Form — Value Type
Custom Claim Form — Operator
Custom Claim Form — Match Value
Claims List
Confirm Review
Related Issue
N/A — internal feature development
Documentation PR
N/A
Companion PR
CDK constructs: https://github.com/aws/agentcore-l3-cdk-constructs/pull/93
Type of Change
Testing
How have you tested the change?
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsdeployed-state.jsonpopulates correctlyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.