@ -4,18 +4,22 @@
The Model Context Protocol (MCP) provides a standardized way to create and manage AI agents through a server-client architecture. Running agents on MCP offers several key benefits:
The Model Context Protocol (MCP) provides a standardized way to create and manage AI agents through a server-client architecture. Running agents on MCP offers several key benefits:
- **Standardized Interface** : Consistent API for agent creation and management across different systems
| Benefit | Description |
- **Scalability** : Handle multiple agents simultaneously through a single MCP server
|------------------------|-----------------------------------------------------------------------------|
- **Interoperability** : Agents can be called from any MCP-compatible client
| Standardized Interface | Consistent API for agent creation and management across different systems |
- **Resource Management** : Centralized control over agent lifecycle and resources
| Scalability | Handle multiple agents simultaneously through a single MCP server |
- **Protocol Compliance** : Follows the established MCP standard for AI tool integration
| Interoperability | Agents can be called from any MCP-compatible client |
| Resource Management | Centralized control over agent lifecycle and resources |
| Protocol Compliance | Follows the established MCP standard for AI tool integration |
## Step 1: Setup and Installation
## Step 1: Setup and Installation
### Prerequisites
### Prerequisites
- Python 3.8 or higher
| Requirement |
- pip package manager
|-----------------------|
| Python 3.8 or higher |
| pip package manager |
### Required Packages
### Required Packages
@ -102,7 +106,7 @@ from mcp.client.streamable_http import (
async def create_agent_via_mcp():
async def create_agent_via_mcp():
"""Create and use an agent through MCP using streamable HTTP."""
"""Create and use an agent through MCP using streamable HTTP."""
print("🔧 Starting MCP client connection...")
print(" Starting MCP client connection...")
# Connect to the MCP server using streamable HTTP
# Connect to the MCP server using streamable HTTP
try:
try:
@ -120,7 +124,7 @@ async def create_agent_via_mcp():
print("Listing available tools...")
print("Listing available tools...")
try:
try:
tools = await session.list_tools()
tools = await session.list_tools()
print(f"📋 Available tools: {[tool.name for tool in tools.tools]}")
print(f" Available tools: {[tool.name for tool in tools.tools]}")
except Exception as e:
except Exception as e:
print(f"Failed to list tools: {e}")
print(f"Failed to list tools: {e}")
@ -187,7 +191,7 @@ from mcp.client.streamable_http import (
async def create_agent_via_mcp(session, agent_name, system_prompt, model_name, task):
async def create_agent_via_mcp(session, agent_name, system_prompt, model_name, task):
"""Create and use an agent through MCP using streamable HTTP."""
"""Create and use an agent through MCP using streamable HTTP."""
print(f"🔧 Creating agent '{agent_name}' with task: {task}")
print(f" Creating agent '{agent_name}' with task: {task}")
try:
try:
arguments = {
arguments = {
"agent_name": agent_name,
"agent_name": agent_name,
@ -223,7 +227,7 @@ async def create_agent_via_mcp(session, agent_name, system_prompt, model_name, t
raise
raise
async def main():
async def main():
print("🔧 Starting MCP client connection...")
print(" Starting MCP client connection...")
try:
try:
async with http_client("http://localhost:8000/mcp") as (read, write, _):
async with http_client("http://localhost:8000/mcp") as (read, write, _):
@ -239,7 +243,7 @@ async def main():
print("Listing available tools...")
print("Listing available tools...")
try:
try:
tools = await session.list_tools()
tools = await session.list_tools()
print(f"📋 Available tools: {[tool.name for tool in tools.tools]}")
print(f" Available tools: {[tool.name for tool in tools.tools]}")
except Exception as e:
except Exception as e:
print(f"Failed to list tools: {e}")
print(f"Failed to list tools: {e}")
raise
raise
@ -307,27 +311,33 @@ Here's a complete overview of all the steps needed to set up your agent initiali
### **Step-by-Step Summary:**
### **Step-by-Step Summary:**
1. ** 📦 Package Installation** - Install MCP SDK, FastMCP, Swarms, and dependencies
| Step | Description |
2. ** 🔧 Server Creation** - Create the MCP server with agent creation tool
|------|-------------|
3. ** 🚀 Server Startup** - Run the MCP server to handle client requests
| 1. Package Installation | Install MCP SDK, FastMCP, Swarms, and dependencies |
4. ** 📱 Basic Client** - Create a simple client to run single agents
| 2. Server Creation | Create the MCP server with agent creation tool |
5. ** 🔄 Advanced Client** - Build multi-agent workflows with sequential processing
| 3. Server Startup | Run the MCP server to handle client requests |
| 4. Basic Client | Create a simple client to run single agents |
| 5. Advanced Client | Build multi-agent workflows with sequential processing |
### **What You'll Have After Following These Steps:**
### **What You'll Have After Following These Steps:**
- ✅ **MCP Server** running and ready to handle agent creation requests
| Component | Description |
- ✅ **Single Agent Client** for basic agent tasks
|-----------|-------------|
- ✅ **Multi-Agent Client** for complex, chained workflows
| MCP Server | Running and ready to handle agent creation requests |
- ✅ **Complete System** for dynamic agent creation and management
| Single Agent Client | For basic agent tasks |
- ✅ **Scalable Architecture** that can handle multiple concurrent agent requests
| Multi-Agent Client | For complex, chained workflows |
| Complete System | For dynamic agent creation and management |
| Scalable Architecture | Can handle multiple concurrent agent requests |
### **Key Benefits Achieved:**
### **Key Benefits Achieved:**
- **Standardized Interface** for agent management
| Benefit | Description |
- **Scalable Architecture** for multiple agents
|---------|-------------|
- **Protocol Compliance** with MCP standards
| Standardized Interface | For agent management |
- **Resource Management** for efficient agent lifecycle
| Scalable Architecture | For multiple agents |
- **Interoperability** with any MCP-compatible client
| Protocol Compliance | With MCP standards |
| Resource Management | For efficient agent lifecycle |
| Interoperability | With any MCP-compatible client |
This setup gives you a complete, production-ready system for running AI agents through the Model Context Protocol!
This setup gives you a complete, production-ready system for running AI agents through the Model Context Protocol!
@ -337,10 +347,10 @@ If you'd like technical support, join our Discord below and stay updated on our
| Platform | Link | Description |
| Platform | Link | Description |
|----------|------|-------------|
|----------|------|-------------|
| 📚 Documentation | [docs.swarms.world ](https://docs.swarms.world ) | Official documentation and guides |
| Documentation | [docs.swarms.world ](https://docs.swarms.world ) | Official documentation and guides |
| 📝 Blog | [Medium ](https://medium.com/@kyeg ) | Latest updates and technical articles |
| Blog | [Medium ](https://medium.com/@kyeg ) | Latest updates and technical articles |
| 💬 Discord | [Join Discord ](https://discord.gg/EamjgSaEQf ) | Live chat and community support |
| Discord | [Join Discord ](https://discord.gg/EamjgSaEQf ) | Live chat and community support |
| 🐦 Twitter | [@kyegomez ](https://twitter.com/kyegomez ) | Latest news and announcements |
| Twitter | [@kyegomez ](https://twitter.com/kyegomez ) | Latest news and announcements |
| 👥 LinkedIn | [The Swarm Corporation ](https://www.linkedin.com/company/the-swarm-corporation ) | Professional network and updates |
| LinkedIn | [The Swarm Corporation ](https://www.linkedin.com/company/the-swarm-corporation ) | Professional network and updates |
| 📺 YouTube | [Swarms Channel ](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ ) | Tutorials and demos |
| YouTube | [Swarms Channel ](https://www.youtube.com/channel/UC9yXyitkbU_WSy7bd_41SqQ ) | Tutorials and demos |
| 🎫 Events | [Sign up here ](https://lu.ma/5p2jnc2v ) | Join our community events |
| Events | [Sign up here ](https://lu.ma/5p2jnc2v ) | Join our community events |