08-10 DecemberWebinar: AWS re:Invent 2026 re:CapRegister now (pl)
21 min read

MCP Server on AWS: Secure Setup with AgentCore and Claude

How to run a secure MCP server on AWS with Amazon Bedrock AgentCore and Cognito, and connect it to Claude. A step-by-step guide based on our experience.



AI assistants are only as useful as the systems they can reach, and only as safe as the way they reach them. Here’s how we give Claude governed, audited access to internal tools by running an MCP server on AWS, on Amazon Bedrock AgentCore, protected by Amazon Cognito.

What should business leaders know about MCP servers on AWS? (TL;DR)

Why don’t local MCP servers scale in a company?

Most teams we talk to meet the Model Context Protocol the same way: someone finds an MCP server on GitHub, adds it to their Claude config, and it runs as a local process on their laptop. It works, and it’s a great way to learn. We started exactly like that ourselves.

Then a second person wants the same tool, then a whole team. Suddenly every laptop runs its own copy, with its own version, its own API keys in a dotfile, and no log anywhere of who called what. If a key to your ticketing system leaks, you can’t tell from whose machine. For a CTO or CISO, that’s shadow IT with direct access to company data.

The fix is to stop treating MCP servers as services you install and start treating them as something you deploy: one MCP server on AWS, hosted in your own account, shared by every authorized agent and user. This guide shows how we do exactly that, based on our webinar from October 2026. It’s written so that engineers can follow every step:

Architecture of an MCP server on AWS: Claude Code signs in through Amazon Cognito and calls a FastMCP server on Amazon Bedrock AgentCore Runtime, which calls the SWAPI API

The setup we'll build: Claude Code signs in through Amazon Cognito and calls an MCP server running on AgentCore Runtime.

What changes when you move MCP servers to AWS?

Local MCP (on each laptop)Remote MCP server on AWS
SecurityAPI keys stored in files on many machinesNo long-lived secrets on laptops; users sign in with their own identity
Audit & complianceNo central record of who called which toolCentral authentication and logs (Amazon CloudWatch)
Access controlWhoever has the key has accessAccess decided per user and per app client; can be tightened with scopes, groups and Cedar policies
Change managementEvery user updates (or doesn’t) on their ownUpdate once; immutable versions with dev / prod endpoints
CostHidden: duplicated setup and support per personPay per second for actual use; nothing runs when nobody is working
ScalabilityEach new user = another installationEach new user = one sign-in

What is the Model Context Protocol (MCP)?

The Model Context Protocol is an open standard for connecting AI applications to tools and data. We like to describe it as a universal adapter: build the integration once, and any MCP-compatible assistant or agent can use it, today Claude, tomorrow whatever comes next. That protects your integration investment from vendor lock-in.

MCP has three roles:

Client and server talk JSON-RPC. The server exposes three kinds of primitives:

PrimitiveWhat it is
toolsActions the model can call. In our projects, by far the most used primitive.
resourcesRead-only data and context, addressed by URI.
promptsReady-made interaction templates shipped by the server.

There are two transports. stdio runs the server as a local child process of the host. Streamable HTTP runs it as a remote service that the host reaches over the network. That second option is what makes central governance possible.

Model Context Protocol overview: a host with an MCP client, an MCP server built with FastMCP, and company systems and data, with the three MCP primitives: tools, resources and prompts

The three MCP roles and the three primitives a server can expose.

Local vs remote MCP server: which one does your team need?

Picture a company with three MCP servers: one for the internal knowledge base, one for the ticketing system, and our SWAPI demo. On the other side are the agents: Claude Code on engineers’ laptops, agents running on AWS, and whatever MCP clients come next.

With stdio, every user runs every server as a process on their own machine. Secrets and versions are scattered across laptops, and there’s no central audit or access control.

With Streamable HTTP, each server is deployed once and shared by many agents and users. Authentication (OAuth) and logs are central, and when you update a tool, you update it in one place.

Local vs remote MCP servers: remote MCP servers on AWS sit between AI agents and company systems and are deployed once instead of on every laptop

Local servers multiply with every user; remote servers are deployed once and shared.

What this means for your company:

The number of integrations you maintain grows with the number of systems, not the number of people. From our experience, that’s what makes AI adoption affordable to scale from a pilot team to the whole organization.

Where should you run an MCP server on AWS?

A remote MCP server is, in the end, an HTTP service, so you have several options on AWS. The choice is a trade-off between control and operational effort, which translates directly into team time and running costs. Here’s how we compare them:

