AWS Builder Center
How to Keep AI Coding Agents Under Control on AWS with the AWS Agent Toolkit

How to Keep AI Coding Agents Under Control on AWS with the AWS Agent Toolkit

This post explains how the AWS Agent Toolkit helps teams make AI coding agents safer and more reliable by combining real-time AWS knowledge, curated Skills, IAM-based guardrails, and built-in observability. It also includes a hands-on Kiro demo showing how an agent can deploy an AWS Lambda function while adapting to real-world execution issues.

Introduction

AI coding agents are changing the way we build on AWS. Tools like Kiro, Claude Code, Cursor, and Codex can scaffold infrastructure, write application code, and even troubleshoot deployments, all from a natural language prompt. For developers, this feels like a superpower. For engineering leads and platform teams, it raises an immediate question: how do you make sure these agents don't break things?
The answer isn't to slow agents down. It's to give them the right knowledge, the right guardrails, and the right observability hooks, so they move fast and stay safe. That's exactly what the AWS Agent Toolkit is designed to do.
In this post, we'll walk through why AI coding agents struggle with AWS today, how the Agent Toolkit addresses those gaps, and, critically, how to govern agents at enterprise scale using IAM, OAuth 2.1, CloudWatch, and CloudTrail.

The Problem — Why AI Coding Agents Struggle with AWS Today

Let's be honest about the current state of AI coding agents on AWS. They're impressive, but they have real limitations that become very visible at scale.
  • The knowledge cutoff problem is the most obvious one. The large language models powering these agents were trained on data that is months, sometimes years, old. AWS launches hundreds of new features every year. That means your agent might confidently recommend a suboptimal architecture, reference a deprecated API, or simply not know that a better service for your use case was launched six months ago. It's not a hallucination in the traditional sense, the model is reasoning correctly from stale information.
  • The complexity cliff is the second problem. Agents handle simple tasks well. Ask one to create an S3 bucket, and it'll do it correctly. Ask it to set up a serverless data pipeline with least-privilege IAM, proper VPC configuration, error handling, and a CloudWatch dashboard, and it starts improvising. It cobbles together patterns from general training data, makes assumptions, retries failed operations, and sometimes ends up in a loop that costs you money and time.
  • The security gap is the third and most critical problem for enterprise teams. Without guardrails, an AI agent operates with whatever permissions are attached to your credentials. A misconfigured IAM policy or an overly permissive role means the agent can do things you didn't intend, create public S3 buckets, modify security groups, or run up unexpected costs. There's also no visibility: without proper logging, you can't tell what the agent actually did, which makes debugging and compliance reporting nearly impossible.
These aren't edge cases. They're the everyday reality of using AI coding agents on AWS without a proper framework around them. The AWS Agent Toolkit was built specifically to close these gaps.

Introducing the AWS Agent Toolkit — What It Is and How It Works

The AWS Agent Toolkit is a framework that gives AI coding agents the tools, knowledge, and guardrails they need to build, deploy, and manage applications on AWS. It doesn't replace the agents you already use — it plugs into them. Whether your team uses Kiro, Claude Code, Cursor, Codex, or any other MCP-compatible agent, the toolkit works the same way.
At a high level, the toolkit operates on three principles:
  • Structured guidance over improvisation. Instead of letting the agent reason from general training data, the toolkit provides curated Skills — step-by-step procedures for specific AWS workflows. The agent follows tested, opinionated paths rather than inventing its own.
  • Current knowledge on demand. The toolkit gives agents real-time access to AWS documentation, API references, and regional availability data. When an agent needs to know whether a feature is available in  ap-southeast-1 , it queries the toolkit rather than guessing.
  • Authenticated, auditable execution. All API calls made through the toolkit are signed with your IAM credentials, logged by CloudTrail, and metered by CloudWatch. You always know who did what, when, and with which identity.
The architectural backbone of all this is the AWS MCP Server — a managed server that implements the Model Context Protocol (MCP), an open standard for connecting AI agents to external tools and data sources. Your agent connects to this server, discovers available capabilities, and uses them to complete tasks. One endpoint. Full observability. No custom integration work.

The Four Components — MCP Server, Skills, Plugins, Rules Files

The AWS Agent Toolkit is made up of four components that work together. Understanding each one is key to using the toolkit effectively.


1. AWS MCP Server

