Overview
MCP has become the norm. Anyone can use it to connect different tools to their LLM, and the LLM consumes them to process what the user asked for. Think of the CLI you use locally to talk to the AWS Console without opening its UI. You authenticate with your own identity, and you can create or delete whatever that identity is allowed to touch, but the access is yours alone. Through MCP everything sits in one place, and you can call any action you exposed as a tool, whether you put every tool behind one endpoint or split them across endpoints with different authentication. You assign a single permission to MCP for the interaction and add the rest of your team to the same MCP, so they do not need direct access inside AWS itself. They go through MCP, with the same access and without holding any AWS credentials.
AWS has just released its official MCP server, with different variants for different use cases (awslabs/mcp). At first I assumed that with this MCP we could do anything in our AWS account easily, without letting the model look up what we asked for on the internet. Every MCP server usually brings a capability known as a tool. After giving the AWS MCP server a try, I noticed it does not create a tool for every service it has. Instead, it offers the tools below.
| Tool | What it does |
|---|---|
aws___run_script | runs Python in a sandbox, with AWS calls through call_boto3 |
aws___search_documentation, aws___read_documentation | look up AWS docs |
aws___retrieve_skill | pulls a packaged procedure for a task |
aws___list_regions, aws___get_regional_availability | check where a service exists |
aws___get_tasks | reads the status of a long-running task |
aws___get_presigned_url | mints a temporary S3 link |
It makes sense that AWS does not expose a separate tool for every feature of its services. With a CLI or an SDK, I already have an access key, a role, or an SSO profile, and the tool signs every request with it. MCP puts a server in the path instead. The client talks to the server, the server talks to AWS for me, and at least three parties have to agree on who is acting.
Inside the AWS MCP Server
AWS offers the MCP server in two ways. The self-managed option is one of the open-source servers from awslabs/mcp that you install and run yourself, and the AWS-managed option is a server AWS runs for you. To keep it simple, this post uses the AWS-managed one. The AWS MCP Server runs at a regional endpoint, such as https://aws-mcp.us-east-1.api.aws/mcp in us-east-1, and any MCP client that supports the HTTP transport can connect to it and use the eight tools listed in the table above. AWS announced it in May 2026 and runs the endpoint, the Python sandbox and the OAuth server behind it.
Two of the tools can change things in your account. aws___run_script can call any API the role allows, and aws___get_presigned_url can hand out an upload link that writes to S3. The other six only read.
Every MCP server describes its tools when a client calls tools/list, and AWS answers that call even without a token. The description of aws___run_script says your Python reaches AWS only through a function called call_boto3, with no other network access, and it includes the function’s signature.
async def call_boto3(
*,
service_name: str,
operation_name: str,
region_name: str | None = None,
params: dict | None = None,
) -> dict: ... # the AWS response itself
Operation names use PascalCase, like ListBuckets rather than list_buckets. The tool description asks for the exact AWS API name and only corrects a snake_case name as a fallback at runtime. Results are paginated for you, up to 1,000 items, and a NextToken or Marker in the reply means there is more to fetch.
A script is just Python that ends with the value you want back. This one asks STS who is calling.
result = await call_boto3(
service_name="sts",
operation_name="GetCallerIdentity",
region_name="us-east-1",
)
result
The response tells you whether the script succeeded, what it returned, and which AWS calls it made.
{
"status": "success",
"stdout": "",
"stderr": null,
"return_value": {
"UserId": "AROAVVIOJHRXD4POL66JH:mcp-aws",
"Account": "389261376622",
"Arn": "arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws"
},
"warning": null,
"api_calls": [
{ "service": "sts", "operation": "GetCallerIdentity", "status": "success" }
]
}
The sandbox has no network access except call_boto3, so a script cannot send what it finds to an outside server. Whatever it reads either comes back in the MCP response or leaves through an AWS call your role allows. Your role still decides how far a script can reach, but the easiest way out is closed. The sandbox has been escaped once, described in Breaking the AWS MCP Python Sandbox, and what stopped that escape was the sandbox’s own locked-down role and the lack of network access, not the Python restrictions.
Calls inside a script keep their plain AWS names, so they are easy to spot when you read one. The exception is aws_mcp, a helper module the sandbox ships, whose functions can wrap a whole job in one line, so a check that matches on names cannot tell what they do.
Setting Up the IAM AWS MCP Needs
The MCP server needs access inside AWS. To make the identity explicit, we create a dedicated IAM user and a role that only this user can assume. The agent itself never holds AWS credentials, so this IAM user acts only for the agent, and only for what the agent needs. This user can only assume the role, every permission sits on the role, and the trust policy names exactly one user, so the key we store does nothing until it is exchanged.
We start with the account ID and store it in ACCOUNT, so the commands below can use it.
ACCOUNT=$(aws sts get-caller-identity --query Account --output text)
Create a user with no permissions.
aws iam create-user --user-name mcp-aws-broker
Next, we give the created user its permission.
aws iam put-user-policy --user-name mcp-aws-broker --policy-name assume-mcp-aws \
--policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Action\":\"sts:AssumeRole\",\"Resource\":\"arn:aws:iam::$ACCOUNT:role/mcp-aws\"}]}"
That permission is sts:AssumeRole, scoped to the one role by name, and it is all the user gets. The role is where the permissions live, so its name and the policy it carries are the two things we define explicitly.
Then a role that only this user may assume.
aws iam create-role --role-name mcp-aws --max-session-duration 3600 \
--assume-role-policy-document "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::$ACCOUNT:user/mcp-aws-broker\"},\"Action\":\"sts:AssumeRole\"}]}"
Give IAM a moment between creating the user and the role. If the user is seconds old, create-role can reject the trust policy with an invalid principal, because the new user has not propagated yet.
Then attach the signin policy. How AWS MCP Authentication Works shows what it unlocks.
aws iam attach-role-policy --role-name mcp-aws \
--policy-arn arn:aws:iam::aws:policy/AWSMCPSignInOAuthAccessPolicy
Without that managed policy, the client authenticates and gets nothing back, because IAM refuses the request before Sign-in issues a token. The token lasts for the shorter of one hour or the remaining role session, which is why create-role sets the session to an hour.
That policy only permits the mint and grants nothing in the account itself. What the server can read and change comes from a second policy on the same role, and that one can be as narrow as read-only on a single service or as wide as read-write on everything.
For this sample the second policy is AdministratorAccess, which gives the MCP full control of my AWS.
aws iam attach-role-policy --role-name mcp-aws --policy-arn arn:aws:iam::aws:policy/AdministratorAccess
Then create an access key for the broker, which signs the AssumeRole call with it. In my setup, the broker is the gateway I already run, Agentgateway, with a small service behind it called mcp-aws. Agentgateway checks the client’s API key, and mcp-aws uses this access key to mint the token.
aws iam create-access-key --user-name mcp-aws-broker
That leaves two objects. The user mcp-aws-broker holds one access key and one inline policy, assume-mcp-aws, which allows sts:AssumeRole on the role. The role mcp-aws trusts only that user, lasts an hour, and carries AWSMCPSignInOAuthAccessPolicy.
AWS documents the whole flow, including the interactive, token-exchange and enterprise-managed models, in Configure OAuth access to AWS MCP Server.
How AWS MCP Authentication Works
flowchart LR
A[agent] -->|its own key| B[token broker]
B -->|client_credentials| S[AWS Sign-in]
S -->|bearer token, 1 hour| B
B -->|bearer token| M[aws-mcp endpoint]
M -->|AssumeRole session| R[IAM role]
R -->|permission policy| ACC[your AWS account]
ACC -->|calls logged| CT[CloudTrail]
The broker is the one holding the key, so it assumes the role first and works from temporary credentials when it asks for a token. It signs the request with those credentials, and because the call carries a SigV4 signature, IAM checks it like any other AWS call. AWSMCPSignInOAuthAccessPolicy is what lets it pass, because it grants the two signin actions, signin:AuthorizeOAuth2Access and signin:CreateOAuth2Token, scoped to the aws-mcp.amazonaws.com service principal. What comes back is a bearer token that lasts an hour.
From then on, every call to the endpoint carries that token. The server turns it into a role session, makes the AWS call for me, and the role’s permission policy decides what it can do. Each call is recorded in CloudTrail under that session, and its event will have invokedBy set to aws-mcp.amazonaws.com. The walkthrough below shows one of those records.
The Bearer Token
As we saw in the flow, the bearer token comes from AWS Sign-in. A client that can open a browser usually goes through a consent screen and comes back with one, which on a laptop takes a couple of clicks.
A headless client cannot open a browser, so it takes the other flow, client credentials, where an IAM identity trades its own credentials for a token. Most apps and agents use this flow, and the call behind it is CreateOAuth2TokenWithIAM. The AWS CLI can reproduce the same call with the following command.
aws signin create-oauth2-token-with-iam \
--grant-type client_credentials \
--resource aws-mcp.amazonaws.com \
--region us-east-1
The output gives us the token, its type, and the seconds until it expires.
{
"accessToken": "ASOAeyJraWQ...",
"tokenType": "Bearer",
"expiresIn": 3600
}
The token is good for an hour.
Minting the Next Token
The broker mints the token and, by design, keeps it only in memory, never in a file. When the token fails, the broker retries the sign-in flow.
The process involves a signin:CreateOAuth2Token event, and we can look at the userIdentity of the role session behind it. requestParameters.resource is aws-mcp.amazonaws.com, and there is no accessKeyId, because what came back was a token and not a key. You can also see how it was minted, because client_id in requestParameters reads arn:aws:signin:::client-credentials/sigv4, the implicit client ID for the client credentials flow.
To pull one, query by event name. Here is a mint from my own account.
aws cloudtrail lookup-events --region us-east-1 \
--lookup-attributes AttributeKey=EventName,AttributeValue=CreateOAuth2Token \
--max-results 1 --output json
{
"eventTime": "2026-11-29T08:16:33Z",
"eventSource": "signin.amazonaws.com",
"eventName": "CreateOAuth2Token",
"awsRegion": "us-east-1",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROAVVIOJHRXD4POL66JH:mcp-aws",
"arn": "arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws",
"accountId": "389261376622",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"arn": "arn:aws:iam::389261376622:role/mcp-aws"
},
"attributes": {
"creationDate": "2026-11-29T08:16:32Z",
"mfaAuthenticated": "false"
}
}
},
"sourceIPAddress": "203.0.113.10",
"userAgent": "Boto3/1.43.126 md/Botocore#1.43.126 ... Botocore/1.43.126",
"requestParameters": {
"resource": "aws-mcp.amazonaws.com",
"client_id": "arn:aws:signin:::client-credentials/sigv4"
},
"additionalEventData": {
"signInSessionArn": "arn:aws:signin:us-east-1:389261376622:session/88ee7ac5-50d5-487f-806a-6cac86d5d332",
"grant_type": "client_credentials",
"success": "true"
}
}
The rest of the record helps with attribution. sourceIPAddress is the host that minted, userAgent shows Boto3 rather than the console, and additionalEventData ties the mint to one Sign-in session through signInSessionArn, with grant_type confirming client credentials. sessionIssuer names the role, and creationDate shows the role session started a second before the mint.
It is the same event type as the sample in the CLI post, where a role exchanged credentials for a token and the record did not say why. This time the reason is known, because the broker asked for it.
The mint is also where you catch someone else using the server, because nothing reaches AWS through MCP without one. If the broker’s role is the only principal that should call CreateOAuth2Token, anything else is worth a look, and the query below lists them.
aws cloudtrail lookup-events --region us-east-1 \
--lookup-attributes AttributeKey=EventName,AttributeValue=CreateOAuth2Token \
--output json \
| jq -r '.Events[].CloudTrailEvent | fromjson
| select(.userIdentity.arn != "arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws")
| "\(.eventTime) \(.userIdentity.type) \(.userIdentity.arn)"'
When I ran it, it listed only my own calls, made with my Administrator IAM user and the root user.
2026-11-21T16:12:31Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T16:11:52Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T16:04:05Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T15:56:15Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T15:56:14Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T15:55:51Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-21T15:48:23Z IAMUser arn:aws:iam::389261376622:user/Administrator
2026-11-07T09:14:45Z Root arn:aws:iam::389261376622:root
2026-11-07T08:43:22Z Root arn:aws:iam::389261376622:root
Where the Broker Can Be Attacked
Anyone who can call the broker gets a token, so the broker’s key check is the only thing stopping an unauthorized caller from getting one. If the broker answers requests without a key, your AWS access is exactly as public as the endpoint. It also costs you attribution. The account sees the role, not a name, and the most you can say about a call is that some agent used the MCP server.
The broker keeps the token in memory and never writes it to the logs. The STS credentials sit in memory as well. signin_client() creates a new boto3.Session() for every token, so each mint calls AssumeRole and gets a fresh set of credentials. CloudTrail shows the pair, an AssumeRole from mcp-aws-broker at 2026-11-29T12:14:20Z and the CreateOAuth2Token from the role one second later. Python has no way to wipe a string, so the broker cannot erase those credentials when it is done with them.
What the broker cannot do is exceed the role. A token from it carries exactly the permissions you attached, and no more, so protect it as carefully as you would protect the role itself.
Whose Name Is on the Call
The first question is whose identity sits behind the token.
On your own laptop, that identity is yours. The client uses the AWS credentials you already have, whether it is an SSO profile from aws sso login, a profile in ~/.aws/credentials, or a role you assumed earlier, and the token is minted from that session. It lives an hour, and the next call mints a new one from the same place, so there is nothing to store and nothing to rotate, and CloudTrail attributes every call to the person who asked.
When I asked the server for the caller identity through the agent, this is what CloudTrail recorded.
{
"eventVersion": "1.11",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROAVVIOJHRXD4POL66JH:mcp-aws",
"arn": "arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws",
"accountId": "389261376622",
"accessKeyId": "ASIA...",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AROAVVIOJHRXD4POL66JH",
"arn": "arn:aws:iam::389261376622:role/mcp-aws",
"accountId": "389261376622",
"userName": "mcp-aws"
},
"attributes": {
"creationDate": "2026-11-29T09:22:53Z",
"mfaAuthenticated": "false"
},
"signInSessionArn": "arn:aws:signin:us-east-1:389261376622:session/f9c9fcd1-f4dc-4034-826c-7706534fc88c"
},
"invokedBy": "aws-mcp.amazonaws.com"
},
"eventTime": "2026-11-29T09:23:05Z",
"eventSource": "sts.amazonaws.com",
"eventName": "GetCallerIdentity",
"awsRegion": "us-east-1",
"sourceIPAddress": "aws-mcp.amazonaws.com",
"userAgent": "aws-mcp.amazonaws.com",
"requestParameters": null,
"responseElements": null,
"additionalEventData": {
"ExtendedRequestId": "MTp1cy1lYXN0LTE6UzoxNzk1OTQ0MTg1NTY4OlI6YTFkTEhzUjc=",
"RequestDetails": {
"endpointType": "regional",
"awsServingRegion": "us-east-1"
}
},
"requestID": "54bec802-0dfb-4f2d-824e-7c2ff945f093",
"eventID": "20cda276-bb20-4234-8800-308b1acc6723",
"readOnly": true,
"eventType": "AwsApiCall",
"managementEvent": true,
"recipientAccountId": "389261376622",
"eventCategory": "Management"
}
The record names the role, not a person, so the role is where attribution stops. What surprised me is sourceIPAddress. Normally it carries the address the call came from, but here it shows the server’s name.
Everything the MCP server does lands in CloudTrail as a role session, and the log cannot tell you whether a person, a job, or something else made the call. That has to come from how the session was created. And if several people share the agent, their calls all land under the same assumed-role ARN, so the log cannot say which of them ran it.
What You Can Ask For
I have my own AI agent connected to Agentgateway, which connects to the AWS MCP using my own account. I asked a simple question.

