What you’ll build: An agent that uses MCP servers to interact with external servicesTime: ~20 minutesPrerequisites:
- Completed the Hello World tutorial
- Node.js installed (for npm-based MCP servers)
- Understanding of agents from previous tutorials
What you’ll learn
This tutorial demonstrates:- What MCP (Model Context Protocol) is and why it matters
- Connecting agents to MCP servers (stdio and SSE)
- Using popular MCP servers (filesystem, web search, etc.)
- Creating multi-agent systems with MCP capabilities
- Authentication and configuration
Understanding MCP
Model Context Protocol (MCP) is an open protocol that standardizes how AI applications connect to external data sources and tools.Why use MCP?
Standardized Integration
One protocol for all tools - no custom integrations needed
Growing Ecosystem
Access hundreds of pre-built MCP servers
Vendor Neutral
Works with any LLM or AI framework
Easy to Build
Create your own MCP servers simply
MCP architecture
Step-by-step guide
Example 1: Filesystem MCP server
The filesystem MCP server gives your agent safe access to read and write files.Create Create the workspace directory:Run the agent:Test it:
filesystem_agent.yaml:filesystem_agent.yaml
Example 2: Remote MCP server with SSE
SSE (Server-Sent Events) allows connecting to remote MCP servers. Let’s use the Atlassian MCP server:Create
atlassian_agent.yaml:atlassian_agent.yaml
The Atlassian MCP server requires authentication. Follow the setup in your Atlassian account to configure OAuth2.
Example 3: Multiple MCP servers
You can combine multiple MCP servers in one agent:Create the research directory:Add your Brave API key to Test the research agent:
multi_mcp_agent.yaml
.env:MCP connection types
STDIO (Standard Input/Output)
SSE (Server-Sent Events)
Docker containers
Building your own MCP server
Simple Python MCP server
Simple Python MCP server
Create a custom MCP server in Python:Use it in your agent:
custom_mcp_server.py
TypeScript MCP server
TypeScript MCP server
Create a custom MCP server in TypeScript:
custom-server.ts
Multi-agent MCP architecture
Create specialized agents with different MCP capabilities:Next steps
Custom Gateway
Build custom gateways for your agents
Multi-Agent Collaboration
Create collaborative agent teams
Complex Workflows
Build advanced workflow patterns
MCP Documentation
Official MCP protocol documentation
Troubleshooting
MCP server not starting
MCP server not starting
Problem: “Failed to start MCP server”Solution:
- Test the command manually:
- Check Node.js is installed:
node --version - Verify the package name is correct
- Check logs for specific error messages
Tool not found errors
Tool not found errors
Problem: “Tool ‘read_file’ not found”Solution:
- Wait for MCP server initialization (check logs)
- Verify the MCP server provides that tool
- Restart the agent after configuration changes
- Check for tool name typos in instructions
Authentication failures
Authentication failures
Problem: “OAuth2 authentication failed”Solution:
- Verify credentials in
.envfile - Check token hasn’t expired
- Ensure proper scopes are requested
- Review MCP server documentation for auth requirements
Permission errors
Permission errors
Problem: “Permission denied accessing /path”Solution:
- Ensure the path exists and is accessible
- Check file/directory permissions
- Use absolute paths instead of relative paths
- Verify the user running the agent has access
Key concepts learned
- Understanding Model Context Protocol (MCP)
- Configuring stdio and SSE MCP connections
- Using popular MCP servers
- Building multi-MCP-server agents
- Authentication and security
- Creating custom MCP servers