The AWS MCP Server is the core runtime component. It's a managed, stateless proxy that sits between your AI agent and AWS services. When your agent wants to call an AWS API, it sends a request to the MCP Server, which authenticates it using your IAM credentials and forwards it to the target service.
The server exposes a set of tools that agents can discover and call:
  •  aws___call_aws  — Execute any of the 15,000+ AWS API calls with proper authentication and error handling
  •  aws___run_script  — Run Python code in a sandboxed environment with AWS access, useful for multi-step workflows and parallel operations
  •  aws___search_documentation  — Search across all AWS docs, API references, and best practice guides in real time
  •  aws___retrieve_skill  — Load a specific curated Skill for the current task
  •  aws___get_regional_availability  — Check whether a service or feature is available in a given region
  •  aws___list_regions  — Get the current list of all AWS regions
  •  aws___get_presigned_url  — Generate pre-signed S3 URLs for file operations
  •  aws___get_tasks  — Poll the status of long-running operations
Two things stand out here. First, the server automatically injects two IAM condition context keys —  aws:ViaAWSMCPService  and  aws:CalledViaAWSMCP  — into every request it forwards. This lets you write IAM policies that treat MCP-initiated calls differently from direct API calls, which is powerful for governance. Second, the server publishes CloudWatch metrics and logs all activity to CloudTrail. Observability is not an afterthought: it's built in.

2. Skills

Skills are curated packages of instructions, code scripts, and reference materials for specific AWS workflows. Think of them as SOPs (Standard Operating Procedures) for AI agents.
Where a general-purpose LLM would improvise a deployment workflow from training data, an agent using Skills follows a proven, tested procedure. Skills cover things like:
  • Choosing the right compute service for a workload
  • Configuring least-privilege IAM policies for common architectures
  • Setting up serverless APIs with API Gateway and Lambda
  • Deploying containerized applications on ECS or EKS
  • Building data pipelines with Glue, Athena, and S3
Skills are loaded on demand — the agent discovers and retrieves only the Skills relevant to the current task. This keeps the context window lean and focused. You can install Skills globally via the AWS CLI or get them bundled inside a Plugin.
There are also specialized Skill bundles available as optional add-ons:
  •  aws-agents  — For building AI agents with API Gateway and Amazon Bedrock AgentCore
  •  aws-data-analytics  — For data lake, ETL, and analytics workflows
  •  aws-agents-for-devsecops  — For incident investigation, code security scanning, and penetration testing

3. Plugins

Plugins are single-install packages that bundle the MCP Server configuration and a curated set of Skills together. Instead of manually configuring the MCP endpoint and installing Skills one by one, you install a plugin and your agent is immediately ready to work with AWS.
For Claude Code:
/plugin install aws-core@claude-plugins-official
/reload-plugins
For Codex:
codex plugin marketplace add aws/agent-toolkit-for-aws
Kiro connects to the AWS MCP Server directly and doesn't require a plugin: you simply add the MCP Server to your  mcp.json  configuration.
Plugins are open source and published in the official AWS GitHub repository, which means you can inspect exactly what's being installed before you deploy it to your team.

4. Rules Files

Rules files are project-level configuration files that provide persistent instructions to your agent across every session. Most AI coding agents support some form of rules file (Cursor has  .cursorrules , Claude Code has  CLAUDE.md , Kiro has its own format).
The Agent Toolkit ships a recommended rules file that tells your agent how to work with AWS effectively:
  • Always use the MCP Server for API calls rather than invoking the AWS CLI directly
  • Search for available Skills before starting a new task
  • Prefer infrastructure-as-code (CDK or CloudFormation) over manual resource creation
  • Follow least-privilege IAM patterns when creating roles and policies
Rules files operate at the project level, which means different projects can have different constraints. A production project might have stricter rules than a development sandbox. This is a simple but effective governance mechanism that costs nothing to implement.

Security & Authentication — OAuth 2.1, SigV4, IAM Guardrails

This is where the AWS Agent Toolkit becomes genuinely enterprise-grade. Let's go through the security model layer by layer.

Authentication: Two Paths, One Decision