ServiceWhen it fitsWhat to watch out for
AWS LambdaSimple, stateless tools; pay per invocationStreaming requires the Lambda Web Adapter; 15-minute limit
Amazon ECS Fargate + ALBFull control over the container and network; a pattern from AWS Solutions GuidanceAuth, scaling and patching are on you; ALB idle timeout of 60 s
Amazon EKSYou already run a Kubernetes platformThe highest operational overhead
AgentCore Runtime(our choice)Serverless for agents and MCP servers; one session = one microVM; OAuth and IAM built inARM64 container; a fixed contract of 0.0.0.0:8000/mcp
AgentCore GatewayTurning existing APIs and Lambdas into MCP tools; aggregating many serversA facade over existing services, not hosting for your server code

For a server you write yourself, we’ve found that AgentCore Runtime takes the most work off your plate: no clusters to patch, no load balancers to tune, security built in. That’s where we’ll deploy.

What is Amazon Bedrock AgentCore?

AgentCore is AWS’s platform for running agents in production, generally available since 13 October 2025. It works with any framework and any model, and it’s modular: you pay for and adopt only the pieces you need. Today we use two of them, Runtime and Gateway, but it’s worth knowing what else is in the box, because these are the building blocks of a production AI platform:

Newer modules added in 2026 include Harness, Optimization, Registry and Payments.

Amazon Bedrock AgentCore modules: Runtime, Gateway, Identity, Memory, Code Interpreter, Browser, Observability, Policy and Evaluations

AgentCore is modular; for an MCP server you need Runtime, and optionally Gateway in front.

How does AgentCore Runtime host an MCP server?

Runtime is a serverless environment for agents and MCP servers. The key idea: every session gets its own microVM, with isolated CPU, memory and filesystem. When the session ends, the memory is wiped. One user’s session can never see another’s state, which, in our experience, is the first thing security and compliance teams ask about.

The key numbers to remember:

ValueWhat it means
1:1one session = one dedicated microVM
8 hmaximum session lifetime (default, configurable)
15 minidle timeout (default)
2 vCPU / 8 GBmaximum resources per session

On top of that, Runtime speaks HTTP, MCP, A2A and AG-UI, supports inbound auth with either IAM SigV4 or OAuth (JWT), bills per second for actual CPU and memory use, and gives you immutable versions with named endpoints such as DEFAULT, dev or prod.

What this means for your company:

You pay for usage, not for capacity sitting idle. Immutable versions give you safe releases and instant rollback, so a faulty update to a tool doesn’t become an incident.

When do you need AgentCore Gateway?

Gateway solves a different problem. Instead of running your code, it puts one virtual MCP endpoint in front of things you already have: AWS Lambda functions, OpenAPI or Smithy specs, Amazon API Gateway APIs, and other MCP servers (including ones on Runtime). On top it adds semantic tool search, inbound and outbound auth (OAuth, IAM, API keys), Cedar policies and call limits.

In short: Runtime runs your code. Gateway exposes existing APIs and servers as a single MCP endpoint, and a server on Runtime can be one of its targets. For one hand-written server, Runtime alone is enough.

Amazon Bedrock AgentCore Gateway aggregating Lambda functions, OpenAPI specs, API Gateway APIs and other MCP servers behind one MCP endpoint for AI agents

Gateway aggregates existing tools behind one MCP endpoint; Runtime hosts your own server code.

What this means for your company:

APIs you’ve already built can be made available to AI agents without rewriting them, which protects past investments and shortens time to value.

How do you build an MCP server for AWS?

What does a minimal FastMCP server look like?

FastMCP turns plain Python functions into MCP tools. The whole server can fit on one screen:

# src/mcp_server/main.pyfrom fastmcp import FastMCPmcp = FastMCP("My MCP Server")@mcp.tooldef greet(name: str) -> str:    """Greet someone by name."""    return f"Hello, {name}!"if __name__ == "__main__":    mcp.run(        transport="http",        host="0.0.0.0",  # not 127.0.0.1        port=8000,        stateless_http=True,    )

In our experience, four details make the difference between “works on my machine” and “works on AgentCore”:

What does AgentCore Runtime require from an MCP server?

AgentCore Runtime doesn’t need to know anything about your framework, but your container has to keep a few promises:

AreaRequirementWhy
Platformlinux/arm64Image in Amazon ECR, built with docker buildx
Listen on0.0.0.0:8000Not localhost: traffic comes from outside the container
PathPOST /mcpStreamable HTTP; responds with JSON or SSE
Modestateless_http=TrueRecommended. Stateful mode (elicitation, sampling) is available since March 2026
SessionMcp-Session-IdAssigned by the platform; the client sends it back to reach the same microVM
ErrorsHTTP 200 + JSON-RPC errorExceptions: 401 and 403 (auth) and 406 (wrong Accept header)
AlternativeDirect code deployA zip in Amazon S3 instead of a container; dependencies must also be built for arm64
Warning:

