Copied to Clipboard
get_notes β Retrieves past study notes:
@tool
def get_notes(topic: str) -> str:
"""Retrieve study notes. Use 'all' to see everything."""
notes = _load_notes()
if topic.lower() == "all":
return f"π You've studied {len(notes['topics'])} topics..."
record_quiz_score β Tracks quiz performance:
@tool
def record_quiz_score(topic: str, score: int, total: int) -> str:
"""Record quiz results for progress tracking."""
calculator β For cost estimates:
@tool
def calculator(expression: str) -> str:
"""Evaluate math expressions for pricing calculations."""
Step 3: Streaming Callback
The callback handler prints text as it arrives β no waiting for the full response:
def streaming_callback(**kwargs):
if "data" in kwargs:
print(kwargs["data"], end="", flush=True)
if "current_tool_use" in kwargs and kwargs["current_tool_use"].get("name"):
print(f"\nπ§ Using tool: {kwargs['current_tool_use']['name']}")
Key insight: The callback uses **kwargs (keyword arguments), not positional args. The SDK passes data, current_tool_use, init_event_loop, etc., as keyword arguments.
Step 4: The Agent System Prompt
The system prompt is crucial β it tells the agent how to behave as a tutor:
system_prompt = """You are AWS Study Buddy ππ€
Your behavior:
1. When asked about AWS, SEARCH the docs first, then explain
2. After explaining, ALWAYS save a note using save_note
3. When asked to quiz, create questions from saved notes
4. Be encouraging, use emojis, make learning fun!
"""
Step 5: Combining MCP + Custom Tools
The magic happens when we combine MCP tools with custom tools:
with aws_docs_mcp:
mcp_tools = aws_docs_mcp.list_tools_sync()
all_tools = mcp_tools + [save_note, get_notes, record_quiz_score, calculator]
agent = Agent(
model=model,
tools=all_tools,
callback_handler=streaming_callback
)
The agent now has access to both AWS documentation search AND persistent memory β it can search docs, explain, save notes, and quiz, all in one conversation.
Step 6: Interactive Chat Loop
while True:
user_input = input("\nπ§ You: ").strip()
if user_input.lower() in ("quit", "exit"):
break
print("\nπ€ Study Buddy: ", end="", flush=True)
response = agent(user_input)
print()
7
π¬ Demo: A Real Conversation
π§ You: Explain S3 in simple terms
π€ Study Buddy:
π§ Using tool: search_documentation
π§ Using tool: read_documentation
Amazon S3 (Simple Storage Service) is object storage! πͺ£
Key points:
β’ Store unlimited data as "objects" in "buckets"
β’ 99.999999999% (11 nines) durability
β’ Use cases: backups, static websites, data lakes
β’ Storage classes: Standard, IA, Glacier
π§ Using tool: save_note
π Note saved for 'S3'! You've now studied 1 topic.
π§ You: How much for 100GB in S3 Standard?
π€ Study Buddy:
π§ Using tool: calculator
S3 Standard: 0γγ«.023/GB/month
100 Γγ°γ€ 0γγ«.023 = 2γγ«.30/month π°
π§ You: Quiz me on S3
π€ Study Buddy:
π§ Using tool: get_notes
Q1: How many nines of durability does S3 have?
Q2: What are objects stored inside?
Q3: Name 2 storage classes.
π§ You: 11 nines, buckets, Standard and Glacier
π€ Study Buddy:
π§ Using tool: record_quiz_score
π Excellent! 3/3 (100%) on S3!
π§© Challenges I Faced
1. mem0ai Version Incompatibility
Initially, I tried using mem0_memory from strands-agents-tools for persistent memory. But mem0ai version 1.x removed FAISS and aws_bedrock support, breaking everything.
Solution: Replaced with a simple JSON file-based memory. Itβs simpler, always works, and has zero dependencies.
2. Streaming Callback Signature
The callback handler signature changed across versions. Using def callback(event) or def callback(event, **kwargs) Both failed.
Solution: Use def callback(**kwargs) - The SDK passes everything as keyword arguments.
3. MCP Server Startup
The MCP server needs uvx (from the uv package manager) to run without pre-installation.
Solution: Install uv with pip install uv, then the script uses uvx to auto-download and run the MCP server.
π‘ Key Learnings
-
MCP is powerful β It gives agents access to real, structured data sources without hallucination
-
Simple memory beats complex memory β A JSON file is more reliable than fighting version conflicts
-
System prompts matter β The agentβs behaviour is 90% determined by how you prompt it
-
Streaming makes UX great β Real-time output feels much more responsive than waiting
-
Tool chaining is magic β The agent naturally chains search β explain β save in one turn
π Judging Criteria
6
π Future Improvements
- Add more MCP servers (CDK, Cost Analysis) for a multi-MCP super-agent
- Spaced repetition algorithm for quiz scheduling
- Export study notes as markdown files
- Add a web UI with Flask/Streamlit
- Connect to Bedrock Knowledge Bases for custom documentation
Conclusion
Building an AI agent with MCP + Strands SDK is surprisingly straightforward. The hardest part wasnβt the code it was getting the right package versions installed! Once thatβs sorted, the SDK handles tool routing, streaming, and conversation management beautifully.
The Model Context Protocol is a game-changer for AI agents. Instead of hoping the LLM knows the answer, you can connect it to authoritative data sources. For AWS documentation, this means accurate, up-to-date answers every time.
If youβre learning AWS, try building your own study buddy. The act of building the agent teaches you more about AWS than using it! π
GitHub link: AWS Study Buddy with MCP
Resources
Built with β€οΈ by DD
Thank you for taking the time to read my article! If you found it helpful, feel free to like, share, and drop your thoughts in the comments; Iβd love to hear from you.
If you want to connect or dive deeper into cloud, AI and DevOps, feel free to follow me on my socials:
πΌ LinkedIn
β X (formerly Twitter)
π¨βπ» DEV Community
π‘οΈMedium
π GitHub
πAWS Builder Profile