The toolkit supports two authentication methods. Choosing the right one for your context matters.
OAuth 2.1 (the simple path) is the right choice for individual developers, teams using web-based MCP clients, or anyone who wants to get started without managing local proxy software. With OAuth, your MCP client opens a browser to AWS Sign-in, you authenticate with your existing credentials, and short-lived tokens are issued automatically. Access tokens are valid for 1 hour and are refreshed silently for up to 12 hours. No credential files. No local proxy. No  uvx .
# Claude Code — OAuth setup
claude mcp add aws-mcp https://aws-mcp.us-east-1.api.aws/mcp --transport http
SigV4 (the advanced path) is the right choice for teams that need multi-account switching, read-only mode enforcement, or fine-grained regional control. SigV4 uses the MCP Proxy for AWS running locally, signing requests with your AWS CLI credentials before forwarding them to the server.
{
"mcpServers": {
"aws-mcp": {
"command": "uvx",
"args": ["mcp-proxy-for-aws==1.6.3", "https://aws-mcp.us-east-1.api.aws/mcp"],
"env": {
"AWS_MCP_PROXY_PROFILES": "data_reply"
}
}
}
}
The multi-profile feature is particularly useful for platform teams managing multiple environments. You can configure the proxy with distinct profiles at startup, and the agent can route individual API calls through different credentials — dev for scaffolding, prod-readonly for inspection, staging for testing — all within the same session, without restarting.
Scenario
Recommended Method
Individual developer, single account
OAuth 2.1
Web-based MCP client
OAuth 2.1
Multi-account workflows
SigV4
Read-only enforcement
SigV4
Automated / headless agent
OAuth 2.1 (client credentials flow)
Enterprise with strict proxy policies
SigV4

IAM Guardrails: The MCP Condition Keys

Here's one of the most powerful — and underappreciated — features of the toolkit. Every request that flows through the AWS MCP Server is tagged with two IAM condition context keys:
  •  aws:ViaAWSMCPService  (Boolean) —  true  for any request passing through an AWS-managed MCP server
  •  aws:CalledViaAWSMCP  (String) — the service principal of the specific MCP server ( aws-mcp.amazonaws.com )
These keys let you write IAM policies that differentiate between what your developers do directly and what their AI agents do on their behalf. This is a fundamental governance capability.
Example 1 — Read-only agents in production:
{
"Sid": "DenyDestructiveActionsViaMCP",
"Effect": "Deny",
"Action": [
"s3:DeleteObject",
"s3:DeleteBucket",
"ec2:TerminateInstances",
"cloudformation:DeleteStack"
],
"Resource": "*",
"Condition": {
"StringEquals": {
"aws:CalledViaAWSMCP": "aws-mcp.amazonaws.com"
}
}
}
Example 2 — Block all MCP-initiated actions across an organization (SCP):
{
"Sid": "DenyAllActionsViaMCP",
"Effect": "Deny",
"Action": "*",
"Resource": "*",
"Condition": {
"Bool": {
"aws:ViaAWSMCPService": "true"
}
}
}
This second pattern is useful for organizations that want to roll out the toolkit progressively — you can whitelist specific accounts or OUs while blocking MCP access everywhere else via SCP.
Example 3 — Allow reads, deny writes through MCP:
[
{
"Sid": "AllowReadOperations",
"Effect": "Allow",
"Action": ["s3:GetObject", "s3:ListBucket", "ec2:Describe*"],
"Resource": "*"
},
{
"Sid": "DenyWritesViaMCP",
"Effect": "Deny",
"Action": ["s3:PutObject", "ec2:RunInstances", "iam:CreateRole"],
"Resource": "*",
"Condition": {
"Bool": { "aws:ViaAWSMCPService": "true" }
}
}
]


Data Protection

The MCP Server is stateless. It doesn't persist your data. When file processing is required (for example, uploading a deployment package), the server uses pre-signed S3 URLs to stage files through your own S3 bucket. The file is never stored on the server's infrastructure permanently — temporary copies on ephemeral Lambda storage are automatically encrypted using AWS-managed keys and destroyed within 8 hours (most operations complete in seconds).
All communication between your MCP client and the server uses TLS 1.2 or later. All downstream API calls also use TLS. CloudTrail logs everything.

Monitoring & Observability — CloudWatch, CloudTrail, Quotas

Governance without observability is just wishful thinking. The toolkit gives you two levels of visibility: real-time metrics via CloudWatch and a full audit trail via CloudTrail.

CloudWatch Metrics

