Skip to content

feat: set gateway env vars in agentcore dev for local testing#428

Open
aidandaly24 wants to merge 1 commit intoaws:feat/gateway-integrationfrom
aidandaly24:feat/batch-5-invoke-gateway-env
Open

feat: set gateway env vars in agentcore dev for local testing#428
aidandaly24 wants to merge 1 commit intoaws:feat/gateway-integrationfrom
aidandaly24:feat/batch-5-invoke-gateway-env

Conversation

@aidandaly24
Copy link
Contributor

Description

Enable agentcore dev to connect to deployed gateways by setting gateway environment variables in the local agent runtime.

When agents are deployed, CDK sets AGENTCORE_GATEWAY_{NAME}_URL and AGENTCORE_GATEWAY_{NAME}_AUTH_TYPE env vars automatically. For local development with agentcore 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 during agentcore deploy) and auth types from mcp.json, then sets the corresponding env vars when starting the local dev server. Values from .env.local take precedence, allowing manual overrides.

Changes:

  • New gateway-env.ts helper that reads deployed state and builds gateway env vars
  • Integrated in both CLI dev command and TUI dev hook
  • parseGatewayOutputs fixed to parse all three CDK output types (Id, Arn, Url) separately instead of only matching URL outputs
  • GatewayDeployedStateSchema extended with optional gatewayUrl field (backward compatible)
  • Graceful fallback when deployed state doesn't exist (agent runs without gateway tools)

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

  • New feature

Testing

  • I ran npm run test:unit and npm run test:integ
  • I ran npm run typecheck
  • I ran npm run lint
  • If I modified src/assets/, I ran npm run test:update-snapshots and committed the updated snapshots

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

@github-actions github-actions bot added the size/l PR size: L label Feb 24, 2026
@aidandaly24 aidandaly24 force-pushed the feat/batch-5-invoke-gateway-env branch from 33bad00 to 5a7265a Compare February 24, 2026 22:54
@github-actions github-actions bot added size/l PR size: L and removed size/l PR size: L labels Feb 24, 2026
@aidandaly24 aidandaly24 force-pushed the feat/batch-5-invoke-gateway-env branch from 5a7265a to 53c561c Compare February 24, 2026 22:59
@github-actions github-actions bot added size/l PR size: L and removed size/l PR size: L labels Feb 24, 2026
@aidandaly24 aidandaly24 force-pushed the feat/batch-5-invoke-gateway-env branch from 53c561c to b00e92c Compare February 25, 2026 03:13
@github-actions github-actions bot added size/m PR size: M and removed size/l PR size: L labels Feb 25, 2026
@aidandaly24 aidandaly24 force-pushed the feat/batch-5-invoke-gateway-env branch from b00e92c to 41e0411 Compare February 25, 2026 05:59
@github-actions github-actions bot added size/m PR size: M and removed size/m PR size: M labels Feb 25, 2026
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)
@aidandaly24 aidandaly24 force-pushed the feat/batch-5-invoke-gateway-env branch from 41e0411 to 8e34e2f Compare February 25, 2026 23:28
@github-actions github-actions bot added size/s PR size: S and removed size/m PR size: M labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s PR size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants