Skip to content
Loading

MCP Deployment Best Practices on AWS: My Production Checklist

MCP Deployment Best Practices on AWS: My Production Checklist hero image

To deploy an MCP server on AWS safely, I follow ten practices that AWS lists in its prescriptive guidance on MCP deployment patterns: least-privilege IAM, encryption at rest and in transit, private compute, multi-AZ design for failure, threat detection from day one, right-sizing, infrastructure as code, asynchronous long-running tools, consistent tagging, and managed services by default. Below is how I turn each of those principles into concrete AWS services, settings and code.

The guidance is written by Deepika Kumar and Lingling Cui at AWS and is grounded in the AWS Well-Architected Framework. It names principles, not services. That gap is where most teams get stuck, so this post fills it in with what I actually reach for.

Key takeaways

  • An MCP server is a privileged execution engine driven by an LLM. Treat it like production infrastructure, not a side project.
  • Keep MCP compute in private subnets. Only the load balancer or API entry point faces the internet.
  • Any MCP tool that runs longer than a few seconds should return a job ID and process work asynchronously.
  • Default to managed compute (Amazon Bedrock AgentCore Runtime, AWS Lambda, AWS Fargate). Pick self-managed only for a specific capability gap.
  • Turn on CloudTrail, GuardDuty and Security Hub before the first tool call hits production.

What is a remote MCP server on AWS?

A remote MCP server is a Model Context Protocol server that runs on shared infrastructure and is reached over HTTP, instead of running as a local process on a developer's laptop. Clients such as Claude Code, Kiro or Amazon Q Developer connect to it over the network.

The AWS guide evaluates five hosting patterns for remote MCP servers:

PatternBest fit
Amazon Bedrock AgentCore RuntimeFully managed agent and MCP hosting with built-in session isolation
AWS Lambda + Amazon API GatewaySpiky, short, stateless tool calls
Amazon ECS (usually on Fargate)Long-lived connections and containerised servers without managing nodes
Amazon EKSTeams already standardised on Kubernetes
Amazon EC2Specific OS, GPU or licensing needs managed services cannot meet

Reference implementations live in the aws-samples/sample-mcp-deployment-patterns repository. The best practices below apply whichever pattern you choose.


The ten practices mapped to AWS services

This is the table I keep open when I review an MCP deployment. The left column is the AWS principle. The right column is what I check for in the account.

Best practiceAWS services and settings I use
Least-privilege accessOne IAM role per function or task, IAM Access Analyzer, STS short-lived credentials, no access keys on compute
Encrypt at rest and in transitAWS KMS, ACM certificates, ALB TLS 1.2+ security policy, Secrets Manager with rotation
Keep compute privatePrivate subnets, Application Load Balancer, VPC endpoints (AWS PrivateLink)
Design for failureTwo or more Availability Zones, explicit client timeouts, circuit breakers
Threat detection from day oneAWS CloudTrail, Amazon GuardDuty, AWS Security Hub, runbooks
Right-size before scalingAmazon CloudWatch metrics, AWS Compute Optimizer
Infrastructure as codeAWS CDK or CloudFormation, deployed through CI pipelines
Asynchronous long-running toolsAmazon SQS, AWS Step Functions, Amazon DynamoDB for job state
Tag every resourceAWS Organizations tag policies, AWS Config required-tags rule, cost allocation tags
Prefer managed servicesAgentCore Runtime, Lambda, Fargate

1. Apply least-privilege access to every MCP component

Least privilege means every function, container and instance gets only the permissions its specific task needs. AWS calls out two things explicitly: avoid wildcard resource permissions, and never store long-lived credentials on compute.

For MCP this matters more than for a normal API. The LLM decides which tools to call. If one tool's role can read every S3 bucket, a prompt injection that reaches that tool can too. I give each tool group its own role and scope it to named resources.

// CDK: a task role scoped to one bucket prefix and one table
const taskRole = new iam.Role(this, "McpTaskRole", {
  assumedBy: new iam.ServicePrincipal("ecs-tasks.amazonaws.com"),
});

reportsBucket.grantRead(taskRole, "reports/*");
jobsTable.grantReadWriteData(taskRole);
// No "*" resources. No access keys. Credentials come from the task role via STS.

On EC2 I use instance profiles. On ECS I use task roles. On Lambda I use the execution role. All three issue short-lived credentials, so there is never a static key sitting in a container image or a .env file. I then run IAM Access Analyzer to flag anything broader than intended.


2. Protect data at rest and in transit

AWS asks for three things here: encrypt stored data with customer-managed or platform-managed keys, enforce TLS 1.2 or higher on all network traffic, and keep secrets in a managed secrets service with automatic rotation.

What that looks like in my stacks:

  • At rest: AWS KMS keys on S3 buckets, DynamoDB tables, EBS volumes and CloudWatch log groups. I use a customer-managed key when compliance needs key policy control, and the AWS-managed key otherwise.
  • In transit: an ACM certificate on the Application Load Balancer with a TLS 1.2 or 1.3 security policy. HTTP listeners only redirect to HTTPS.
  • Secrets: OAuth client secrets and downstream API keys live in AWS Secrets Manager with rotation enabled. The task reads them at runtime.