Now, let’s try to ask Please list all my S3 buckets. By using this prompt I was expecting the result to give me all my S3 buckets in the region I set after signing in to AWS, which is us-east-1. The agent sent the request below through MCP.
{"code": "result = await call_boto3(\n service_name=\"s3\",\n operation_name=\"ListBuckets\",\n)\nresult"}
It uses the aws___run_script tool, with boto3 inside it, to run the action. Then it responds with the output below.
{
"status": "success",
"stdout": "",
"stderr": null,
"return_value": {
"Buckets": [
{
"Name": "gdp2-389261376622-1795342402",
"CreationDate": "2026-11-22T10:13:24+00:00",
"BucketArn": "arn:aws:s3:::gdp2-389261376622-1795342402"
}
],
"Owner": {
"ID": "6898b8cdb58caef06c1053e35131064b8612d47191fa015fc26625d7b862bcb9"
},
"Prefix": null
},
"warning": null,
"api_calls": [
{
"service": "s3",
"operation": "ListBuckets",
"status": "success",
"n_items": {
"Buckets": 1
}
}
]
}
By doing this we can understand the request and response from the AWS MCP tool, but the output does not mention where this bucket is hosted, does it? So I asked my agent, and it gave me the request and response below.
{"code": "result = await call_boto3(\n service_name=\"s3\",\n operation_name=\"GetBucketLocation\",\n params={\"Bucket\": \"gdp2-389261376622-1795342402\"},\n)\n"}
{
"status": "success",
"stdout": "",
"stderr": null,
"return_value": {
"LocationConstraint": "us-east-2"
},
"warning": "Auto-fixed: Line 1: appended 'result' as the final expression so its value is returned as return_value",
"api_calls": [
{
"service": "s3",
"operation": "GetBucketLocation",
"status": "success"
}
]
}
This is how CloudTrail recorded the ListBuckets call.
{
"eventVersion": "1.11",
"userIdentity": {
"type": "AssumedRole",
"principalId": "AROAVVIOJHRXD4POL66JH:mcp-aws",
"arn": "arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws",
"accountId": "389261376622",
"accessKeyId": "ASIA...",
"sessionContext": {
"sessionIssuer": {
"type": "Role",
"principalId": "AROAVVIOJHRXD4POL66JH",
"arn": "arn:aws:iam::389261376622:role/mcp-aws",
"accountId": "389261376622",
"userName": "mcp-aws"
},
"attributes": {
"creationDate": "2026-11-29T07:17:22Z",
"mfaAuthenticated": "false"
}
},
"invokedBy": "aws-mcp.amazonaws.com"
},
"eventTime": "2026-11-29T08:06:17Z",
"eventSource": "s3.amazonaws.com",
"eventName": "ListBuckets",
"awsRegion": "us-east-1",
"sourceIPAddress": "aws-mcp.amazonaws.com",
"userAgent": "aws-mcp.amazonaws.com",
"requestParameters": {
"Host": "s3.amazonaws.com"
},
"responseElements": null,
"additionalEventData": {
"SignatureVersion": "SigV4",
"CipherSuite": "TLS_AES_128_GCM_SHA256",
"bytesTransferredIn": 0,
"startTime": 1795939577434,
"AuthenticationMethod": "AuthHeader",
"endTime": 1795939577467,
"x-amz-id-2": "3hKtiikU7+ov3xWCh/0UBOuNzMK9BTHQWGBvBYW/lclsGt4AUZ2z5dhyzlcjd9kbflZcN6FhbM7LGLGN2T+m+fedTTu55ZHM",
"turnAroundTime": 30,
"httpStatusCode": 200,
"bytesTransferredOut": 418
},
"requestID": "Q59SMJMCXKG4NEC6",
"eventID": "c84360f5-b680-3d4c-b124-c5ecebb37d98",
"readOnly": true,
"eventType": "AwsApiCall",
"managementEvent": true,
"recipientAccountId": "389261376622",
"sharedEventID": "540aae44-9dbf-47c7-806b-8d848c0366c5",
"vpcEndpointId": "AWS Internal",
"vpcEndpointAccountId": "AWS Internal",
"eventCategory": "Management"
}
The vpcEndpointId and vpcEndpointAccountId fields both read AWS Internal, because the call came from inside AWS rather than through a VPC endpoint in your account. That is one more sign the caller is the MCP server itself.
The field to filter on is invokedBy. The CLI post filters out events that have it set, on the grounds that AWS made the call, and MCP calls are exactly those events, because the server really is the one calling. A rule built on the principal alone will miss everything the agent did, while invokedBy = aws-mcp.amazonaws.com finds all of it in one filter.
Scoping What the Role May Do
Now the question stops being about MCP and becomes the one you already know. What may this role do?
A simple answer is least privilege on the role the MCP server assumes. Agent-level guardrails help, but an agent can still go rogue, so the controls have to stack, from the role’s policies to SCPs in AWS itself and the other security controls the account already applies.
AWS argues the same in Secure AI agent access patterns to AWS resources using Model Context Protocol. It says to assume the agent can use any permission it holds, and to put permission boundaries and SCPs above the role. The same post introduces two condition keys for calls that come through MCP, covered below.
For example, we can give the mcp-aws role read-only access with the AWS managed policy ReadOnlyAccess.
aws iam attach-role-policy --role-name mcp-aws --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess
Read-only can still read a lot. ReadOnlyAccess includes ssm:Get*, so the role can read every parameter in the account, and a String parameter can hold anything. A SecureString does not stop it either. I created one with the default aws/ssm key, and the read-only role read it back in plain text with WithDecryption set to true, even though ReadOnlyAccess has no kms:Decrypt. The key policy of aws/ssm lets any principal in the account decrypt through SSM, and CloudTrail shows the Decrypt call from the mcp-aws role. Secrets Manager is different, and GetSecretValue came back AccessDeniedException because no policy allows it. The deny below blocks all of these reads, and it keeps them blocked even if someone attaches another policy later.
aws iam put-role-policy --role-name mcp-aws --policy-name deny-secrets --policy-document \
'{"Version":"2012-10-17","Statement":[{"Effect":"Deny","Action":["secretsmanager:GetSecretValue","ssm:GetParameter*","kms:Decrypt"],"Resource":"*"}]}'
With the deny attached, the same parameter and secret reads all failed with an explicit deny, and CloudTrail logged each of them as AccessDenied.
Then add writes one capability at a time, on named resources. If the agent needs to tag something, grant the tagging action on the resources it owns, not ec2:*.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["ec2:CreateTags"],
"Resource": "arn:aws:ec2:us-east-1:389261376622:instance/*",
"Condition": { "StringEquals": { "aws:ResourceTag/managed-by": "mcp-aws" } }
}
]
}
That lets it tag instances you already marked, in one region. It cannot start, stop or terminate one, and it cannot write to anything you did not tag.
Finally, keep a short deny list for the calls that would widen the role’s own reach. Those are worth blocking even if nothing asks for them yet.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Deny",
"Action": [
"iam:CreateUser", "iam:CreateAccessKey", "iam:AttachRolePolicy",
"iam:PutRolePolicy", "iam:PassRole", "organizations:*",
"cloudtrail:StopLogging", "cloudtrail:DeleteTrail", "guardduty:DeleteDetector"
],
"Resource": "*"
}
]
}
Two habits cost nothing. Use one role per client, so a compromise reaches one workload and not all of them. And after a week, open the role’s service last accessed data. It shows the services the role never touched, and every one of those is a permission you can remove.
Denying What Comes Through MCP
The managed server adds two condition keys to every request it forwards on your behalf. aws:ViaAWSMCPService is a boolean, true when an AWS MCP server makes the downstream call through what AWS calls a forward access session. aws:CalledViaAWSMCP holds the name of the server that made it, such as aws-mcp.amazonaws.com. A deny written against either one applies only to calls that come through MCP.
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DenySensitiveActionsViaMCP",
"Effect": "Deny",
"Action": ["s3:DeleteBucket", "s3:DeleteObject", "dynamodb:DeleteTable"],
"Resource": "*",
"Condition": { "Bool": { "aws:ViaAWSMCPService": "true" } }
}
]
}
I checked it with the IAM policy simulator, next to an allow for s3:DeleteObject. With aws:ViaAWSMCPService set to true, the delete came back explicitDeny. Without the key, the same delete was allowed. Matching aws:CalledViaAWSMCP against aws-mcp.amazonaws.com denied it the same way, and IAM Access Analyzer found nothing wrong with the policy.
I then tried it on the live role. With a deny on ec2:CreateVpc conditioned on aws:ViaAWSMCPService, the DryRun through my gateway came back UnauthorizedOperation, citing an explicit deny in an identity-based policy. The same happened when the condition matched aws:CalledViaAWSMCP against aws-mcp.amazonaws.com. A condition on eks-mcp.amazonaws.com did not match, so that DryRun went through as DryRunOperation. CloudTrail logged all three attempts with those same results.
On the mcp-aws role this adds little, since every call that role makes comes through MCP anyway. It pays off when one identity is used both ways, like someone who signs in to the server with their own role through the browser and also runs the CLI. That role keeps its delete permission in the terminal and loses it through the agent.
Testing AWS MCP Access
So far we have set up a user, a role with its policies, the broker, and the gateway route in front of it, but we have not tested any of it. Any of these can be set up wrong, and the agent will not tell you. It connects, lists its tools and looks fine, even if the endpoint is open to everyone or the role can do more than you meant.
To confirm the AWS MCP access works the way it should, I check three things, in this order.
- The gateway rejects requests that have no key.
- A real request goes out to AWS as the
mcp-awsrole. - The role, not the agent, decides what is allowed.
If the first check fails, the other two do not matter, so fix it before moving on. I ran all three on my own gateway while writing this, and the outputs below are from that run.
The Gateway Rejects Requests Without a Key
First, save the gateway route’s address and a sample initialize request. initialize is the first message an MCP client sends when it connects.
GATEWAY=https://mcp.example.com/aws
INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"check","version":"0"}}}'
Then send that request without a key.
curl -s -o /dev/null -w '%{http_code}\n' -X POST "$GATEWAY" \
-H 'content-type: application/json' \
-H 'accept: application/json, text/event-stream' -d "$INIT"
My gateway returned 401, both with no key and with a fake one, which means it refused the request because there was no valid key. Any other answer would have meant that anyone who can reach this URL could use my AWS access through it.
A Token Is Minted for the Role
A 200 here does not tell you much. AWS answers initialize and tools/list even without a token, and I confirmed it by sending both straight to aws-mcp.us-east-1.api.aws with no token. Both came back 200, so a client can connect and list tools without ever showing which identity it uses.
The identity only shows up when the broker mints a token. Send one request through the gateway with a valid key, then look in two places.
- the broker’s log, which should show a new token
- CloudTrail, which should show a
CreateOAuth2Tokenevent from themcp-awsrole, using thelookup-eventsquery from Minting the Next Token
On my gateway, both showed up at the same second.
broker 2026-11-29 12:14:21,545 INFO mcp-aws minted an AWS MCP token, expires in 3599s
CloudTrail 2026-11-29T12:14:21Z arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws
The Role Decides What Runs
The last check asks AWS to change something in the account, without actually doing it. CreateVpc with DryRun set to true asks EC2 whether the role may create a VPC, and EC2 answers without creating one.
When I asked my agent to try a dry run of CreateVpc, it gave me this result.

