So far in this series, we've built custom tools and taught agents how to interact with the outside world.
But what if someone else has already built the tools you need?
Instead of writing every integration yourself, you can connect your AI agent to an MCP Server.
Model Context Protocol (MCP) is an open standard that allows AI agents to discover and use tools provided by external systems.
In this lab, you'll connect a Strands Agent to the AWS Documentation MCP Server and allow the agent to retrieve factual AWS documentation directly from official sources.
By the end of this lab, you'll have an AWS Documentation Assistant powered by MCP.
🚀 What You'll Learn
In this lab, you'll learn:
- What MCP (Model Context Protocol) is
- Why MCP is becoming important in Agentic AI
- How to connect to an MCP server
- How to use STDIO transport
- How agents automatically discover MCP tools
- How to build an AWS Documentation Assistant
🤖 What is MCP?
Model Context Protocol (MCP) is an open protocol that allows AI models and agents to connect to external tools and data sources.
Think of MCP as:
USB for AI Agents
Just as USB allows computers to connect to keyboards, printers, and storage devices, MCP allows AI agents to connect to:
- Documentation systems
- Databases
- APIs
- Search engines
- Internal tools
- Enterprise applications
Without MCP:
Agent
↓
Custom Tool
↓
External System
With MCP:
Agent
↓
MCP Server
↓
Many Tools
One connection can expose dozens of tools instantly.
🛠️ Prerequisites
Before starting, make sure you have:
- Python 3.10+
- AWS Account
- Amazon Bedrock access
- AWS credentials configured
- uv installed
- MCP SDK installed
- Strands SDK installed
Install dependencies:
pip install strands-agents
pip install mcp
🌟 Why MCP Matters
Imagine you're building an AWS assistant.
Without MCP:
Build Tool #1
Build Tool #2
Build Tool #3
Build Tool #4
...
You must create and maintain every integration yourself.
With MCP:
Connect MCP Server
Discover Tools
Start Using Them
The MCP server handles the heavy lifting.
Your agent simply consumes the available tools.
This dramatically reduces development effort.
📜 The Script
Let's start by looking at the complete example.
from strands import Agent, tool
from strands.models.bedrock import BedrockModel
from strands.tools.mcp import MCPClient
from mcp import stdio_client, StdioServerParameters
# Bedrock
bedrock_model = BedrockModel(
model_id="<YOUR_MODEL_ID>",
region_name="eu-west-2",
temperature=0.3,
)
# Connect to an MCP server using stdio transport
stdio_mcp_client = MCPClient(
lambda: stdio_client(
StdioServerParameters(
command="uvx",
args=["awslabs.aws-documentation-mcp-server@latest"]
)
)
)
with stdio_mcp_client:
tools = stdio_mcp_client.list_tools_sync()
agent = Agent(
system_prompt="""
You are an AWS Documentation expert.
Use the tools that are available to provide factual information.
""",
model=bedrock_model,
tools=tools
)
agent("What is AWS Lambda?")
Now let's break it down.
⚙️ Step 1: Import MCP Components
from strands.tools.mcp import MCPClient
from mcp import stdio_client, StdioServerParameters
These imports provide everything required to communicate with an MCP server.
Components
| Component | Purpose |
|---|---|
| MCPClient | Connects Strands to MCP |
| stdio_client | Uses standard input/output transport |
| StdioServerParameters | Configures the MCP server |
⚙️ Step 2: Configure Amazon Bedrock
bedrock_model = BedrockModel(
model_id="<YOUR_MODEL_ID>",
region_name="eu-west-2",
temperature=0.3,
)
This is the reasoning engine behind our agent.
The model decides:
- Which tool to use
- What information to retrieve
- How to respond
⚙️ Step 3: Create the MCP Connection
stdio_mcp_client = MCPClient(
lambda: stdio_client(
StdioServerParameters(
command="uvx",
args=[
"awslabs.aws-documentation-mcp-server@latest"
]
)
)
)
This establishes a connection to the AWS Documentation MCP Server.
Think of it as:
Agent
↓
MCP Client
↓
AWS Documentation MCP Server
The server exposes AWS documentation tools automatically.
⚙️ Step 4: Understanding STDIO Transport
This lab uses STDIO transport.
Agent Process
⇅
Standard Input/Output
⇅
MCP Server Process
STDIO is ideal for:
- Local development
- Local testing
- Lightweight integrations
Because communication happens through process streams, no network setup is required.
⚙️ Step 5: Start the MCP Session
with stdio_mcp_client:
This opens a connection to the MCP server.
Once inside the context manager:
- Server starts
- Tools become available
- Agent can access them
When execution finishes, the connection closes automatically.
⚙️ Step 6: Discover Available Tools
tools = stdio_mcp_client.list_tools_sync()
This is one of the most powerful MCP features.
Instead of manually creating tools:
tools = stdio_mcp_client.list_tools_sync()
The agent automatically discovers everything exposed by the MCP server.
Think of it like:
Connect
↓
Discover Tools
↓
Use Tools
No additional coding required.
⚙️ Step 7: Create the Agent
agent = Agent(
system_prompt="""
You are an AWS Documentation expert.
Use the tools that are available to provide factual information.
""",
model=bedrock_model,
tools=tools
)
Notice something interesting.
We aren't manually registering tools.
Instead:
tools=tools
contains every tool discovered from the MCP server.
The agent now has access to AWS documentation capabilities.
⚙️ Step 8: Ask a Question
agent("What is AWS Lambda?")
The workflow becomes:
User Question
↓
Agent Analysis
↓
MCP Tool Selection
↓
AWS Documentation Search
↓
Documentation Retrieved
↓
Final Response
The answer comes from official AWS documentation rather than relying solely on model memory.
▶️ Run the Agent
Execute the script:
python agent.py
Or:
uv run labs/05-mcp-introduction/agent.py
📊 Example Interaction
User
What is AWS Lambda?
Agent Workflow
Question Received
↓
Discover Documentation Tool
↓
Query AWS Documentation
↓
Retrieve Information
↓
Generate Response
Agent Response
AWS Lambda is a serverless compute service that lets you run code without provisioning or managing servers.
You pay only for the compute time consumed and can automatically scale applications in response to demand.
The exact response may vary depending on the documentation version and model.
🔍 What Makes MCP Different?
Traditional Tool Approach:
Build Tool
Register Tool
Maintain Tool
Update Tool
MCP Approach:
Connect Server
Discover Tools
Use Tools
The MCP server owns the implementation.
Your agent simply consumes capabilities.
This dramatically improves scalability.
💡 Real-World MCP Use Cases
MCP is useful for connecting agents to:
Documentation Systems
AWS Documentation
Azure Documentation
Internal Knowledge Bases
Databases
PostgreSQL
MySQL
MongoDB
Development Tools
GitHub
GitLab
Jira
Cloud Services
AWS
Azure
Google Cloud
Enterprise Systems
CRM
ERP
HR Systems
The possibilities are nearly endless.
🧠 Why Developers Love MCP
Without MCP:
❌ Build every integration yourself
❌ Maintain tool definitions
❌ Handle protocol changes
❌ Create custom wrappers
With MCP:
✅ Discover tools automatically
✅ Reuse existing integrations
✅ Standardized communication
✅ Faster development
✅ Easier maintenance
MCP shifts focus from integration work to solving business problems.
🎯 Key Takeaways
- MCP stands for Model Context Protocol
- MCP allows agents to connect to external tool providers
- STDIO transport is perfect for local development
- Agents can automatically discover available tools
- MCP significantly reduces integration effort
- The AWS Documentation MCP Server provides direct access to official AWS information
📚 Source Code
GitHub Repository:
https://github.com/d3vjamal/strands-agents-labs
🚀 Next Lab
In the next lab, we'll explore remote MCP servers and learn how agents can connect to tools running on different machines and services across the network.
🔗 Continue Learning
⬅️ Previous Lab
Lab 04B: Building a Web Search Tool for AI Agents
➡️ Next Lab
Top comments (0)