The AWS MCP Server automatically publishes metrics to the  AWS-MCP  namespace in CloudWatch at no additional cost. Metrics are organized by tool name, so you can see exactly which capabilities your agents are using.
Metric
Description
Invocation
Total number of tool calls
Success
Calls that returned HTTP 200
UserError
4XX errors (permission issues, bad parameters)
SystemError
5XX errors (service disruptions)
Throttle
Calls throttled with HTTP 429
A spike in  UserError  for  aws___call_aws  usually means an IAM permission issue — the agent is trying to do something it's not allowed to do. This is your early warning system for misconfigured roles. A spike in  Throttle  tells you your agent is hitting the 3 requests/second sustained rate limit and you may need to optimize your workflows or request a quota increase.
Example of a monitoring dashboard on CloudWatch (from my demo)

Recommended alarms to set up on day one:
Alarm 1: UserError rate > 10% of Invocations over 5 minutes
→ Likely cause: IAM misconfiguration or stale credentials
→ Action: SNS notification to platform team

Alarm 2: Throttle count > 0 sustained over 10 minutes
→ Likely cause: Agent in a retry loop or overly parallel workflows
→ Action: Trigger Lambda to pause agent session

Alarm 3: ConcurrentConnection approaching quota (default: 27 per region)
→ Action: Auto-notify and consider quota increase request
The  AWS/Usage  namespace also exposes usage metrics for quota monitoring:
  •  CallCount  — Total requests to MCP Server
  •  ConcurrentConnection  — Active connections
  •  AccountSessionCount  — Active sessions per account
  •  UserSessionCount  — Active sessions per IAM user/role

CloudTrail Audit

Every API call made through the AWS MCP Server is logged by CloudTrail. Every single one. This includes the tool name, request parameters, response, execution time, source IP, IAM identity, and — when using OAuth — the  aws:SignInSessionArn  that links the call back to the originating user session.
Here's what a CloudTrail entry looks like for an MCP tool call:
{
"eventSource": "aws-mcp.us-east-1.api.aws",
"eventName": "CallTool",
"eventCategory": "Data",
"eventType": "AwsMcpEvent",
"userIdentity": {
"type": "AssumedRole",
"arn": "arn:aws:sts::111111111111:assumed-role/DevRole/engineer"
},
"requestParameters": {
"method": "call_aws",
"params": { "service": "s3", "operation": "ListBuckets" }
},
"responseElements": {
"isError": false
},
"mcpEventDetails": {
"sessionId": "sess_xyz789",
"executionTimeMs": 250
}
}
A few things to notice:  eventCategory: Data  means these are data events, which you need to explicitly enable in your trail configuration if you want them captured. Also note the  mcpEventDetails  block — this is specific to MCP events and gives you session-level correlation, which is invaluable when debugging an agent that made an unexpected change.
For compliance reporting, the combination of CloudTrail logs +  aws:ViaAWSMCPService  condition keys gives you a clean, auditable separation between human-initiated and agent-initiated actions in your AWS account. This is the kind of evidence your security team will ask for when you start rolling out agents in regulated environments.

Quotas to Know

Before you go to production, internalize these limits:
Quota
Default
Adjustable
Concurrent connections per account/region
27
No
Concurrent sessions per account/region
180
Yes
Concurrent sessions per user/region
90
Yes
Requests per second per account/region
3 (sustained)
No
Max ephemeral storage retention
8 hours
No
Max file size for processing
125 MB
No
The 3 requests/second sustained rate limit is the one most teams hit first. If you're running multiple agents in parallel or building an automated pipeline that calls the MCP Server in a loop, you'll need to design with backoff and queuing in mind.

Live Demo

🎬 Watch the demo below: we walk through a practical end-to-end scenario using AWS Agent Toolkit with Kiro to deploy an AWS component in minutes from a natural language prompt.
In this demo, Kiro is connected to the AWS MCP Server and uses the AWS Agent Toolkit capabilities to deploy a simple Python-based AWS Lambda function. The goal is to show how an AI coding agent can understand an AWS deployment request, select the right execution path, troubleshoot issues during the process, and still reach the expected outcome.


Demo scenario

The objective of the demo is to deploy a Lambda function named  lambda-test-toolkit  in the  us-east-1  Region.
The Lambda function accepts a JSON payload in the following format:
{
"query": "the query in natural language"
}
The function processes the value of  query  using Amazon Bedrock and returns an answer to the caller.
The deployment is intentionally limited to the Lambda component only. No additional infrastructure, such as Amazon API Gateway, is created.

Prompt used in the demo

