From 86cb09ad76f4d32bad09c6cc0b171fde674fe81d Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Thu, 17 Apr 2025 17:41:04 +0000 Subject: [PATCH] chore: restore repository state to commit 8d1d22d for stability --- .replit | 40 +---- ...6-43-21-WARNING-swarms-s-1744908233843.txt | 149 ------------------ ...6-50-04-WARNING-swarms-s-1744908654878.txt | 129 --------------- ...51-35-WARNING-swarms-str-1744908739972.txt | 125 --------------- ...ommands-math-calculation-1744911431477.txt | 82 ---------- examples/mcp_example/README.md | 43 ----- examples/mcp_example/calc_server.py | 22 --- examples/mcp_example/math_server.py | 43 +++-- examples/mcp_example/multi_server_test.py | 55 ------- examples/mcp_example/test_integration.py | 103 +++++------- 10 files changed, 57 insertions(+), 734 deletions(-) delete mode 100644 attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-43-21-WARNING-swarms-s-1744908233843.txt delete mode 100644 attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-50-04-WARNING-swarms-s-1744908654878.txt delete mode 100644 attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-51-35-WARNING-swarms-str-1744908739972.txt delete mode 100644 attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-Available-commands-math-calculation-1744911431477.txt delete mode 100644 examples/mcp_example/README.md delete mode 100644 examples/mcp_example/calc_server.py delete mode 100644 examples/mcp_example/multi_server_test.py diff --git a/.replit b/.replit index 3605922f..9b2aec89 100644 --- a/.replit +++ b/.replit @@ -4,7 +4,7 @@ modules = ["python-3.10", "bash"] channel = "stable-24_05" [workflows] -runButton = "Run Multi Server" +runButton = "Run MCP Server" [[workflows.workflow]] name = "Run MCP Tests" @@ -58,41 +58,3 @@ args = "sleep 2" [[workflows.workflow.tasks]] task = "shell.exec" 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" diff --git a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-43-21-WARNING-swarms-s-1744908233843.txt b/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-43-21-WARNING-swarms-s-1744908233843.txt deleted file mode 100644 index bb024033..00000000 --- a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-43-21-WARNING-swarms-s-1744908233843.txt +++ /dev/null @@ -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): \ No newline at end of file diff --git a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-50-04-WARNING-swarms-s-1744908654878.txt b/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-50-04-WARNING-swarms-s-1744908654878.txt deleted file mode 100644 index 63ce8907..00000000 --- a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-50-04-WARNING-swarms-s-1744908654878.txt +++ /dev/null @@ -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: │ -│ │ -╰────────────────────────────────────────────────────────────────────────╯ - -[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: - - - -[2025-04-17 16:50:18] Enter your request (or Ctrl+C to exit): \ No newline at end of file diff --git a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-51-35-WARNING-swarms-str-1744908739972.txt b/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-51-35-WARNING-swarms-str-1744908739972.txt deleted file mode 100644 index 3e892550..00000000 --- a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-2025-04-17-16-51-35-WARNING-swarms-str-1744908739972.txt +++ /dev/null @@ -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: │ -╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ - -[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: - - diff --git a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-Available-commands-math-calculation-1744911431477.txt b/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-Available-commands-math-calculation-1744911431477.txt deleted file mode 100644 index b320fb4d..00000000 --- a/attached_assets/Pasted--Multi-Agent-MCP-Test-Environment-Type-exit-to-quit-Available-commands-math-calculation-1744911431477.txt +++ /dev/null @@ -1,82 +0,0 @@ - -Multi-Agent MCP Test Environment -Type 'exit' to quit - -Available commands: -- math: (e.g., 'math: add 5 and 3') -- finance: (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: │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ -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: - - -User: - - --------------------------------------------------- - -Enter your calculation request: ╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: -╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: 1] ────────────────────────────╮ -│ Super-Calculator: │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ -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: - - -User: - - -Human:: - - -Super-Calculator: - - -User: - - --------------------------------------------------- - -Enter your calculation request: add 3 and 33 -╭──────────────────────────── Agent Name: Super-Calculator [Max Loops: 1] ────────────────────────────╮ -│ Super-Calculator: │ -╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ -You: 2025-04-17 17:36:52 | INFO | swarms.structs.agent:_run:1123 - Interactive mode enabled. diff --git a/examples/mcp_example/README.md b/examples/mcp_example/README.md deleted file mode 100644 index 55fe1e74..00000000 --- a/examples/mcp_example/README.md +++ /dev/null @@ -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) diff --git a/examples/mcp_example/calc_server.py b/examples/mcp_example/calc_server.py deleted file mode 100644 index b01ec456..00000000 --- a/examples/mcp_example/calc_server.py +++ /dev/null @@ -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) diff --git a/examples/mcp_example/math_server.py b/examples/mcp_example/math_server.py index 66c976c2..af533c90 100644 --- a/examples/mcp_example/math_server.py +++ b/examples/mcp_example/math_server.py @@ -1,32 +1,25 @@ - from fastmcp import FastMCP -import logging - -# Configure logging -logging.basicConfig(level=logging.INFO) -logger = logging.getLogger(__name__) +from typing import Dict, Any, Optional # Initialize MCP server mcp = FastMCP("Math-Server") -@mcp.tool(name="add") -def add(a: float, b: float) -> float: - return float(a) + float(b) - -@mcp.tool(name="subtract") -def subtract(a: float, b: float) -> float: - return float(a) - float(b) - -@mcp.tool(name="multiply") -def multiply(a: float, b: float) -> float: - return float(a) * float(b) - -@mcp.tool(name="divide") -def divide(a: float, b: float) -> float: - if float(b) == 0: - raise ValueError("Cannot divide by zero") - return float(a) / float(b) +@mcp.tool() +def add(a: int, b: int) -> int: + """Add two numbers together""" + try: + return a + b + except Exception as e: + return {"error": str(e)} + +@mcp.tool() +def multiply(a: int, b: int) -> int: + """Multiply two numbers together""" + try: + return a * b + except Exception as e: + return {"error": str(e)} if __name__ == "__main__": - print("Starting Math Server on port 6274...") - mcp.run(transport="sse", host="0.0.0.0", port=6274) + print("Starting Math Server...") + mcp.run(transport="sse") \ No newline at end of file diff --git a/examples/mcp_example/multi_server_test.py b/examples/mcp_example/multi_server_test.py deleted file mode 100644 index 8c08d086..00000000 --- a/examples/mcp_example/multi_server_test.py +++ /dev/null @@ -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() \ No newline at end of file diff --git a/examples/mcp_example/test_integration.py b/examples/mcp_example/test_integration.py index 21f96272..5429c2ea 100644 --- a/examples/mcp_example/test_integration.py +++ b/examples/mcp_example/test_integration.py @@ -1,79 +1,52 @@ + from swarms import Agent +from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT from swarms.tools.mcp_integration import MCPServerSseParams 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 -math_server = MCPServerSseParams( - url="http://0.0.0.0:6274", - headers={"Content-Type": "application/json"}, - timeout=10.0, - sse_read_timeout=300.0 # 5 minute timeout for long-running operations -) - -# Error handling wrapper -def setup_mcp_server(server_params: MCPServerSseParams): - try: - math_agent = setup_agent( - "Math-Agent", - "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, - mcp_servers=servers, - streaming_on=False, - model_name="gpt-4o-mini" - ) def main(): - # Initialize specialized math agent - math_agent = setup_agent( - "Math-Agent", - "Handles mathematical calculations", - [math_server] + # Configure MCP server connection + server = MCPServerSseParams( + url="http://0.0.0.0:6274", + headers={"Content-Type": "application/json"}, + timeout=10.0, + sse_read_timeout=300.0 ) - print("\nMulti-Agent MCP Test Environment") - print("Type 'exit' to quit\n") - - while True: - try: - timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S") - user_input = input(f"\n[{timestamp}] Enter your request (or Ctrl+C to exit): ") + # Initialize agent with MCP capabilities + agent = Agent( + agent_name="Math-Agent", + agent_description="Agent that performs math operations", + system_prompt=FINANCIAL_AGENT_SYS_PROMPT, + max_loops=1, + mcp_servers=[server], + streaming_on=True + ) + try: + # First get available tools from server + print("\nDiscovering available tools from MCP server...") + tools = agent.mcp_tool_handling() + print("\nAvailable tools:", tools) + + while True: + # Get user input + user_input = input("\nEnter a math operation (or 'exit' to quit): ") + if user_input.lower() == 'exit': break + + # Process user input through agent + try: + result = agent.run(user_input) + print("\nResult:", result) + except Exception as e: + print(f"Error processing request: {e}") - print(f"\n[{timestamp}] Processing math request...") - response = math_agent.run(user_input) - print(f"\n[{timestamp}] Math calculation result: {response}") - - except KeyboardInterrupt: - print("\nExiting gracefully...") - break - except Exception as e: - print(f"[{timestamp}] Error processing request: {e}") + except Exception as e: + logging.error(f"Test failed: {e}") + raise if __name__ == "__main__": logging.basicConfig(level=logging.INFO) - main() \ No newline at end of file + main()