Build an MCP Server on AWS Bedrock in 30 Minutes (Python Tutorial)

Build an MCP Server on AWS Bedrock in 30 Minutes (Python Tutorial)

Cloud Edventures

Cloud Edventures

11 days agoβ€’10 min
awsAmazon BedrockaiPythonsoftware-engineering
Build MCP Server on AWS Bedrock (2026): Python Tutorial

MCP (Model Context Protocol) is becoming the standard for how AI agents interact with tools.

An MCP server lets AI agents discover and use real-world tools like databases, APIs, and cloud services.

In this guide, you’ll build a production-ready MCP server connected to AWS services β€” and deploy it using Bedrock AgentCore Runtime. :contentReference[oaicite:0]{index=0}


🧠 What is MCP (Model Context Protocol)?

MCP standardizes how AI agents interact with external tools.

  • Agents ask what tools exist
  • Server returns tool schemas
  • Agent calls tools dynamically
  • Server executes and returns results

πŸ‘‰ This removes custom integrations and makes tools reusable across agents.


βš™οΈ What We’re Building

A real MCP server with two tools:

  • query_dynamodb β†’ Query AWS DynamoDB
  • get_s3_summary β†’ List and summarize S3 data

Deployed on AWS Bedrock AgentCore β†’ serverless + scalable.


πŸ§ͺ Part 1: Build the MCP Server

pip install fastmcp boto3

Core idea:

  • Define tools using @mcp.tool()
  • Use clear docstrings (this controls agent behavior)
  • Return structured JSON always

πŸ‘‰ Tool descriptions are critical β€” they guide the agent.


πŸ§ͺ Part 2: Test Locally

claude mcp add aws-tools -- python aws_mcp_server.py

Test by asking:

β€œHow many files are in my S3 bucket?”

πŸ‘‰ Claude will automatically call your tool.


πŸš€ Part 3: Deploy to AWS Bedrock

Steps:

  • Containerize with Docker
  • Push to ECR
  • Deploy via AgentCore Runtime

πŸ‘‰ Result:

  • Serverless MCP execution
  • Auto scaling
  • Session isolation

πŸ” Part 4: The Agentic Loop

The core pattern:

  • Agent receives request
  • Calls tool
  • Gets result
  • Repeats until done

πŸ‘‰ Controlled by stopReason internally.


🚨 3 Things That Break MCP in Production

1. Weak Tool Descriptions

If descriptions are vague, agents call wrong tools or fail.

2. Returning Too Much Data

Large responses overflow context β†’ break reasoning.

3. Unhandled Exceptions

Always return structured JSON β€” never crash the loop.


⚑ New: Stateful MCP Sessions (2026)

Bedrock now supports session-based MCP servers:

  • Elicitation β†’ ask follow-up questions
  • Sampling β†’ generate content inside tools
  • Progress updates β†’ long-running tasks

πŸ‘‰ This enables real production-grade AI workflows.


πŸ”— Learn by Doing (Hands-On AI Labs)

πŸ‘‰ Build real MCP systems with validation and portfolio proof.


πŸ”— Related Articles


❓ FAQs

What is an MCP server?

An MCP server exposes tools that AI agents can discover and use dynamically.

Why use MCP with AWS?

It allows Bedrock agents to interact directly with AWS services like DynamoDB and S3.

Is MCP production-ready?

Yes, especially with Bedrock AgentCore Runtime and session-based execution.

What language is used for MCP servers?

Python is commonly used with frameworks like FastMCP.


What did you think of this article?

42 people reacted to this article

Share this article

Cloud Edventures

Written by Cloud Edventures

View All Articles

Previous

No more articles

Next

No more articles