Without the agent, the same check is one call_boto3 call that you send through aws___run_script.
await call_boto3(
service_name="ec2",
operation_name="CreateVpc",
params={"CidrBlock": "10.99.0.0/16", "DryRun": True},
)
Run it with the agent’s key. On my gateway, a normal client key cannot even see aws___run_script, and calling it anyway returns unknown resource.
There are two possible answers, and both are a pass, because each one means the request reached AWS as the right role.
DryRunOperationmeans the role can do it.UnauthorizedOperationmeans the role is not allowed, which is what you want from a read-only role.
My role still has AdministratorAccess, so I got the first one.
ClientError: An error occurred (DryRunOperation) when calling the CreateVpc operation: Request would have succeeded, but DryRun flag is set.
The script output says "status": "error", which is expected, because boto3 raises DryRunOperation as an error even though it means the call would have worked. CloudTrail recorded it too, as a CreateVpc event from the mcp-aws role with errorCode set to Client.DryRunOperation and invokedBy set to aws-mcp.amazonaws.com. No VPC was created in us-east-1.
To see the other answer, I switched the role to ReadOnlyAccess for a minute and ran the same DryRun again.
ClientError: An error occurred (UnauthorizedOperation) when calling the CreateVpc operation: You are not authorized to perform this operation. User: arn:aws:sts::389261376622:assumed-role/mcp-aws/mcp-aws is not authorized to perform: ec2:CreateVpc on resource: arn:aws:ec2:us-east-1:389261376622:vpc/* because no identity-based policy allows the ec2:CreateVpc action. ...
CloudTrail logged that one as Client.UnauthorizedOperation, from the same mcp-aws role. Then I put AdministratorAccess back.