In our deployments, the arm64 requirement is the one that bites most often. An image built on an x86 laptop without --platform linux/arm64 will push to ECR just fine and then fail to start in Runtime.

How do you containerize the MCP server?

We use uv for dependency management, which keeps the image small and the builds reproducible:

FROM python:3.13-slimCOPY --from=ghcr.io/astral-sh/uv:0.9.5 /uv /uvx /bin/WORKDIR /appENV UV_COMPILE_BYTECODE=1COPY pyproject.toml uv.lock ./RUN uv sync --locked --no-install-projectCOPY . /appRUN uv sync --lockedEXPOSE 8000CMD ["uv", "run", "src/mcp_server/main.py"]

How do you deploy the MCP server to AgentCore Runtime?

Getting the server live is four steps:

  1. Build for arm64 with docker buildx --platform linux/arm64. On a Mac with Apple Silicon this is native.
  2. Push to Amazon ECR, into a private repository (ours lives in eu-central-1).
  3. Create the Agent Runtime with the MCP protocol, PUBLIC network mode, an IAM role, and a JWT authorizer (more on that in the next section).
  4. Use the DEFAULT endpoint, which always points to the latest version. Every configuration change creates a new immutable version.

Steps 1-2 are three commands:

export ECR=<account-id>.dkr.ecr.eu-central-1.amazonaws.comaws ecr get-login-password | docker login -u AWS --password-stdin $ECRdocker buildx build --platform linux/arm64 -t $ECR/<repo>:latest --push .
AgentCore Runtime console showing a deployed MCP server: version 3, status Active, endpoint DEFAULT, compute type microVMs

The deployed runtime in the AgentCore console: version 3 is active behind the DEFAULT endpoint. Every configuration change creates a new immutable version.

How do you secure an MCP server on AWS?

A public MCP endpoint without authentication is an open door into whatever your tools can reach: your CRM, your tickets, your documents. Closing that door properly is what separates an experiment from something your security team will sign off on.

Should you use IAM SigV4 or OAuth for MCP authentication?

AgentCore Runtime offers two inbound auth mechanisms:

AspectIAM SigV4 (default)OAuth 2.0 / JWT (our choice)
How it worksRequests are signed with AWS credentialsA bearer token from an IdP: Amazon Cognito, Microsoft Entra ID, Okta…
Best forAWS-to-AWS traffic: agents, Lambdas, servicesUsers and clients outside AWS, such as Claude Code
Access controlIAM policies and resource-based policiesdiscoveryUrl plus allowedClients, allowedAudience, allowedScopes or customClaims
Without credentials403, with no hint for the MCP client401 + WWW-Authenticate pointing to the metadata (RFC 9728), so the MCP client discovers the authorization server on its own

That last row is why we chose OAuth for Claude Code. A 401 with the right header lets the client start the login flow by itself. A bare 403 leaves it stuck.

What this means for your company:

OAuth works with the identity provider you already use. Joiners, leavers and permission changes are handled where they are today, in your IdP, so offboarding an employee also cuts their AI tools’ access to company systems.

Important:

One Runtime supports one mechanism: SigV4 or JWT, not both at once. If you need both humans and AWS services to call the same server, plan for it up front (for example, M2M tokens via Cognito client_credentials for the services).

Should the MCP server run in PUBLIC or VPC network mode?

There are two separate network questions here, and it helps to keep them apart.

Outbound: where can the Runtime reach? That’s networkMode. With PUBLIC, the Runtime has internet access, which our server needs to call SWAPI. With VPC, it gets ENIs in your subnets and can reach private databases and services; internet only via a NAT gateway.

Inbound: who can call the Runtime? Calls always go through an AgentCore endpoint, either the public one or a VPC endpoint (PrivateLink). You can restrict callers to a network with a resource-based policy using aws:SourceVpc or aws:SourceVpce. Agents inside AWS can authenticate machine-to-machine, with Cognito client_credentials or IAM SigV4.

Our choice:PUBLIC mode and the public endpoint, protected with OAuth. Claude Code connects from a laptop over the internet, so access is decided by the token, not by the network address. For servers that touch sensitive internal data, we recommend VPC mode, which keeps traffic to your databases inside your private network.

How does the OAuth 2.1 flow with PKCE work for MCP?

