feat: set gateway env vars in agentcore dev for local testing#428
Open
aidandaly24 wants to merge 1 commit intoaws:feat/gateway-integrationfrom
Open
feat: set gateway env vars in agentcore dev for local testing#428aidandaly24 wants to merge 1 commit intoaws:feat/gateway-integrationfrom
aidandaly24 wants to merge 1 commit intoaws:feat/gateway-integrationfrom
Conversation
33bad00 to
5a7265a
Compare
5a7265a to
53c561c
Compare
53c561c to
b00e92c
Compare
b00e92c to
41e0411
Compare
Read deployed-state.json for gateway URLs and mcp.json for auth types,
then set AGENTCORE_GATEWAY_{NAME}_URL and AGENTCORE_GATEWAY_{NAME}_AUTH_TYPE
env vars when running agentcore dev locally.
- New gateway-env.ts helper iterates all deployment targets
- Integrated in both CLI dev command and TUI dev hook
- .env.local values take precedence over gateway env vars
- Graceful fallback when no deployed state exists
- Fixed parseGatewayOutputs to parse Id, Arn, and Url outputs separately
- Added gatewayUrl field to deployed-state schema (optional, backward compat)
41e0411 to
8e34e2f
Compare
jesseturner21
approved these changes
Feb 26, 2026
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
Enable
agentcore devto connect to deployed gateways by setting gateway environment variables in the local agent runtime.When agents are deployed, CDK sets
AGENTCORE_GATEWAY_{NAME}_URLandAGENTCORE_GATEWAY_{NAME}_AUTH_TYPEenv vars automatically. For local development withagentcore dev, these env vars were missing — agents would log "gateway URL not set" warnings and run without gateway tools.This PR reads gateway URLs from
deployed-state.json(populated duringagentcore deploy) and auth types frommcp.json, then sets the corresponding env vars when starting the local dev server. Values from.env.localtake precedence, allowing manual overrides.Changes:
gateway-env.tshelper that reads deployed state and builds gateway env varsparseGatewayOutputsfixed to parse all three CDK output types (Id, Arn, Url) separately instead of only matching URL outputsGatewayDeployedStateSchemaextended with optionalgatewayUrlfield (backward compatible)Companion CDK PR adds the gateway URL to CloudFormation outputs.
Related Issue
Part of the MCP Gateway Phase 1 integration (gateway-integration branch). Task 16b.
Type of Change
Testing
npm run test:unitandnpm run test:integnpm run typechecknpm run lintsrc/assets/, I rannpm run test:update-snapshotsand committed the updated snapshotsChecklist