The dev command runs your agent locally for testing before deployment.
# Start dev server (auto-selects agent if only one)
agentcore dev
# Specify agent
agentcore dev --agent MyAgent
# Custom port
agentcore dev --port 3000
# Non-interactive mode (logs to stdout)
agentcore dev --logsWith the dev server running, open another terminal:
# Interactive chat
agentcore invoke
# Single prompt
agentcore invoke "What can you do?"
# With streaming
agentcore invoke "Tell me a story" --stream
# Direct invoke to running server
agentcore dev --invoke "Hello" --streamThe dev server automatically:
- Creates
.venvif it doesn't exist - Runs
uv syncto install dependencies frompyproject.toml - Starts uvicorn with your agent
For non-Bedrock providers, add keys to agentcore/.env.local:
AGENTCORE_CREDENTIAL_{projectName}OPENAI=sk-...
AGENTCORE_CREDENTIAL_{projectName}ANTHROPIC=sk-ant-...
AGENTCORE_CREDENTIAL_{projectName}GEMINI=...Logs are written to agentcore/.cli/logs/:
agentcore/.cli/logs/
├── dev/ # Dev server logs
└── invoke/ # Invocation logs with request/response
# Dev server with stdout logging
agentcore dev --logsPort already in use:
agentcore dev --port 8081Missing dependencies:
cd app/MyAgent
uv syncThe dev server watches for file changes and automatically reloads. Edit your agent code and the changes take effect immediately.
For container agents, the dev server builds a Docker image and runs it with your source directory mounted as a volume.
Changes to your code are picked up by uvicorn's --reload inside the container — no image rebuild needed.
See Container Builds for full details on container development.
| Aspect | Local Dev | Deployed |
|---|---|---|
| API Keys | .env.local |
AgentCore Identity service |
| Memory | Not available | AgentCore Memory service |
| Gateways | Env vars from deployed state | CDK-injected env vars |
| Networking | localhost | Public |
Memory requires deployment to test fully. For local testing, you can mock these dependencies in your agent code.
When you have deployed gateways, agentcore dev automatically injects gateway environment variables into your local
agent process. This lets your local agent connect to real deployed gateways during development.
The dev server reads deployed-state.json and mcp.json to generate:
AGENTCORE_GATEWAY_{NAME}_URL=https://{gateway-id}.gateway.agentcore.{region}.amazonaws.com
AGENTCORE_GATEWAY_{NAME}_AUTH_TYPE=NONE|AWS_IAM|CUSTOM_JWTThe gateway name is uppercased with hyphens replaced by underscores. For example, a gateway named my-gateway produces:
AGENTCORE_GATEWAY_MY_GATEWAY_URL=https://...
AGENTCORE_GATEWAY_MY_GATEWAY_AUTH_TYPE=NONEGateway env vars require a prior deployment — the dev server reads the gateway URLs from deployed-state.json, which is
populated by agentcore deploy. If you haven't deployed yet, no gateway env vars will be set.
# 1. Add a gateway and target
agentcore add gateway --name my-gateway
agentcore add gateway-target --name my-tools --type mcp-server \
--endpoint https://mcp.example.com/mcp --gateway my-gateway
# 2. Deploy to create the gateway
agentcore deploy -y
# 3. Run locally — gateway env vars are injected automatically
agentcore devYour agent code reads these env vars to connect to the gateway. The agent templates generated by the CLI already include this wiring.