// CDK: inject a secret into the container without putting it in plain env vars
container.addSecret(
  "UPSTREAM_API_KEY",
  ecs.Secret.fromSecretsManager(upstreamApiSecret),
);

The anti-pattern AWS names directly is hardcoded secrets or unencrypted environment variables. I have seen MCP servers ship with a GitHub token baked into the Dockerfile. Anyone who can pull the image owns that token.


3. Keep MCP compute private

All MCP servers sit behind a load balancer in private subnets. Only the load balancer or the API entry point is internet-facing. Internal service-to-service traffic goes through private endpoints so it never crosses the public internet.

// CDK: Fargate service in private subnets, public ALB in front
const service = new ecsPatterns.ApplicationLoadBalancedFargateService(
  this,
  "McpService",
  {
    cluster,
    taskSubnets: { subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS },
    publicLoadBalancer: true,
    certificate,
    redirectHTTP: true,
    desiredCount: 2,
    circuitBreaker: { rollback: true },
    taskImageOptions: {
      image: ecs.ContainerImage.fromEcrRepository(repo, "1.4.0"),
      containerPort: 8080,
      taskRole,
    },
  },
);

I also add VPC interface endpoints for Secrets Manager, ECR, CloudWatch Logs and STS, plus a gateway endpoint for S3 and DynamoDB. That keeps AWS API calls on the AWS network and lets me lock down NAT egress to only the third-party hosts the tools actually call.

If you only need internal clients, make the load balancer internal too. An MCP server that only your engineers use has no reason to have a public DNS name.


4. Design MCP servers for failure

AWS sets a clear floor: deploy across at least two Availability Zones, put circuit breakers and explicit timeouts on every downstream call, and never rely on platform defaults. The application should degrade gracefully when a dependency is down instead of failing entirely.

The "never rely on defaults" line is the one I see ignored most. Many HTTP clients have no timeout, or a very long one, by default. An MCP tool that hangs on a slow upstream holds a connection open, and the agent waits with it.

// Explicit timeout on every downstream call
async function callUpstream(url: string, body: unknown) {
  const res = await fetch(url, {
    method: "POST",
    body: JSON.stringify(body),
    headers: { "content-type": "application/json" },
    signal: AbortSignal.timeout(5_000),
  });
  if (!res.ok) throw new Error(`Upstream returned ${res.status}`);
  return res.json();
}

For graceful degradation I return a structured tool error the model can reason about, such as "pricing service unavailable, try again later", rather than a stack trace or an empty result. A clear error lets the agent tell the user what happened instead of inventing an answer.

Note that circuitBreaker: { rollback: true } in the CDK example above is the ECS deployment circuit breaker. It rolls back a bad deploy. It is not a runtime circuit breaker for downstream calls, so you still need one in application code.


5. Enable threat detection from day one

AWS recommends audit logging for all API activity across accounts, automated threat detection on those logs, a single dashboard for security findings, and incident response runbooks written before an incident happens.

My baseline for any account that hosts an MCP server:

  • AWS CloudTrail organisation trail, delivered to a locked-down log archive account.
  • Amazon GuardDuty enabled in every Region, including runtime monitoring for ECS and EKS where it applies.
  • AWS Security Hub aggregating GuardDuty, IAM Access Analyzer and Config findings into one view.
  • Application-level tool logs: which client called which tool, with which arguments, and what it returned. CloudTrail sees AWS API calls. It does not see what the LLM asked your tool to do.

That last point is specific to MCP. I wrote more about tool-call auditing and anomaly detection in my MCP server security checklist and defending MCP servers against prompt injection.


6. Right-size before you scale

Start with a conservative allocation and tune from observed metrics. AWS points out that over-provisioned resources waste money and energy, and recommends using automated recommendations after a baseline period rather than guessing upfront.

In practice I start Fargate tasks small, watch CPU, memory and p95 tool latency in CloudWatch for a couple of weeks, and then read AWS Compute Optimizer recommendations. MCP traffic is often bursty and driven by when developers are working, so target-tracking auto scaling on CPU or request count usually beats a large fixed task count.


7. Define all MCP infrastructure as code

Never create or change production resources by hand. Compute, networking, IAM and monitoring should be version-controlled, peer-reviewed and deployed through automated pipelines. AWS frames this as repeatability, auditability and safe rollbacks.

I use AWS CDK in TypeScript, which is why the snippets in this post are CDK. The IAM policies get reviewed in the same pull request as the tool code that needs them. That pairing is the most useful review habit I have for MCP: a new tool and its new permission should never arrive separately.


8. Make long-running MCP tools asynchronous

Any MCP tool that takes more than a few seconds should be decoupled from the synchronous request path. AWS describes the pattern directly: accept the request, queue the work, return a job ID, and provide a polling or callback mechanism. This avoids gateway timeouts and improves the experience for the user.

