feat: set gateway env vars in agentcore dev for local testing#428
Open
aidandaly24 wants to merge 6 commits intoaws:feat/gateway-integrationfrom
Open
feat: set gateway env vars in agentcore dev for local testing#428aidandaly24 wants to merge 6 commits intoaws:feat/gateway-integrationfrom
aidandaly24 wants to merge 6 commits intoaws:feat/gateway-integrationfrom
Conversation
33bad00 to
5a7265a
Compare
5a7265a to
53c561c
Compare
53c561c to
b00e92c
Compare
Add SigV4 authentication to MCP client templates so agents can
authenticate with AWS_IAM gateways. Each framework's client.py
uses Handlebars conditionals to include auth when gateways exist.
SigV4HTTPXAuth class signs HTTP requests using botocore SigV4Auth,
passed to the MCP client via httpx.AsyncClient. Templates read
gateway URLs from AGENTCORE_GATEWAY_{NAME}_URL env vars and handle
missing vars gracefully (warn, don't crash).
Updated all 5 frameworks: Strands, LangChain, OpenAI Agents,
Google ADK, AutoGen. Schema mapper reads mcp.json to populate
gateway config for template rendering. All gateways are auto-
included when creating an agent.
Replace single-gateway [0] indexing with {{#each gatewayProviders}}
loops. Each gateway gets its own client function (Strands) or entry
in the servers dict (LangChain/OpenAI/AutoGen/ADK).
Add snakeCase Handlebars helper for gateway function names.
Add gatewayAuthTypes array for conditional SigV4 imports.
Fix @index parse error by using plain variable names.
All 5 framework main.py files now use Handlebars conditionals to import the correct MCP client function based on hasGateway flag. Fix snakeCase helper to handle all special characters.
…way support Replace custom SigV4HTTPXAuth class with official mcp-proxy-for-aws package: - Strands: aws_iam_streamablehttp_client factory pattern - LangChain: SigV4HTTPXAuth via auth param in MultiServerMCPClient config - OpenAI Agents: SigV4HTTPXAuth via httpx_client_factory param - Google ADK: SigV4HTTPXAuth via httpx_client_factory in StreamableHTTPConnectionParams Revert AutoGen to original upstream — SDK doesn't support custom httpx auth (no httpx_client_factory param).
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)
b00e92c to
41e0411
Compare
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