Here’s what happens the first time Claude Code talks to the server:

  1. Claude Code sends POST /mcp without a token.
  2. Runtime answers 401 with a WWW-Authenticate header.
  3. Claude Code fetches the OIDC metadata from Cognito.
  4. It opens Cognito’s Managed Login in the browser, with PKCE (S256).
  5. After sign-in, Cognito redirects to localhost:8080/callback?code=….
  6. Claude Code exchanges the code plus its code_verifier for an access token.
  7. It retries POST /mcp with Authorization: Bearer <token>.
  8. Runtime validates the JWT (signature, iss, client_id), and only then is the request routed to a microVM.

The user sees none of the plumbing. They click Authenticate, sign in, and they’re back in the terminal. We’ve noticed that strong security which doesn’t get in people’s way is security they won’t try to work around.

OAuth 2.1 with PKCE sequence diagram for MCP authentication between Claude Code, Amazon Cognito and AgentCore Runtime

The full OAuth 2.1 + PKCE flow. Only steps 4-5 are visible to the user.

How do you set up Amazon Cognito for MCP authentication?

Amazon Cognito acts as the authorization server. The setup takes six steps:

Step 1: User pool and an SPA app client. Choose the Single-page application type. It creates a public client with no client secret, which is what a CLI on a laptop should be: there’s nowhere safe to keep a secret anyway, and PKCE takes its place.

Step 2: The Essentials plan. Managed Login requires the Essentials or Plus plan. Lite only offers the classic Hosted UI.

Step 3: A domain. Either a prefix domain (<prefix>.auth.eu-central-1.amazoncognito.com) or your own domain, with an ACM certificate in us-east-1.

Step 4: Managed Login style. Set the domain’s branding version to Managed login and assign a style to the app client.

Step 5: Login pages for the app client. Callback URL http://localhost:8080/callback, grant type Authorization code, scope openid.

Step 6: A test user.Users → Create user. You can test the login right away on the Managed Login page.

Amazon Cognito app client login pages settings for an MCP server: callback URL http://localhost:8080/callback, authorization code grant and openid scope

The app client's managed login pages: a localhost callback for Claude Code, the authorization code grant, and the openid scope.

Amazon Cognito Managed Login sign-in page that users see when authenticating to the MCP server from Claude Code

The Managed Login page your users see after choosing Authenticate in Claude Code.

Tip:

Cognito only redirects to callback URLs that match exactly. The port in http://localhost:8080/callback must be the same as callbackPort in the Claude Code configuration (we’ll set it later), otherwise sign-in ends with a redirect_mismatch error.

How do you configure the JWT authorizer in AgentCore Runtime?

The last piece ties Runtime to Cognito. When creating the runtime, add this to authorizerConfiguration:

"authorizerConfiguration": {  "customJWTAuthorizer": {    "discoveryUrl": "<COGNITO_DISCOVERY_URL>",    "allowedClients": ["<APP_CLIENT_ID>"]  }}

The discovery URL for Cognito has this shape:

https://cognito-idp.eu-central-1.amazonaws.com/<pool-id>/.well-known/openid-configuration

Which validation fields to use is less obvious than it looks:

Every condition you set must be satisfied. Our recommendation: start with allowedClients, confirm the flow works, then tighten with scopes or claims. This is where governance becomes concrete: for example, only members of the Support group can use the ticketing tools.

How do you connect an MCP server on AWS to Claude?

What is the MCP server URL on AgentCore?

The URL of an MCP server on AgentCore is built from four parts:

  1. https://bedrock-agentcore.eu-central-1.amazonaws.com - the AgentCore data-plane endpoint in your region.
  2. /runtimes/ - the resource type.
  3. arn%3Aaws%3Abedrock-agentcore%3Aeu-central-1%3A<account>%3Aruntime%2F<name-id> - the runtime ARN, URL-encoded (: becomes %3A, / becomes %2F).
  4. /invocations?qualifier=DEFAULT - the invocation; the qualifier selects the endpoint (DEFAULT unless you’ve created others).

Put together:

https://bedrock-agentcore.<region>.amazonaws.com/runtimes/<ENCODED_ARN>/invocations?qualifier=DEFAULT
Tip:

Don’t encode the ARN by hand. python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "<ARN>" does it in one line.

How do you register a remote MCP server in Claude Code?

One command adds the server, including its OAuth configuration:

claude mcp add-json webinar '{  "type": "http",  "url": "<RUNTIME_URL>",  "oauth": {    "clientId": "<APP_CLIENT_ID>",    "callbackPort": 8080,    "authServerMetadataUrl": "<COGNITO_DISCOVERY_URL>",    "scopes": "openid"  }}'

By default the configuration is saved in ~/.claude.json (local or user scope). With --scope project, it goes into .mcp.json in the repository instead, so the whole team gets the server when they clone the repo, and each person still signs in as themselves.