The following prompt was provided to Kiro:
You are an expert in Python and AWS. Deploy a simple Python Lambda function named lambda-test-toolkit in the us-east-1 region, which receives a JSON payload structured as {"query": "the query in natural language"} and uses Amazon Bedrock to process the query and return an answer. Deploy the Lambda component only, without any additional infrastructure such as API Gateway. Use the AWS MCP server and the available skills to carry out the deployment.

What the demo shows

During the demo, Kiro connects to the AWS MCP Server and uses the available AWS Agent Toolkit capabilities to work toward the deployment goal.
The workflow demonstrates several important behaviors:
  • Interpreting an AWS deployment request from a natural language prompt
  • Creating a Python Lambda function for a Bedrock-backed use case
  • Targeting the  us-east-1  Region
  • Keeping the deployment scope limited to Lambda only
  • Using the AWS MCP Server and available skills as part of the workflow
  • Handling execution issues during the deployment process
  • Adapting to an alternative approach when the initial tool path is unavailable

Handling tool execution issues

One important part of the demo is that the AWS  run script  tool starts returning errors during the workflow because of a connection issue.
This happens even though the AWS MCP Server is connected and successfully returns a response at the beginning of the demo. The issue appears during the execution phase and is currently being investigated to determine whether it is related to networking, scalability, or another transient behavior on the AWS side.
This is useful to observe because real-world agentic workflows do not always follow a perfect path. Tools can fail, connections can be interrupted, and agents need to recover without losing sight of the original goal.
In this case, Kiro does not stop at the failed execution path. Instead, it adapts by switching to another approach, such as using the AWS CLI, to continue progressing toward the deployment objective.

Why this matters

This demo highlights an important benefit of combining AI coding agents with the AWS Agent Toolkit: the agent is not only generating code or infrastructure instructions, but also reasoning through the task.
When a tool path fails, the agent can evaluate the situation, choose another valid approach, and continue working toward the same outcome. This makes the workflow more resilient and closer to how an experienced developer would troubleshoot a deployment.

Key takeaways from the demo

  • Kiro can use the AWS Agent Toolkit to translate a natural language request into an AWS deployment workflow.
  • The AWS MCP Server provides a structured way for agents to interact with AWS capabilities.
  • The demo deploys a Python Lambda function that integrates with Amazon Bedrock.
  • The deployment remains scoped to Lambda only, without additional infrastructure such as API Gateway.
  • When the AWS  run script  tool encounters a connection issue, Kiro adapts by using an alternative execution path.
  • Agentic development workflows become more valuable when agents can recover from failures and continue toward the desired result.

Main Takeaways

After everything we've covered, here are the five things worth remembering.
1. AI coding agents are only as good as their knowledge and guardrails. Without the Agent Toolkit, agents improvise from stale training data and operate with unconstrained permissions. That's a recipe for wasted time and unexpected costs. The toolkit gives agents current knowledge and tested procedures — and gives you the controls to define exactly what they're allowed to do.
2. The MCP Server is your single integration point. One endpoint. 15,000+ APIs. Built-in auth. CloudWatch metrics. CloudTrail logs. You don't need to build custom tooling to connect your agents to AWS — the infrastructure is already there.
3. IAM condition keys are your governance lever.  aws:ViaAWSMCPService  and  aws:CalledViaAWSMCP  let you write policies that treat agent-initiated actions differently from human-initiated ones. Use this to enforce read-only agents in production, block destructive operations, or implement progressive rollouts via SCPs.
4. OAuth 2.1 for humans, SigV4 for automation. Use OAuth when developers are interacting with agents manually — it's simpler, token-based, and integrates with your existing identity provider. Use SigV4 when you need multi-account switching, headless automation, or stricter session control.
5. Observability is not optional at scale. Set up CloudWatch alarms on  UserError  and  Throttle  on day one. Enable data events in your CloudTrail trail. Use  aws:SignInSessionArn  to correlate OAuth sessions with API activity. When something goes wrong — and it will — you want the data to already be there.

Getting Started

The fastest way to get started is a single command:
aws configure agent-toolkit
This interactive wizard detects your installed AI coding agents, installs default Skills, and configures the MCP Server connection. If you prefer a manual setup, install the plugin directly in your agent of choice and verify the connection by asking: "What AWS Regions are available?"
From there, explore the available Skill bundles based on your use case —  aws-data-analytics  for data teams,  aws-agents  for teams building on Bedrock and AgentCore,  aws-agents-for-devsecops  for security-focused workflows.
The toolkit is free. You pay only for the AWS resources your agents provision, at standard pricing.

Resources

Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article