This one bites hard on AWS because of fixed limits in the request path. The Amazon API Gateway REST API integration timeout defaults to 29 seconds, and the Application Load Balancer idle timeout defaults to 60 seconds. A report-generation tool that runs for two minutes will fail behind either one.

The shape I use is two tools instead of one:

// Tool 1: start the job and return immediately
server.tool(
  "start_report",
  { accountId: z.string() },
  async ({ accountId }) => {
    const jobId = crypto.randomUUID();
    await jobs.put({ jobId, status: "queued", accountId });
    await sqs.send(
      new SendMessageCommand({
        QueueUrl: process.env.REPORT_QUEUE_URL,
        MessageBody: JSON.stringify({ jobId, accountId }),
      }),
    );
    return { content: [{ type: "text", text: JSON.stringify({ jobId }) }] };
  },
);

// Tool 2: poll for the result
server.tool("get_report_status", { jobId: z.string() }, async ({ jobId }) => {
  const job = await jobs.get(jobId);
  return { content: [{ type: "text", text: JSON.stringify(job) }] };
});

A worker on Lambda or Fargate consumes the SQS queue and writes status and results to DynamoDB. For multi-step jobs I swap SQS for AWS Step Functions. The agent calls start_report, gets a job ID back in milliseconds, and polls get_report_status until it is done.


9. Tag every MCP resource

Apply consistent tags to every resource, with environment, application, team and cost centre as the minimum. AWS recommends enforcing the policy through automated rules, because without tags, cost attribution and compliance reporting become impractical at scale.

In CDK, I tag at the app level so nothing slips through:

Tags.of(app).add("environment", "prod");
Tags.of(app).add("application", "mcp-reports");
Tags.of(app).add("team", "platform");
Tags.of(app).add("cost-centre", "eng-1234");

Then I enforce it with AWS Organizations tag policies and the AWS Config required-tags managed rule, and activate the tags as cost allocation tags in Billing. Once a company runs ten MCP servers, "which one is costing us money" is a question you want answered by a filter, not an investigation.


10. Prefer managed services over self-managed infrastructure

Managed and serverless compute removes idle resource consumption and reduces operational burden. AWS is explicit that self-managed infrastructure should only be chosen when a specific capability requirement cannot be met by a managed service.

My default order for a new MCP server:

  1. Amazon Bedrock AgentCore Runtime if I want AWS to handle hosting, session isolation and scaling for agent workloads.
  2. AWS Lambda + API Gateway for short, stateless tools with spiky traffic.
  3. Amazon ECS on Fargate for long-lived streamable HTTP connections or heavier containers.
  4. Amazon EKS or EC2 only when there is a concrete reason, such as an existing Kubernetes platform, GPUs or OS-level dependencies.

Every step down that list is more control and more things I have to patch, scale and secure myself.


My pre-production checklist for MCP on AWS

Before an MCP server takes real traffic, I want a "yes" to every line:

  • Each task, function or instance has its own IAM role with no * resources
  • No long-lived access keys anywhere in images, env vars or code
  • KMS encryption on every data store and log group
  • TLS 1.2+ on the load balancer, HTTP redirects to HTTPS
  • Secrets in Secrets Manager with rotation enabled
  • Compute in private subnets, VPC endpoints for AWS APIs
  • At least two Availability Zones
  • Explicit timeouts and a circuit breaker on every downstream call
  • CloudTrail, GuardDuty and Security Hub enabled, plus tool-call logs
  • An incident runbook exists for "MCP tool misused"
  • Everything deployed from CDK or CloudFormation through CI
  • Tools longer than a few seconds return a job ID
  • Required tags enforced by policy
  • A written reason for any self-managed compute

If you are still building your first server, start with my guide to building an MCP server in Python, then come back to this list before you deploy it.


Frequently asked questions

What is the best way to deploy an MCP server on AWS?

For most teams, a managed option is best: Amazon Bedrock AgentCore Runtime, AWS Lambda with API Gateway for short stateless tools, or Amazon ECS on Fargate for long-lived connections. AWS recommends choosing self-managed compute such as EC2 only when managed services cannot meet a specific requirement.

Should an MCP server be public on AWS?

The MCP server itself should not be. AWS recommends placing MCP servers in private subnets behind a load balancer, with only the load balancer or API entry point facing the internet. If only internal users need it, make the load balancer internal as well.

How do I handle MCP tools that take a long time on AWS?

Make them asynchronous. Accept the request, put the work on a queue such as Amazon SQS or AWS Step Functions, return a job ID, and expose a second tool to poll for the result. This avoids API Gateway and load balancer timeouts.

How should MCP servers store secrets on AWS?

Store them in AWS Secrets Manager with automatic rotation and inject them at runtime. AWS guidance says secrets should never be hardcoded or kept unencrypted in environment variables.

Which AWS services detect threats against an MCP deployment?

AWS CloudTrail for API audit logs, Amazon GuardDuty for automated threat detection, and AWS Security Hub to centralise findings. Add your own tool-call logging, because AWS services do not see which tools the LLM invoked or with which arguments.