The same configuration works in the Claude Code CLI and in the Code tab of Claude Desktop.

What this means for your company:

Rolling the tools out to a new team member takes minutes: clone the repo, sign in, done. No tickets for API keys, no setup guides that go out of date.

What happens when you sign in and make the first call?

  1. Run /mcp in Claude Code and select the webinar server.
  2. Choose Authenticate. The browser opens Amazon Cognito’s Managed Login.
  3. After sign-in, Amazon Cognito redirects to localhost:8080/callback.
  4. Claude Code exchanges the code for a token and stores it securely.
  5. The server’s tools are now available in the conversation.
Claude Code MCP servers dialog showing the remote MCP server on AWS connected with 12 tools, with Re-authenticate and Clear authentication options

Signed in: the webinar server is connected with all twelve SWAPI tools. Re-authenticate and Clear authentication manage the stored OAuth token.

What does a working MCP server on AWS look like? Our Star Wars demo

To show the whole chain working end to end, we built an MCP server for our webinar on top of SWAPI, the Star Wars API. It’s a FastMCP server running on AgentCore Runtime, protected by Amazon Cognito, and it exposes the six SWAPI resources (people, planets, films, species, vehicles and starships), each with a search_* and a get_* tool: search_people, get_person, search_planets, get_planet, and so on.

A tool in that server looks like this (simplified):

import httpxfrom fastmcp import FastMCPmcp = FastMCP("SWAPI")SWAPI = "https://swapi.dev/api"@mcp.tooldef search_people(query: str) -> list[dict]:    """Search Star Wars characters by name."""    r = httpx.get(f"{SWAPI}/people/", params={"search": query}, timeout=10)    r.raise_for_status()    return r.json()["results"]

With the server connected, you ask Claude questions in plain language and it decides which tools to call. A simple “can you use webinar mcp tools?” is enough for a first check: Claude loads the webinar tools, picks get_person, and calls it with ID 1. The request goes through AgentCore Runtime to SWAPI and comes back with Luke Skywalker’s record. No glue code, no copy-pasting between browser tabs.

Claude Code calling the get_person tool of the MCP server on AWS with ID 1 and receiving Luke Skywalker's record from SWAPI

The first call: Claude loads the webinar tools and calls get_person, which returns Luke Skywalker straight from SWAPI.

Now swap SWAPI for your internal knowledge base, your ticketing system or your CRM. An employee asks “what’s the status of the open tickets for client X?” and gets an answer from live company data, under their own identity, with every call logged. That’s the same setup a real team would use: one server, one login, one audit trail.

What are the most common mistakes when deploying MCP servers on AWS?

These are the lessons we keep coming back to. They don’t belong to any single step, but they will save your team debugging time:

What should you decide before rolling out MCP servers in your company?

Before connecting AI assistants to company systems, we always go through these questions with our clients:

  1. Which systems deliver the most value first? A knowledge base, ticketing or CRM are typical starting points.
  2. Who should have access, and to what? This defines your scopes, groups and policies.
  3. Which identity provider do you use? Amazon Cognito, Entra ID and Okta all work with the same pattern.
  4. Does the data need to stay in a private network? That decides between PUBLIC and VPC mode.
  5. Will only people call the tools, or also automated agents? That decides between OAuth, SigV4 or both on separate runtimes.

Is running MCP servers on AWS worth it for your company?

Running an MCP server on your own laptop is how you learn MCP. Running an MCP server on AWS is how a company actually uses it.

With AgentCore Runtime, the hosting part comes down to a small FastMCP app, a Dockerfile and three commands. Each session gets an isolated microVM, and you pay only for what’s used. Amazon Cognito and a JWT authorizer add a real login, without a single long-lived secret on anyone’s machine. And because the endpoint follows the MCP authorization spec, Claude Code discovers the login flow on its own: one claude mcp add-json command, one click on Authenticate, and the tools are there.

The result is a repeatable pattern, not a one-off project: every internal API your agents need can become its own MCP server, deployed once, protected once, and shared by everyone who’s allowed to use it. When there are enough of them, AgentCore Gateway can put them all behind a single endpoint. That’s the foundation of a governed AI platform that grows with your organization instead of against your security policies.

Want to connect your company’s tools to Claude securely?

At Chaos Gears we design and deploy AI, data and cloud solutions on AWS, from the first proof of concept to production. If you want to give Claude or your own agents safe access to your company’s tools and data, we can help you:

Use the contact form below this article to talk to our team. For technical questions, you can reach me directly at [email protected] or on LinkedIn.

Resources

Let's talk about your project

We'd love to answer your questions and help you thrive in the cloud.