You can deploy MCP tools on ECS Fargate with AWS CDK, but the AWS Samples design behind this guide does not run Claude inside a container. It runs an agent service that accesses Claude Sonnet 4 through Amazon Bedrock, alongside two separate MCP server services. That distinction matters: a Claude remote custom connector uses a different network path and requires a publicly reachable MCP endpoint.
Choose how Claude will reach your MCP tools
This guide follows the AWS Samples CDK architecture: an agent service calls Claude Sonnet 4 through Bedrock and communicates with MCP servers running as ECS services. ECS Service Connect handles service-to-service communication. The model is hosted through Bedrock; it is not deployed in your Fargate task.
As an Amazon Associate I earn from qualifying purchases.
| Design | Where Claude runs | Network path to the MCP server | When to use it |
|---|---|---|---|
| Agent using Claude through Bedrock | Claude Sonnet 4 is accessed as a Bedrock-hosted model by the agent service. | The agent and MCP services can communicate inside the VPC using ECS Service Connect; public ingress is not inherently required for that internal connection. | Use this for the AWS CDK/Fargate pattern described in this guide. |
| Claude remote custom connector | Claude runs in Anthropic’s hosted client environment and connects to your remote server. | The MCP endpoint must be publicly reachable from Anthropic’s cloud infrastructure and its IP ranges. A private-VPC-only endpoint will not work for this connector flow. | Use this when configuring a remote custom connector in a hosted Claude client, not as a private-only service-to-service setup. |
Anthropic states: “When you add a custom connector, Claude connects to your remote MCP server from Anthropic’s cloud infrastructure, rather than from your local device.” Its connector guidance also describes authentication options such as sign-in modes and fixed request headers; check Anthropic’s current requirements and published IP ranges when setting up that separate design.
What the CDK deployment contains
The AWS Samples project is the closest documented match for CDK, Fargate, Claude, and MCP. Its example includes an Application Load Balancer, an AI service, a custom Python MCP server, and an AWS API MCP server. The AI service is configured for Claude Sonnet 4 through Bedrock; ECS Service Connect supports communication among services. In the example, the AWS API MCP server is restricted to listing S3 buckets. That permission scope and the sample’s API-key arrangement are example choices, not defaults every deployment should copy.
#1 Best Overall
AWS also describes a separate ECS walkthrough with a Gradio UI, a Bedrock-backed agent, and a FastMCP server. In that topology, the UI is exposed through an Application Load Balancer while the agent and MCP server communicate within the VPC, and the server reads catalog data from S3. It is useful as an architecture reference, but it uses CloudFormation and Amazon Nova 2 Lite rather than the CDK/Claude combination in this guide.
Prerequisites for the AWS Samples CDK example
- Node.js 20 or later.
- Docker.
- A configured AWS CLI and credentials for the AWS account and region where you will deploy.
- Access to the Claude Sonnet 4 model in Amazon Bedrock in the target environment.
- Permission to bootstrap CDK resources and deploy the required AWS services.
These are the CDK sample’s documented prerequisites, not universal requirements for every MCP deployment on Fargate. The separate AWS ECS walkthrough specifies AWS CLI v2.32.0 or later, Docker 20.10 or later with buildx, Git, jq, Bash, and Bedrock access to Nova 2 Lite; those version and tool requirements belong to that walkthrough, not this CDK sample.
Rank #2
Deploy the CDK and Fargate sample
- Review the AWS Samples repository and its README. Confirm the current stack configuration, IAM permissions, model identifier and region support, container definitions, and ingress rules before deploying. The repository is a starting point; inspect its code rather than treating sample settings as production defaults.
- Install the project dependencies. Use the dependency installation instructions in the repository README. The available deployment instructions establish that dependencies must be installed, but do not specify a single command here.
- Authenticate Docker to public ECR. Follow the repository’s stated login instructions before the image build or deployment. Docker is needed for the container images.
- Configure and bootstrap CDK. Ensure the AWS CLI is using the intended account and region, then bootstrap that AWS environment as directed by the README. Bootstrapping prepares the account and region for CDK deployments.
- Deploy the stack. From the project directory, run
npm run cdk deploy, the deployment command named in the README. Review the proposed changes and approve the deployment when prompted. - Check the deployed resources and access path. Confirm that the expected ECS services, load balancer, service discovery/connectivity, IAM roles, secrets, and networking were created. Validate that the agent can reach its MCP services and that the Bedrock model access is configured for the deployed region.
The README’s sample output reports 362.32 seconds, but that is repository-provided example output with no established measurement date; it is not a benchmark or a deployment-time promise. A separate AWS ECS article estimates 30–40 minutes for its own CloudFormation/Nova walkthrough, not for this CDK deployment.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Adapt the sample safely for your tools
Define each tool’s downstream permissions
Give each MCP server only the AWS permissions its tools require. The example’s bucket-list-only AWS API permissions are deliberately narrower than broad account access; do not expand that scope without a specific need. If a tool reads or writes other resources, scope its task role to the required actions and resources, and consider separating tools with materially different privileges into distinct services or roles.
Rank #3
Secure both sides of the MCP boundary
There are two authorization questions: which client or agent may call an MCP tool, and what the MCP server may do against downstream systems. An API key in an x-api-key header is one mechanism used by the sample’s load-balancer example, not a complete authorization policy. For a public remote connector, protect the HTTPS endpoint with a suitable authentication method, authorize individual tools and operations, and account for tenant separation. For the Bedrock agent design, restrict service access within the VPC and avoid assuming that private networking alone provides application-level authorization.
Keep direct AWS access in scope
If the agent or its user can also run shell commands or AWS CLI calls, those calls can reach AWS APIs without passing through MCP. MCP-specific controls therefore do not replace least-privilege IAM roles or broader AWS account and organization guardrails.
Rank #4
Choose networking and session behavior deliberately
For an agent and MCP server that are both intended to run inside the VPC, private service-to-service communication can be appropriate. AWS’s ECS walkthrough demonstrates that pattern with the UI exposed and the agent-to-MCP traffic kept within the VPC. By contrast, a Claude remote custom connector must reach a public HTTPS endpoint from Anthropic’s infrastructure. Do not make that connector depend on a private-only service address.
Recommended Free Tools
For horizontally replicated servers, stateless Streamable HTTP can avoid dependence on session affinity. If a workflow is stateful and uses an Mcp-Session-Id, decide how sessions are maintained and routed before adding replicas; the session behavior must match the load-balancing and scaling design.
Best Value
Other ways to connect Claude and ECS
If the goal is for Claude Code or another assistant to inspect and troubleshoot ECS itself, AWS documents a managed Amazon ECS MCP server. The documented service is in preview and subject to change; it uses AWS IAM permissions and MCP Proxy for AWS to sign requests with SigV4. It is an alternative for ECS operations, not a self-built MCP server deployed to Fargate with CDK.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




