|
|
@ -33705,7 +33705,7 @@ The **Model Context Protocol (MCP)** integration enables Swarms agents to dynami
|
|
|
|
agent_name="Financial-Analysis-Agent",
|
|
|
|
agent_name="Financial-Analysis-Agent",
|
|
|
|
agent_description="AI-powered financial advisor",
|
|
|
|
agent_description="AI-powered financial advisor",
|
|
|
|
max_loops=1,
|
|
|
|
max_loops=1,
|
|
|
|
mcp_url="http://localhost:8000/sse", # Your MCP server
|
|
|
|
mcp_url="http://localhost:8000/mcp", # Your MCP server
|
|
|
|
output_type="all",
|
|
|
|
output_type="all",
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -33729,7 +33729,7 @@ The **Model Context Protocol (MCP)** integration enables Swarms agents to dynami
|
|
|
|
agent_description="Comprehensive market analysis agent",
|
|
|
|
agent_description="Comprehensive market analysis agent",
|
|
|
|
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
|
|
|
|
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
|
|
|
|
max_loops=3,
|
|
|
|
max_loops=3,
|
|
|
|
mcp_url="http://production-server:8000/sse",
|
|
|
|
mcp_url="http://production-server:8000/mcp",
|
|
|
|
output_type="json",
|
|
|
|
output_type="json",
|
|
|
|
# Additional parameters for production
|
|
|
|
# Additional parameters for production
|
|
|
|
temperature=0.1,
|
|
|
|
temperature=0.1,
|
|
|
@ -33805,7 +33805,7 @@ graph TD
|
|
|
|
|
|
|
|
|
|
|
|
| Parameter | Type | Description | Default | Example |
|
|
|
|
| Parameter | Type | Description | Default | Example |
|
|
|
|
|-----------|------|-------------|---------|---------|
|
|
|
|
|-----------|------|-------------|---------|---------|
|
|
|
|
| `mcp_url` | `str` | MCP server endpoint | `None` | `"http://localhost:8000/sse"` |
|
|
|
|
| `mcp_url` | `str` | MCP server endpoint | `None` | `"http://localhost:8000/mcp"` |
|
|
|
|
| `output_type` | `str` | Response format | `"str"` | `"json"`, `"all"`, `"dict"` |
|
|
|
|
| `output_type` | `str` | Response format | `"str"` | `"json"`, `"all"`, `"dict"` |
|
|
|
|
| `max_loops` | `int` | Execution iterations | `1` | `3` |
|
|
|
|
| `max_loops` | `int` | Execution iterations | `1` | `3` |
|
|
|
|
| `temperature` | `float` | Response creativity | `0.1` | `0.1-1.0` |
|
|
|
|
| `temperature` | `float` | Response creativity | `0.1` | `0.1-1.0` |
|
|
|
@ -33826,7 +33826,7 @@ graph TD
|
|
|
|
agent_name="Crypto-Trading-Agent",
|
|
|
|
agent_name="Crypto-Trading-Agent",
|
|
|
|
agent_description="Real-time cryptocurrency market analyzer",
|
|
|
|
agent_description="Real-time cryptocurrency market analyzer",
|
|
|
|
max_loops=2,
|
|
|
|
max_loops=2,
|
|
|
|
mcp_url="http://crypto-server:8000/sse",
|
|
|
|
mcp_url="http://crypto-server:8000/mcp",
|
|
|
|
output_type="json",
|
|
|
|
output_type="json",
|
|
|
|
temperature=0.1,
|
|
|
|
temperature=0.1,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -33853,7 +33853,7 @@ graph TD
|
|
|
|
agent_description="Comprehensive financial market analyst",
|
|
|
|
agent_description="Comprehensive financial market analyst",
|
|
|
|
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
|
|
|
|
system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
|
|
|
|
max_loops=4,
|
|
|
|
max_loops=4,
|
|
|
|
mcp_url="http://finance-api:8000/sse",
|
|
|
|
mcp_url="http://finance-api:8000/mcp",
|
|
|
|
output_type="all",
|
|
|
|
output_type="all",
|
|
|
|
temperature=0.2,
|
|
|
|
temperature=0.2,
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -33881,7 +33881,7 @@ graph TD
|
|
|
|
agent_name="Healthcare-Data-Agent",
|
|
|
|
agent_name="Healthcare-Data-Agent",
|
|
|
|
agent_description="Medical data analysis and research assistant",
|
|
|
|
agent_description="Medical data analysis and research assistant",
|
|
|
|
max_loops=3,
|
|
|
|
max_loops=3,
|
|
|
|
mcp_url="http://medical-api:8000/sse",
|
|
|
|
mcp_url="http://medical-api:8000/mcp",
|
|
|
|
output_type="dict",
|
|
|
|
output_type="dict",
|
|
|
|
system_prompt="""
|
|
|
|
system_prompt="""
|
|
|
|
You are a healthcare data analyst. Use available medical databases
|
|
|
|
You are a healthcare data analyst. Use available medical databases
|
|
|
@ -34008,14 +34008,14 @@ graph TD
|
|
|
|
from swarms.schemas.mcp_schemas import MCPConnection
|
|
|
|
from swarms.schemas.mcp_schemas import MCPConnection
|
|
|
|
|
|
|
|
|
|
|
|
mcp_config = MCPConnection(
|
|
|
|
mcp_config = MCPConnection(
|
|
|
|
url="http://server:8000/sse",
|
|
|
|
url="http://server:8000/mcp",
|
|
|
|
headers={"Authorization": "Bearer token"},
|
|
|
|
headers={"Authorization": "Bearer token"},
|
|
|
|
timeout=30,
|
|
|
|
timeout=30,
|
|
|
|
retry_attempts=3
|
|
|
|
retry_attempts=3
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# ✅ Use direct URL instead
|
|
|
|
# ✅ Use direct URL instead
|
|
|
|
mcp_url = "http://server:8000/sse"
|
|
|
|
mcp_url = "http://server:8000/mcp"
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 🚧 Single Server Limitation
|
|
|
|
### 🚧 Single Server Limitation
|
|
|
@ -34025,12 +34025,12 @@ graph TD
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
# ❌ Multiple servers not supported
|
|
|
|
# ❌ Multiple servers not supported
|
|
|
|
mcp_servers = [
|
|
|
|
mcp_servers = [
|
|
|
|
"http://server1:8000/sse",
|
|
|
|
"http://server1:8000/mcp",
|
|
|
|
"http://server2:8000/sse"
|
|
|
|
"http://server2:8000/mcp"
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
# ✅ Single server only
|
|
|
|
# ✅ Single server only
|
|
|
|
mcp_url = "http://primary-server:8000/sse"
|
|
|
|
mcp_url = "http://primary-server:8000/mcp"
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
### 🚧 Sequential Execution
|
|
|
|
### 🚧 Sequential Execution
|
|
|
@ -34056,7 +34056,7 @@ graph TD
|
|
|
|
**Solutions**:
|
|
|
|
**Solutions**:
|
|
|
|
```bash
|
|
|
|
```bash
|
|
|
|
# Check server status
|
|
|
|
# Check server status
|
|
|
|
curl -I http://localhost:8000/sse
|
|
|
|
curl -I http://localhost:8000/mcp
|
|
|
|
|
|
|
|
|
|
|
|
# Verify port is open
|
|
|
|
# Verify port is open
|
|
|
|
netstat -tulpn | grep :8000
|
|
|
|
netstat -tulpn | grep :8000
|
|
|
@ -34125,7 +34125,7 @@ graph TD
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
# Increase timeout
|
|
|
|
# Increase timeout
|
|
|
|
agent = Agent(
|
|
|
|
agent = Agent(
|
|
|
|
mcp_url="http://server:8000/sse",
|
|
|
|
mcp_url="http://server:8000/mcp",
|
|
|
|
timeout=60, # seconds
|
|
|
|
timeout=60, # seconds
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -34158,7 +34158,7 @@ graph TD
|
|
|
|
|
|
|
|
|
|
|
|
agent = Agent(
|
|
|
|
agent = Agent(
|
|
|
|
agent_name="Debug-Agent",
|
|
|
|
agent_name="Debug-Agent",
|
|
|
|
mcp_url="http://localhost:8000/sse",
|
|
|
|
mcp_url="http://localhost:8000/mcp",
|
|
|
|
verbose=True, # Enable verbose output
|
|
|
|
verbose=True, # Enable verbose output
|
|
|
|
output_type="all", # Get full execution trace
|
|
|
|
output_type="all", # Get full execution trace
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -34213,7 +34213,7 @@ graph TD
|
|
|
|
|
|
|
|
|
|
|
|
# Environment variables (.env file)
|
|
|
|
# Environment variables (.env file)
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
MCP_SERVER_URL=https://secure-server.company.com/sse
|
|
|
|
MCP_SERVER_URL=https://secure-server.company.com/mcp
|
|
|
|
MCP_API_KEY=your-secure-api-key
|
|
|
|
MCP_API_KEY=your-secure-api-key
|
|
|
|
MCP_TIMEOUT=30
|
|
|
|
MCP_TIMEOUT=30
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -34353,7 +34353,7 @@ graph TD
|
|
|
|
|
|
|
|
|
|
|
|
agent = Agent(
|
|
|
|
agent = Agent(
|
|
|
|
agent_name="Your-Agent",
|
|
|
|
agent_name="Your-Agent",
|
|
|
|
mcp_url="http://localhost:8000/sse",
|
|
|
|
mcp_url="http://localhost:8000/mcp",
|
|
|
|
output_type="json",
|
|
|
|
output_type="json",
|
|
|
|
max_loops=2
|
|
|
|
max_loops=2
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -53166,7 +53166,7 @@ def get_okx_crypto_volume(symbol: str) -> str:
|
|
|
|
```python
|
|
|
|
```python
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
# Run the MCP server with SSE (Server-Sent Events) transport
|
|
|
|
# Run the MCP server with SSE (Server-Sent Events) transport
|
|
|
|
# Server will be available at http://localhost:8001/sse
|
|
|
|
# Server will be available at http://localhost:8001/mcp
|
|
|
|
mcp.run(transport="sse")
|
|
|
|
mcp.run(transport="sse")
|
|
|
|
```
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
@ -53176,7 +53176,7 @@ if __name__ == "__main__":
|
|
|
|
from swarms import Agent
|
|
|
|
from swarms import Agent
|
|
|
|
|
|
|
|
|
|
|
|
# Method 2: Using direct URL (simpler for development)
|
|
|
|
# Method 2: Using direct URL (simpler for development)
|
|
|
|
mcp_url = "http://0.0.0.0:8001/sse"
|
|
|
|
mcp_url = "http://0.0.0.0:8001/mcp"
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize agent with MCP tools
|
|
|
|
# Initialize agent with MCP tools
|
|
|
|
agent = Agent(
|
|
|
|
agent = Agent(
|
|
|
@ -58363,7 +58363,7 @@ async def swarm_completion():
|
|
|
|
"""Connect to a server over SSE and fetch available swarms."""
|
|
|
|
"""Connect to a server over SSE and fetch available swarms."""
|
|
|
|
|
|
|
|
|
|
|
|
async with Client(
|
|
|
|
async with Client(
|
|
|
|
transport="http://localhost:8000/sse"
|
|
|
|
transport="http://localhost:8000/mcp"
|
|
|
|
) as client:
|
|
|
|
) as client:
|
|
|
|
# Basic connectivity testing
|
|
|
|
# Basic connectivity testing
|
|
|
|
# print("Ping check:", await client.ping())
|
|
|
|
# print("Ping check:", await client.ping())
|
|
|
@ -68979,7 +68979,7 @@ let agent = client
|
|
|
|
.add_stdio_mcp_server("uvx", ["mcp-hn"])
|
|
|
|
.add_stdio_mcp_server("uvx", ["mcp-hn"])
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
// Add SSE MCP server
|
|
|
|
// Add SSE MCP server
|
|
|
|
.add_sse_mcp_server("file-browser", "http://127.0.0.1:8000/sse")
|
|
|
|
.add_sse_mcp_server("file-browser", "http://127.0.0.1:8000/mcp")
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
```
|
|
|
|
```
|
|
|
@ -69016,7 +69016,7 @@ async fn main() -> Result<()> {
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
// Add filesystem tool
|
|
|
|
// Add filesystem tool
|
|
|
|
// To set up: uvx mcp-proxy --sse-port=8000 -- npx -y @modelcontextprotocol/server-filesystem ~
|
|
|
|
// To set up: uvx mcp-proxy --sse-port=8000 -- npx -y @modelcontextprotocol/server-filesystem ~
|
|
|
|
.add_sse_mcp_server("file-browser", "http://127.0.0.1:8000/sse")
|
|
|
|
.add_sse_mcp_server("file-browser", "http://127.0.0.1:8000/mcp")
|
|
|
|
.await
|
|
|
|
.await
|
|
|
|
.retry_attempts(2)
|
|
|
|
.retry_attempts(2)
|
|
|
|
.max_loops(3)
|
|
|
|
.max_loops(3)
|
|
|
|