Building AI Agents with Model Context Protocol (MCP), Amazon Bedrock, Strands, and Athena
This repository is based on the original "AI-AGENTS-WITH-MCP" examples and extends them with a Moneytree Hackdays demo that:
- Exposes AWS Athena as a read-only MCP server
- Wraps that server with a Strands Agent backed by Amazon Bedrock (Claude 3)
- Lets you ask natural-language questions like "Show me 5 wifi transactions" or "Which tables mention salary?" and get SQL-backed answers
- Baseline agents with Bedrock models
- Local tool integration
- Single MCP server connection
- Multi-MCP orchestration
- Custom MCP servers:
- Calculator example (from the original article)
- Moneytree Athena server + Strands Agent (Hackdays scenario)
- A Streamlit portfolio assistant driven by MCP
- Python 3.12+
- Optionally uv for fast Python env + dependency management
- For the Athena demo:
- AWS credentials with access to Athena + S3 query results
- Access to Amazon Bedrock in the desired region (e.g.
ap-northeast-1)
- For production deployment:
- AWS IAM permissions to create roles and policies (see Deployment section)
Install uv (optional but recommended):
pip install uv
uv --versiongit clone https://github.com/<your-username>/mtb-hackdays-agents.git
cd mtb-hackdays-agentsuv venv --python 3.12
source .venv/bin/activate # Linux/macOS
# .venv\Scripts\activate # Windows PowerShelluv pip install -r requirements.txt
# or: pip install -r requirements.txtmtb-hackdays-agents/
βββ README.md
βββ requirements.txt
βββ Dockerfile # Docker container for Streamlit app
βββ streamlit_app.py # Main Streamlit application
βββ AthenaAssistant.png # Demo screenshot
βββ iam/ # IAM configuration files
β βββ trust-policy.json # EC2 trust policy for IAM role
β βββ permissions-policy.json # Permissions policy for Athena/Bedrock
βββ scenario1_single_server/ # Scenario 1: Baseline agent + local tool + doc MCP server
β βββ baseline_agent.py
β βββ agent_with_local_tool.py
β βββ agent_with_doc_mcp.py
βββ scenario2_multi_server/ # Scenario 2: Multi-MCP orchestration
β βββ multi_server_agent.py
βββ scenario3_custom_server/ # Scenario 3: Custom MCP servers
β βββ calculator_server.py # Original calculator MCP example
β βββ calculator_client.py
β βββ mtb_athena_server.py # NEW: Athena MCP server (read-only)
β βββ mtb_athena_client.py # NEW: Simple MCP client / smoke test
β βββ mtb_athena_strands_agent.py # NEW: Strands Agent + Bedrock + Athena MCP
βββ kite_streamlit_app/ # Streamlit + Kite MCP demo
β βββ streamlit_app.py
βββ utils/
βββ streamlit_helpers.py
The easiest way to get started is with the Streamlit application:
# Build the Docker image
docker build -t mtb-athena-assistant .
# Run locally with your AWS credentials
docker run --rm -p 8501:8501 \
-e AWS_REGION=ap-northeast-1 \
-e AWS_ACCESS_KEY_ID=your_access_key \
-e AWS_SECRET_ACCESS_KEY=your_secret_key \
-e AWS_SESSION_TOKEN=your_session_token \
mtb-athena-assistant:latest
# Open http://localhost:8501Once running, try these natural language questions:
- "Show me 5 wifi transactions"
- "Which institutions have the highest number of transactions? Show the top 5 with counts."
- "Which tables mention salary?"
- "Find the top 5 most generously paying companies from the salary capture table"
Note: Deploying to AWS EC2 requires IAM permissions to create roles and policies. If you don't have these permissions (common in corporate environments), ask your AWS administrator to:
- Create an IAM role using the trust policy in
iam/trust-policy.json - Attach a policy using the permissions in
iam/permissions-policy.json - Create an instance profile and attach the role
The required IAM configuration files are provided:
- Trust Policy (
iam/trust-policy.json): Allows EC2 to assume the role - Permissions Policy (
iam/permissions-policy.json): Grants access to Athena, S3, Glue, and Bedrock
# Create the role and policies
aws iam create-role --role-name athena-assistant-ec2-role --assume-role-policy-document file://iam/trust-policy.json
aws iam create-policy --policy-name athena-assistant-permissions --policy-document file://iam/permissions-policy.json
aws iam attach-role-policy --role-name athena-assistant-ec2-role --policy-arn arn:aws:iam::ACCOUNT-ID:policy/athena-assistant-permissions
# Create instance profile
aws iam create-instance-profile --instance-profile-name athena-assistant-instance-profile
aws iam add-role-to-instance-profile --instance-profile-name athena-assistant-instance-profile --role-name athena-assistant-ec2-roleLaunch EC2 instance with the IAM instance profile:
aws ec2 run-instances \
--image-id ami-0abcdef1234567890 \
--instance-type t3.medium \
--iam-instance-profile Name=athena-assistant-instance-profile \
--security-group-ids sg-your-security-group \
--subnet-id subnet-your-subnet \
--user-data file://user-data.shBenefits of IAM role approach:
- No credential expiration issues
- Automatic credential rotation
- More secure than embedding access keys
Baseline examples using a single MCP server:
- Bedrock-backed agent
- Local tool (e.g. Python execution)
- AWS Documentation MCP server (awslabs.aws-documentation-mcp-server)
Run (example):
python scenario1_single_server/agent_with_doc_mcp.pyAgent with access to multiple MCP servers (e.g. AWS Docs + AWS Pricing) to answer richer questions like "Generate a SageMaker fine-tuning research report".
Run:
python scenario2_multi_server/multi_server_agent.pyStart server:
python scenario3_custom_server/calculator_server.pyRun client:
python scenario3_custom_server/calculator_client.pyThis is the main Hackdays demo:
mtb_athena_server.pyexposes read-only Athena tools via MCP:list_tables(database?)describe_table(database, table)run_readonly_query(database, sql, max_rows=50)
mtb_athena_client.pyis a small MCP client to verify everything worksmtb_athena_strands_agent.pywraps those tools in a Strands Agent that:- Uses Amazon Bedrock (Claude 3)
- Generates and executes SQL via the Athena MCP tools
- Explains the results in natural language
Required environment variables (with sensible defaults):
export MTB_ATHENA_WORKGROUP="DataLakeWorkgroup-v3-production"
export MTB_ATHENA_OUTPUT_LOCATION="s3://jp-data-lake-athena-query-results-production/DataLakeWorkgroup-v3-production/"
export MTB_ATHENA_DEFAULT_DB="lakehouse_omoikane_streaming_jp_production"Bedrock model configuration:
# Default is Claude 3 Haiku on Bedrock:
export MTB_BEDROCK_MODEL_ID="anthropic.claude-3-haiku-20240307-v1:0"
# Optional: if you have an inference profile (e.g. for Sonnet):
export MTB_BEDROCK_INFERENCE_PROFILE_ARN="arn:aws:bedrock:ap-northeast-1:...:inference-profile/..."Make sure your AWS credentials + region are configured so that:
- Athena can run queries in the chosen workgroup
- Bedrock calls succeed in the target region (e.g. ap-northeast-1)
Run the basic MCP client:
python scenario3_custom_server/mtb_athena_client.pyThis will:
- Start mtb_athena_server.py as an MCP server over stdio
- Initialize the MCP session
- List tables in lakehouse_omoikane_streaming_jp_production
- Run a sample SELECT * FROM transactions LIMIT 5
You should see a small JSON snippet of transactions if everything is wired up.
Run the interactive agent:
python scenario3_custom_server/mtb_athena_strands_agent.pyYou'll see a prompt like:
π Athena Strands Agent Ready!
Type questions about your data, for example:
β’ 'Show me 5 wifi transactions'
β’ 'Which tables mention salary?'
β’ 'Describe the transactions table'
β’ 'Generate SQL to find negative transactions in transactions'
Type 'exit' to quit.
Example queries:
- Wifi transactions:
Show me 5 wifi transactions - Salary schema discovery:
Which tables mention salary? - Top paying companies:
The lakehouse_experimental_jp_production database contains several tables related to salary data, including the "250911_ai459_pbo_salary_capture_dataset_complete_gold" table. This table appears to have comprehensive salary information for different companies, including average total compensation, salary, and bonus amounts. Given this, what are the top 5 most generously paying companies?
The system prompt is tuned to:
-
Treat Athena as read-only:
- Only SELECT / SHOW / DESCRIBE are allowed
- The MCP server rejects any mutating SQL
-
Discover schemas and relationships using:
- list_tables
- describe_table
-
Infer joins using shared keys (e.g. account_id, user_id, guest_id) and then build SQL that:
- Uses small samples (LIMIT 5 / LIMIT 50)
- Quotes table names starting with digits:
SELECT *
FROM "250911_ai459_pbo_salary_capture_dataset_complete_gold"
LIMIT 5;Interactive app integrating Kite MCP and OpenAI GPT-4o.
Run:
streamlit run kite_streamlit_app/streamlit_app.pyEnter your OpenAI API key in the sidebar, log in to Zerodha Kite when prompted, and start asking portfolio questions.
- Read-only access: The MCP server enforces read-only SQL operations
- No data leaves AWS: All processing happens within your AWS account
- IAM least privilege: Use the minimal permissions provided in
iam/permissions-policy.json - Network security: Configure security groups to restrict access appropriately
Some MCP servers can be launched using uvx. Example:
uvx --from awslabs.aws-documentation-mcp-server@latest awslabs.aws-documentation-mcp-server.exeThe agent examples in this repo demonstrate how to connect to those servers programmatically.
The Moneytree Athena Assistant demonstrates a powerful pattern that could be pre-packaged and deployed within Amazon SageMaker Unified Studio environments. This would provide data scientists and analysts with immediate access to natural language querying capabilities across their organization's data lake.
- Zero setup friction: Data scientists get instant access to Athena querying via natural language
- No SQL expertise required: Junior analysts can explore data without learning complex SQL syntax
- Built-in best practices: Pre-configured with security, performance, and cost optimization
- IAM integration: Inherits existing SageMaker role-based permissions
- Read-only by design: Prevents accidental data modification
- Audit trail: All queries logged through CloudTrail for compliance
- Data lineage: Integration with AWS Glue Data Catalog for governance
- Feature discovery: Helps data scientists discover relevant datasets for ML projects
- Data profiling: Quick statistical summaries and data quality checks
MIT License. Use freely with attribution.

