How to Set Up and Use the AWS MCP Server for Secure AI Agent AWS Access

Introduction

AI coding agents are powerful, but giving them safe, up-to-date access to AWS has been a challenge. The AWS MCP Server – now generally available as part of the Agent Toolkit for AWS – solves this by providing a managed remote Model Context Protocol (MCP) server. It gives agents a fixed set of tools to call thousands of AWS APIs, retrieve current documentation, and even run sandboxed scripts – all while respecting your existing IAM permissions. This guide walks you through setting it up and using it effectively.

How to Set Up and Use the AWS MCP Server for Secure AI Agent AWS Access
Source: aws.amazon.com

What You Need

Step 1: Configure Your AI Agent for Remote MCP

Most MCP-compatible agents allow you to add remote servers via a configuration file (e.g., `mcp.json` or agent settings). Look for options to specify a server URL and authentication details. You’ll need the AWS MCP Server endpoint URL from the Agent Toolkit documentation. Typically, it looks like:

https://mcp.aws.com/v1

Add this as a new server entry, along with your IAM credentials (access key and secret key, or a role ARN). The server uses IAM context keys for fine-grained access – you no longer need a separate IAM permission to use the server itself.

Step 2: Create an IAM Policy with Context Keys

Create an IAM policy that grants your agent only the permissions it truly needs. Use IAM context keys to limit which API operations the agent can call via the MCP server. For example:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:ListBucket", "s3:GetObject"],
      "Resource": "arn:aws:s3:::my-bucket/*",
      "Condition": {
        "StringEquals": {
          "aws:SourceService": ["mcp.amazonaws.com"]
        }
      }
    }
  ]
}

Attach this policy to the IAM user or role your agent will use. The server will enforce these permissions on every API call, ensuring the agent can’t exceed its scope – even if it tries to call `iam:CreateUser`.

Step 3: Test the Core Tools

Once connected, your agent can use three built-in tools without consuming its context window:

Test with a simple request like “List my S3 buckets” or “Find documentation for Amazon Bedrock AgentCore.” The agent will respond with accurate, live data.

Step 4: Use the run_script Tool for Multi-Step Operations

For scenarios where the agent needs to chain multiple API calls and process results, use the run_script tool. This lets the agent write a short Python script that runs server-side in a sandboxed environment. The sandbox inherits your IAM permissions but has no network access – so it can’t touch your local filesystem or reach the internet. This is ideal for tasks like:

How to Set Up and Use the AWS MCP Server for Secure AI Agent AWS Access
Source: aws.amazon.com

The agent sends the script as a string, and the server executes it in one round-trip. This reduces token usage and speeds up complex workflows dramatically.

Step 5: Load Skills for Best-Practice Guidance

The AWS MCP Server replaces the older “Agent SOPs” with Skills – curated, contextual guidance for common tasks. Skills are essentially pre-built prompts that teach the agent best practices, such as building CDK infrastructure or writing secure IAM policies. To use a Skill, include it in the agent’s system prompt or configuration:

Your agent can also call search_documentation to find relevant Skills on the fly.

Tips and Best Practices

With the AWS MCP Server, your AI agents can now securely and efficiently interact with the entire AWS platform. Start with the steps above, and gradually expand capabilities as you gain confidence.

Recommended

Discover More

Huawei's HarmonyOS Surpasses 55 Million Devices: A Rising Force in the Open-Source Mobile OS LandscapeBreaking: Volla Phone Plinius Launches with Rugged Design and Dual OS FreedomWhen Payment Platforms Become Censors: Rainey Reitman’s Eye-Opening Book “Transaction Denied”Python 3.15 Alpha 6 Released: New Profiler, UTF-8 Default, and JIT SpeedupsWhy Traditional Weather Forecasting Models Still Beat AI for Extreme Events: A Hands-On Guide