chore: restore repository state to commit 8d1d22d for stability

pull/819/head
Pavan Kumar 2 days ago committed by ascender1729
parent cb6eca6784
commit 86cb09ad76

@ -4,7 +4,7 @@ modules = ["python-3.10", "bash"]
channel = "stable-24_05" channel = "stable-24_05"
[workflows] [workflows]
runButton = "Run Multi Server" runButton = "Run MCP Server"
[[workflows.workflow]] [[workflows.workflow]]
name = "Run MCP Tests" name = "Run MCP Tests"
@ -58,41 +58,3 @@ args = "sleep 2"
[[workflows.workflow.tasks]] [[workflows.workflow.tasks]]
task = "shell.exec" task = "shell.exec"
args = "python examples/mcp_example/test_integration.py" args = "python examples/mcp_example/test_integration.py"
[[workflows.workflow]]
name = "Run Multiple MCP"
author = 13983571
mode = "sequential"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "python examples/mcp_example/math_server.py &"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "sleep 2"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "python examples/mcp_example/test_integration.py"
[[workflows.workflow]]
name = "Run Multi Server"
author = 13983571
mode = "sequential"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "python examples/mcp_example/math_server.py &"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "python examples/mcp_example/calc_server.py &"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "sleep 2"
[[workflows.workflow.tasks]]
task = "shell.exec"
args = "python examples/mcp_example/multi_server_test.py"

@ -1,149 +0,0 @@
Multi-Agent MCP Test Environment
Type 'exit' to quit
2025-04-17 16:43:21 | WARNING | swarms.structs.agent:llm_handling:658 - Model name is not provided, using gpt-4o-mini. You can configure any model from litellm if desired.
[2025-04-17 16:43:21] Enter your request (or Ctrl+C to exit): add 5 and 10
[2025-04-17 16:43:21] Processing math request...
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-17 16:43:36 | ERROR | swarms.structs.agent:_run:1089 - Attempt 1: Error generating response: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-17 16:43:37 | ERROR | swarms.structs.agent:_run:1089 - Attempt 2: Error generating response: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
Give Feedback / Get Help: https://github.com/BerriAI/litellm/issues/new
LiteLLM.Info: If you need to debug this error, use `litellm._turn_on_debug()'.
2025-04-17 16:43:38 | ERROR | swarms.structs.agent:_run:1089 - Attempt 3: Error generating response: litellm.AuthenticationError: AuthenticationError: OpenAIException - The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
2025-04-17 16:43:39 | ERROR | swarms.structs.agent:_run:1102 - Failed to generate a valid response after retry attempts.
[2025-04-17 16:43:21] Math calculation result: System: : Your Name: Math-Agent
Your Description: Handles mathematical calculations
### System Prompt for an Agent Specializing in Analyzing Financial and Accounting Statements
---
#### Introduction
Welcome! You are an advanced AI agent designed to analyze financial and accounting statements, extracting and summarizing key statistics and insights. Your primary goal is to provide structured knowledge that highlights the financial health, performance, and trends within an organization. Below, we will detail how you should approach this task, including how to think, reason, and structure your analyses, followed by several examples to illustrate the process.
## Instructions
1. **Understand the Document:**
- Begin by identifying the type of financial statement you are analyzing. Common types include balance sheets, income statements, cash flow statements, and statements of shareholders' equity.
- Determine the reporting period and the currency used.
2. **Identify Key Sections:**
- For balance sheets, focus on assets, liabilities, and shareholders' equity.
- For income statements, focus on revenues, expenses, and net income.
- For cash flow statements, focus on operating, investing, and financing activities.
- For statements of shareholders' equity, focus on changes in equity, including retained earnings and issued shares.
3. **Extract Key Metrics:**
- Calculate and highlight important financial ratios such as liquidity ratios (current ratio, quick ratio), profitability ratios (gross profit margin, net profit margin, return on equity), and solvency ratios (debt-to-equity ratio, interest coverage ratio).
- Identify trends by comparing current figures with those from previous periods.
- Highlight significant changes, unusual items, and potential red flags.
4. **Summarize Clearly and Concisely:**
- Use plain language to explain the financial health and performance of the organization.
- Organize your summary logically, mirroring the structure of the original document.
- Include visual aids like charts or graphs where applicable to illustrate trends and comparisons.
#### Examples
---
**Example 1: Income Statement Analysis**
**Original Text:**
"ABC Corporation's income statement for the fiscal year ended December 31, 2023, reports total revenues of $5,000,000, cost of goods sold (COGS) of $3,000,000, operating expenses of $1,200,000, and net income of $600,000. The previous fiscal year's total revenues were $4,500,000, with a net income of $500,000."
**Summary:**
- **Revenues:** $5,000,000 (up from $4,500,000 in the previous year, an increase of 11.1%)
- **Cost of Goods Sold (COGS):** $3,000,000
- **Operating Expenses:** $1,200,000
- **Net Income:** $600,000 (up from $500,000 in the previous year, an increase of 20%)
- **Gross Profit Margin:** 40% (calculated as (Revenues - COGS) / Revenues)
- **Net Profit Margin:** 12% (calculated as Net Income / Revenues)
- **Key Observations:** Revenue growth of 11.1%, with a significant improvement in net income (20% increase), indicating improved profitability.
---
**Example 2: Balance Sheet Analysis**
**Original Text:**
"As of December 31, 2023, XYZ Ltd.'s balance sheet reports total assets of $10,000,000, total liabilities of $6,000,000, and shareholders' equity of $4,000,000. The previous year's total assets were $9,000,000, total liabilities were $5,500,000, and shareholders' equity was $3,500,000."
**Summary:**
- **Total Assets:** $10,000,000 (up from $9,000,000 in the previous year, an increase of 11.1%)
- **Total Liabilities:** $6,000,000 (up from $5,500,000 in the previous year, an increase of 9.1%)
- **Shareholders' Equity:** $4,000,000 (up from $3,500,000 in the previous year, an increase of 14.3%)
- **Current Ratio:** 1.67 (calculated as Total Assets / Total Liabilities)
- **Debt-to-Equity Ratio:** 1.5 (calculated as Total Liabilities / Shareholders' Equity)
- **Key Observations:** Healthy increase in both assets and equity, indicating growth and improved financial stability. The debt-to-equity ratio suggests a moderate level of debt relative to equity.
---
**Example 3: Cash Flow Statement Analysis**
**Original Text:**
"For the fiscal year ended December 31, 2023, DEF Inc.'s cash flow statement shows net cash provided by operating activities of $700,000, net cash used in investing activities of $300,000, and net cash used in financing activities of $200,000. The beginning cash balance was $100,000, and the ending cash balance was $300,000."
**Summary:**
- **Net Cash Provided by Operating Activities:** $700,000
- **Net Cash Used in Investing Activities:** $300,000
- **Net Cash Used in Financing Activities:** $200,000
- **Net Increase in Cash:** $200,000 (calculated as $700,000 - $300,000 - $200,000)
- **Beginning Cash Balance:** $100,000
- **Ending Cash Balance:** $300,000
- **Key Observations:** Positive cash flow from operating activities indicates strong operational performance. The company is investing in growth while maintaining a healthy cash balance. The ending cash balance shows a significant increase, indicating improved liquidity.
---
**Example 4: Statement of Shareholders' Equity Analysis**
**Original Text:**
"GHI Corporation's statement of shareholders' equity for the fiscal year ended December 31, 2023, shows common stock of $1,000,000, retained earnings of $2,000,000, and additional paid-in capital of $500,000. The previous year's retained earnings were $1,500,000."
**Summary:**
- **Common Stock:** $1,000,000
- **Retained Earnings:** $2,000,000 (up from $1,500,000 in the previous year, an increase of 33.3%)
- **Additional Paid-in Capital:** $500,000
- **Total Shareholders' Equity:** $3,500,000
- **Key Observations:** Significant growth in retained earnings indicates strong profitability and reinvestment in the business. The overall increase in shareholders' equity reflects the company's robust financial health and potential for future growth.
---
By following this structured approach, you will be able to provide thorough and accurate analyses of financial and accounting statements, ensuring that all key metrics and insights are clearly understood.
Human:: add 5 and 10
[2025-04-17 16:43:39] Enter your request (or Ctrl+C to exit):

@ -1,129 +0,0 @@
Multi-Agent MCP Test Environment
Type 'exit' to quit
2025-04-17 16:50:04 | WARNING | swarms.structs.agent:llm_handling:658 - Model name is not provided, using gpt-4o-mini. You can configure any model from litellm if desired.
[2025-04-17 16:50:04] Enter your request (or Ctrl+C to exit): add 2 and 231
[2025-04-17 16:50:04] Processing math request...
╭──────────────── Agent Name: Math-Agent [Max Loops: 1] ─────────────────╮
│ Math-Agent: │
│ <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper │
│ object at 0x7f51bd525990> │
╰────────────────────────────────────────────────────────────────────────╯
[2025-04-17 16:50:04] Math calculation result: System: : Your Name: Math-Agent
Your Description: Handles mathematical calculations
### System Prompt for an Agent Specializing in Analyzing Financial and Accounting Statements
---
#### Introduction
Welcome! You are an advanced AI agent designed to analyze financial and accounting statements, extracting and summarizing key statistics and insights. Your primary goal is to provide structured knowledge that highlights the financial health, performance, and trends within an organization. Below, we will detail how you should approach this task, including how to think, reason, and structure your analyses, followed by several examples to illustrate the process.
## Instructions
1. **Understand the Document:**
- Begin by identifying the type of financial statement you are analyzing. Common types include balance sheets, income statements, cash flow statements, and statements of shareholders' equity.
- Determine the reporting period and the currency used.
2. **Identify Key Sections:**
- For balance sheets, focus on assets, liabilities, and shareholders' equity.
- For income statements, focus on revenues, expenses, and net income.
- For cash flow statements, focus on operating, investing, and financing activities.
- For statements of shareholders' equity, focus on changes in equity, including retained earnings and issued shares.
3. **Extract Key Metrics:**
- Calculate and highlight important financial ratios such as liquidity ratios (current ratio, quick ratio), profitability ratios (gross profit margin, net profit margin, return on equity), and solvency ratios (debt-to-equity ratio, interest coverage ratio).
- Identify trends by comparing current figures with those from previous periods.
- Highlight significant changes, unusual items, and potential red flags.
4. **Summarize Clearly and Concisely:**
- Use plain language to explain the financial health and performance of the organization.
- Organize your summary logically, mirroring the structure of the original document.
- Include visual aids like charts or graphs where applicable to illustrate trends and comparisons.
#### Examples
---
**Example 1: Income Statement Analysis**
**Original Text:**
"ABC Corporation's income statement for the fiscal year ended December 31, 2023, reports total revenues of $5,000,000, cost of goods sold (COGS) of $3,000,000, operating expenses of $1,200,000, and net income of $600,000. The previous fiscal year's total revenues were $4,500,000, with a net income of $500,000."
**Summary:**
- **Revenues:** $5,000,000 (up from $4,500,000 in the previous year, an increase of 11.1%)
- **Cost of Goods Sold (COGS):** $3,000,000
- **Operating Expenses:** $1,200,000
- **Net Income:** $600,000 (up from $500,000 in the previous year, an increase of 20%)
- **Gross Profit Margin:** 40% (calculated as (Revenues - COGS) / Revenues)
- **Net Profit Margin:** 12% (calculated as Net Income / Revenues)
- **Key Observations:** Revenue growth of 11.1%, with a significant improvement in net income (20% increase), indicating improved profitability.
---
**Example 2: Balance Sheet Analysis**
**Original Text:**
"As of December 31, 2023, XYZ Ltd.'s balance sheet reports total assets of $10,000,000, total liabilities of $6,000,000, and shareholders' equity of $4,000,000. The previous year's total assets were $9,000,000, total liabilities were $5,500,000, and shareholders' equity was $3,500,000."
**Summary:**
- **Total Assets:** $10,000,000 (up from $9,000,000 in the previous year, an increase of 11.1%)
- **Total Liabilities:** $6,000,000 (up from $5,500,000 in the previous year, an increase of 9.1%)
- **Shareholders' Equity:** $4,000,000 (up from $3,500,000 in the previous year, an increase of 14.3%)
- **Current Ratio:** 1.67 (calculated as Total Assets / Total Liabilities)
- **Debt-to-Equity Ratio:** 1.5 (calculated as Total Liabilities / Shareholders' Equity)
- **Key Observations:** Healthy increase in both assets and equity, indicating growth and improved financial stability. The debt-to-equity ratio suggests a moderate level of debt relative to equity.
---
**Example 3: Cash Flow Statement Analysis**
**Original Text:**
"For the fiscal year ended December 31, 2023, DEF Inc.'s cash flow statement shows net cash provided by operating activities of $700,000, net cash used in investing activities of $300,000, and net cash used in financing activities of $200,000. The beginning cash balance was $100,000, and the ending cash balance was $300,000."
**Summary:**
- **Net Cash Provided by Operating Activities:** $700,000
- **Net Cash Used in Investing Activities:** $300,000
- **Net Cash Used in Financing Activities:** $200,000
- **Net Increase in Cash:** $200,000 (calculated as $700,000 - $300,000 - $200,000)
- **Beginning Cash Balance:** $100,000
- **Ending Cash Balance:** $300,000
- **Key Observations:** Positive cash flow from operating activities indicates strong operational performance. The company is investing in growth while maintaining a healthy cash balance. The ending cash balance shows a significant increase, indicating improved liquidity.
---
**Example 4: Statement of Shareholders' Equity Analysis**
**Original Text:**
"GHI Corporation's statement of shareholders' equity for the fiscal year ended December 31, 2023, shows common stock of $1,000,000, retained earnings of $2,000,000, and additional paid-in capital of $500,000. The previous year's retained earnings were $1,500,000."
**Summary:**
- **Common Stock:** $1,000,000
- **Retained Earnings:** $2,000,000 (up from $1,500,000 in the previous year, an increase of 33.3%)
- **Additional Paid-in Capital:** $500,000
- **Total Shareholders' Equity:** $3,500,000
- **Key Observations:** Significant growth in retained earnings indicates strong profitability and reinvestment in the business. The overall increase in shareholders' equity reflects the company's robust financial health and potential for future growth.
---
By following this structured approach, you will be able to provide thorough and accurate analyses of financial and accounting statements, ensuring that all key metrics and insights are clearly understood.
Human:: add 2 and 231
Math-Agent: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7f51bd525990>
[2025-04-17 16:50:18] Enter your request (or Ctrl+C to exit):

@ -1,125 +0,0 @@
Multi-Agent MCP Test Environment
Type 'exit' to quit
2025-04-17 16:51:35 | WARNING | swarms.structs.agent:llm_handling:658 - Model name is not provided, using gpt-4o-mini. You can configure any model from litellm if desired.
[2025-04-17 16:51:35] Enter your request (or Ctrl+C to exit): add 123 and 123
[2025-04-17 16:51:35] Processing math request...
╭───────────────────────────────────────── Agent Name: Math-Agent [Max Loops: 1] ──────────────────────────────────────────╮
│ Math-Agent: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7f59b68adbd0> │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
[2025-04-17 16:51:35] Math calculation result: System: : Your Name: Math-Agent
Your Description: Handles mathematical calculations
### System Prompt for an Agent Specializing in Analyzing Financial and Accounting Statements
---
#### Introduction
Welcome! You are an advanced AI agent designed to analyze financial and accounting statements, extracting and summarizing key statistics and insights. Your primary goal is to provide structured knowledge that highlights the financial health, performance, and trends within an organization. Below, we will detail how you should approach this task, including how to think, reason, and structure your analyses, followed by several examples to illustrate the process.
## Instructions
1. **Understand the Document:**
- Begin by identifying the type of financial statement you are analyzing. Common types include balance sheets, income statements, cash flow statements, and statements of shareholders' equity.
- Determine the reporting period and the currency used.
2. **Identify Key Sections:**
- For balance sheets, focus on assets, liabilities, and shareholders' equity.
- For income statements, focus on revenues, expenses, and net income.
- For cash flow statements, focus on operating, investing, and financing activities.
- For statements of shareholders' equity, focus on changes in equity, including retained earnings and issued shares.
3. **Extract Key Metrics:**
- Calculate and highlight important financial ratios such as liquidity ratios (current ratio, quick ratio), profitability ratios (gross profit margin, net profit margin, return on equity), and solvency ratios (debt-to-equity ratio, interest coverage ratio).
- Identify trends by comparing current figures with those from previous periods.
- Highlight significant changes, unusual items, and potential red flags.
4. **Summarize Clearly and Concisely:**
- Use plain language to explain the financial health and performance of the organization.
- Organize your summary logically, mirroring the structure of the original document.
- Include visual aids like charts or graphs where applicable to illustrate trends and comparisons.
#### Examples
---
**Example 1: Income Statement Analysis**
**Original Text:**
"ABC Corporation's income statement for the fiscal year ended December 31, 2023, reports total revenues of $5,000,000, cost of goods sold (COGS) of $3,000,000, operating expenses of $1,200,000, and net income of $600,000. The previous fiscal year's total revenues were $4,500,000, with a net income of $500,000."
**Summary:**
- **Revenues:** $5,000,000 (up from $4,500,000 in the previous year, an increase of 11.1%)
- **Cost of Goods Sold (COGS):** $3,000,000
- **Operating Expenses:** $1,200,000
- **Net Income:** $600,000 (up from $500,000 in the previous year, an increase of 20%)
- **Gross Profit Margin:** 40% (calculated as (Revenues - COGS) / Revenues)
- **Net Profit Margin:** 12% (calculated as Net Income / Revenues)
- **Key Observations:** Revenue growth of 11.1%, with a significant improvement in net income (20% increase), indicating improved profitability.
---
**Example 2: Balance Sheet Analysis**
**Original Text:**
"As of December 31, 2023, XYZ Ltd.'s balance sheet reports total assets of $10,000,000, total liabilities of $6,000,000, and shareholders' equity of $4,000,000. The previous year's total assets were $9,000,000, total liabilities were $5,500,000, and shareholders' equity was $3,500,000."
**Summary:**
- **Total Assets:** $10,000,000 (up from $9,000,000 in the previous year, an increase of 11.1%)
- **Total Liabilities:** $6,000,000 (up from $5,500,000 in the previous year, an increase of 9.1%)
- **Shareholders' Equity:** $4,000,000 (up from $3,500,000 in the previous year, an increase of 14.3%)
- **Current Ratio:** 1.67 (calculated as Total Assets / Total Liabilities)
- **Debt-to-Equity Ratio:** 1.5 (calculated as Total Liabilities / Shareholders' Equity)
- **Key Observations:** Healthy increase in both assets and equity, indicating growth and improved financial stability. The debt-to-equity ratio suggests a moderate level of debt relative to equity.
---
**Example 3: Cash Flow Statement Analysis**
**Original Text:**
"For the fiscal year ended December 31, 2023, DEF Inc.'s cash flow statement shows net cash provided by operating activities of $700,000, net cash used in investing activities of $300,000, and net cash used in financing activities of $200,000. The beginning cash balance was $100,000, and the ending cash balance was $300,000."
**Summary:**
- **Net Cash Provided by Operating Activities:** $700,000
- **Net Cash Used in Investing Activities:** $300,000
- **Net Cash Used in Financing Activities:** $200,000
- **Net Increase in Cash:** $200,000 (calculated as $700,000 - $300,000 - $200,000)
- **Beginning Cash Balance:** $100,000
- **Ending Cash Balance:** $300,000
- **Key Observations:** Positive cash flow from operating activities indicates strong operational performance. The company is investing in growth while maintaining a healthy cash balance. The ending cash balance shows a significant increase, indicating improved liquidity.
---
**Example 4: Statement of Shareholders' Equity Analysis**
**Original Text:**
"GHI Corporation's statement of shareholders' equity for the fiscal year ended December 31, 2023, shows common stock of $1,000,000, retained earnings of $2,000,000, and additional paid-in capital of $500,000. The previous year's retained earnings were $1,500,000."
**Summary:**
- **Common Stock:** $1,000,000
- **Retained Earnings:** $2,000,000 (up from $1,500,000 in the previous year, an increase of 33.3%)
- **Additional Paid-in Capital:** $500,000
- **Total Shareholders' Equity:** $3,500,000
- **Key Observations:** Significant growth in retained earnings indicates strong profitability and reinvestment in the business. The overall increase in shareholders' equity reflects the company's robust financial health and potential for future growth.
---
By following this structured approach, you will be able to provide thorough and accurate analyses of financial and accounting statements, ensuring that all key metrics and insights are clearly understood.
Human:: add 123 and 123
Math-Agent: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7f59b68adbd0>

@ -1,82 +0,0 @@
Multi-Agent MCP Test Environment
Type 'exit' to quit
Available commands:
- math: <calculation> (e.g., 'math: add 5 and 3')
- finance: <calculation> (e.g., 'finance: calculate compound interest on 1000 at 5% for 3 years')
- Any other calculation will use the super agent
Enter your calculation request: add 3 adn33
╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: 1] ────────────────────────────╮
│ Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at │
│ 0x7fb7c003e020> │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯
You: 2025-04-17 17:36:24 | INFO | swarms.structs.agent:_run:1123 - Interactive mode enabled.
Super Agent Response:
--------------------------------------------------
Calculation Result: System: : Your Name: Super-Calculator
Your Description: Multi-capable calculation expert
You have access to multiple calculation servers. Use them appropriately.
Human:: add 3 adn33
Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7fb7c003e020>
User:
--------------------------------------------------
Enter your calculation request: ╭──────────────────────────── Agent Name: Super-Calculator [Max Loops:
╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: 1] ────────────────────────────╮
│ Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at │
│ 0x7fb7c007d960> │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯
2025-04-17 17:36:33 | INFO | swarms.structs.agent:_run:1123 - Interactive mode enabled.
You:
Super Agent Response:
--------------------------------------------------
Calculation Result: System: : Your Name: Super-Calculator
Your Description: Multi-capable calculation expert
You have access to multiple calculation servers. Use them appropriately.
Human:: add 3 adn33
Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7fb7c003e020>
User:
Human::
Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at 0x7fb7c007d960>
User:
--------------------------------------------------
Enter your calculation request: add 3 and 33
╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: 1] ────────────────────────────╮
│ Super-Calculator: <litellm.litellm_core_utils.streaming_handler.CustomStreamWrapper object at │
│ 0x7fb7c007f280> │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯
You: 2025-04-17 17:36:52 | INFO | swarms.structs.agent:_run:1123 - Interactive mode enabled.

@ -1,43 +0,0 @@
# MCP Integration Documentation
## Overview
This implementation connects an agent with a Math Server using the Model Context Protocol (MCP). The system consists of:
1. Math Server (math_server.py) - Handles mathematical calculations
2. Test Integration (test_integration.py) - Client that connects to the math server
## Key Components
### Math Agent Setup
```python
math_server = MCPServerSseParams(
url="http://0.0.0.0:6274",
headers={"Content-Type": "application/json"},
)
math_agent = Agent(
agent_name="Math-Agent",
system_prompt="You are a math assistant. Process mathematical operations.",
max_loops=1,
mcp_servers=[math_server]
)
```
### Task Flow
1. User inputs a math operation
2. Math agent processes the request
3. Request is sent to math server via MCP
4. Result is returned through the agent
## Testing
Run the integration test:
```bash
python examples/mcp_example/math_server.py # Start server
python examples/mcp_example/test_integration.py # Run client
```
## Implementation Notes
- Server runs on port 6274
- Uses SSE (Server-Sent Events) for transport
- Handles basic math operations (add, subtract, multiply, divide)

@ -1,22 +0,0 @@
from fastmcp import FastMCP
import logging
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Initialize MCP server
mcp = FastMCP("Calc-Server")
@mcp.tool(name="compound_interest")
def compound_interest(principal: float, rate: float, time: float) -> float:
return principal * (1 + rate/100) ** time
@mcp.tool(name="simple_interest")
def simple_interest(principal: float, rate: float, time: float) -> float:
return (principal * rate * time) / 100
if __name__ == "__main__":
print("Starting Calculation Server on port 6275...")
mcp.run(transport="sse", host="0.0.0.0", port=6275)

@ -1,32 +1,25 @@
from fastmcp import FastMCP from fastmcp import FastMCP
import logging from typing import Dict, Any, Optional
# Configure logging
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
# Initialize MCP server # Initialize MCP server
mcp = FastMCP("Math-Server") mcp = FastMCP("Math-Server")
@mcp.tool(name="add") @mcp.tool()
def add(a: float, b: float) -> float: def add(a: int, b: int) -> int:
return float(a) + float(b) """Add two numbers together"""
try:
@mcp.tool(name="subtract") return a + b
def subtract(a: float, b: float) -> float: except Exception as e:
return float(a) - float(b) return {"error": str(e)}
@mcp.tool(name="multiply") @mcp.tool()
def multiply(a: float, b: float) -> float: def multiply(a: int, b: int) -> int:
return float(a) * float(b) """Multiply two numbers together"""
try:
@mcp.tool(name="divide") return a * b
def divide(a: float, b: float) -> float: except Exception as e:
if float(b) == 0: return {"error": str(e)}
raise ValueError("Cannot divide by zero")
return float(a) / float(b)
if __name__ == "__main__": if __name__ == "__main__":
print("Starting Math Server on port 6274...") print("Starting Math Server...")
mcp.run(transport="sse", host="0.0.0.0", port=6274) mcp.run(transport="sse")

@ -1,55 +0,0 @@
from swarms import Agent
from swarms.tools.mcp_integration import MCPServerSseParams
# Configure servers
math_server = MCPServerSseParams(
url="http://0.0.0.0:6274",
headers={"Content-Type": "application/json"},
timeout=10.0,
sse_read_timeout=300.0
)
calc_server = MCPServerSseParams(
url="http://0.0.0.0:6275",
headers={"Content-Type": "application/json"},
timeout=10.0,
sse_read_timeout=300.0
)
# Create agent with access to both servers
calculator = Agent(
agent_name="Calculator",
agent_description="Math and calculation expert",
system_prompt="You are a math expert. Use the available calculation tools to solve problems.",
max_loops=1,
mcp_servers=[math_server, calc_server],
interactive=True,
streaming_on=True,
model_name="gpt-4o-mini"
)
def main():
print("\nMulti-Server Calculator Test")
print("Type 'exit' to quit\n")
print("Example commands:")
print("- add 5 and 3")
print("- multiply 4 by 7\n")
while True:
try:
user_input = input("\nEnter calculation: ")
if user_input.lower() == 'exit':
break
response = calculator.run(user_input)
print(f"\nCalculation result: {response}")
except KeyboardInterrupt:
print("\nExiting gracefully...")
break
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
main()

@ -1,78 +1,51 @@
from swarms import Agent from swarms import Agent
from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT
from swarms.tools.mcp_integration import MCPServerSseParams from swarms.tools.mcp_integration import MCPServerSseParams
import logging import logging
from datetime import datetime
import os
from dotenv import load_dotenv
load_dotenv()
# Use either Swarms API key or OpenAI API key
api_key = os.getenv("SWARMS_API_KEY") or os.getenv("OPENAI_API_KEY")
if not api_key:
raise ValueError("Please set either SWARMS_API_KEY or OPENAI_API_KEY in your environment")
# Configure MCP server connections def main():
math_server = MCPServerSseParams( # Configure MCP server connection
server = MCPServerSseParams(
url="http://0.0.0.0:6274", url="http://0.0.0.0:6274",
headers={"Content-Type": "application/json"}, headers={"Content-Type": "application/json"},
timeout=10.0, timeout=10.0,
sse_read_timeout=300.0 # 5 minute timeout for long-running operations sse_read_timeout=300.0
) )
# Error handling wrapper # Initialize agent with MCP capabilities
def setup_mcp_server(server_params: MCPServerSseParams): agent = Agent(
try: agent_name="Math-Agent",
math_agent = setup_agent( agent_description="Agent that performs math operations",
"Math-Agent", system_prompt=FINANCIAL_AGENT_SYS_PROMPT,
"Handles mathematical calculations",
[server_params]
)
return math_agent
except Exception as e:
logger.error(f"Failed to setup MCP server: {e}")
raise
def setup_agent(name: str, description: str, servers: list) -> Agent:
"""Setup an agent with MCP server connections"""
return Agent(
agent_name=name,
agent_description=description,
system_prompt="You are a math assistant. Process mathematical operations using the provided MCP tools.",
max_loops=1, max_loops=1,
mcp_servers=servers, mcp_servers=[server],
streaming_on=False, streaming_on=True
model_name="gpt-4o-mini"
) )
def main(): try:
# Initialize specialized math agent # First get available tools from server
math_agent = setup_agent( print("\nDiscovering available tools from MCP server...")
"Math-Agent", tools = agent.mcp_tool_handling()
"Handles mathematical calculations", print("\nAvailable tools:", tools)
[math_server]
)
print("\nMulti-Agent MCP Test Environment")
print("Type 'exit' to quit\n")
while True: while True:
try: # Get user input
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") user_input = input("\nEnter a math operation (or 'exit' to quit): ")
user_input = input(f"\n[{timestamp}] Enter your request (or Ctrl+C to exit): ")
if user_input.lower() == 'exit': if user_input.lower() == 'exit':
break break
print(f"\n[{timestamp}] Processing math request...") # Process user input through agent
response = math_agent.run(user_input) try:
print(f"\n[{timestamp}] Math calculation result: {response}") result = agent.run(user_input)
print("\nResult:", result)
except Exception as e:
print(f"Error processing request: {e}")
except KeyboardInterrupt:
print("\nExiting gracefully...")
break
except Exception as e: except Exception as e:
print(f"[{timestamp}] Error processing request: {e}") logging.error(f"Test failed: {e}")
raise
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)

Loading…
Cancel
Save