From 977623ab7b23902d29c4d5c7347ca49dd5230b6d Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Sun, 20 Apr 2025 09:17:46 +0000 Subject: [PATCH] refactor(mcp): simplify client to use math agent only, remove finance agent --- .replit | 8 ------- examples/mcp_example/mcp_client.py | 34 ++++++------------------------ 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/.replit b/.replit index 6d97aa07..b721b4ea 100644 --- a/.replit +++ b/.replit @@ -81,14 +81,6 @@ name = "Run MCP Demo" author = 13983571 mode = "parallel" -[[workflows.workflow.tasks]] -task = "shell.exec" -args = "python examples/mcp_example/mock_stock_server.py &" - -[[workflows.workflow.tasks]] -task = "shell.exec" -args = "sleep 2" - [[workflows.workflow.tasks]] task = "shell.exec" args = "python examples/mcp_example/mock_math_server.py &" diff --git a/examples/mcp_example/mcp_client.py b/examples/mcp_example/mcp_client.py index 71993e2f..49d3c651 100644 --- a/examples/mcp_example/mcp_client.py +++ b/examples/mcp_example/mcp_client.py @@ -1,23 +1,15 @@ - from swarms import Agent from swarms.tools.mcp_integration import MCPServerSseParams -from swarms.prompts.agent_prompts import FINANCE_AGENT_PROMPT, MATH_AGENT_PROMPT +from swarms.prompts.agent_prompts import MATH_AGENT_PROMPT def main(): - # Configure MCP server connections + # Configure MCP server connection math_server = MCPServerSseParams( url="http://0.0.0.0:8000/mcp", headers={"Content-Type": "application/json"}, timeout=5.0, sse_read_timeout=30.0 ) - - stock_server = MCPServerSseParams( - url="http://0.0.0.0:8001/mcp", - headers={"Content-Type": "application/json"}, - timeout=5.0, - sse_read_timeout=30.0 - ) # Initialize math agent math_agent = Agent( @@ -29,33 +21,19 @@ def main(): streaming_on=True ) - # Initialize stock agent - stock_agent = Agent( - agent_name="Stock Agent", - agent_description="Specialized agent for stock analysis", - system_prompt=FINANCE_AGENT_PROMPT, - max_loops=1, - mcp_servers=[stock_server], - streaming_on=True - ) - - print("\nMulti-Agent System Initialized") + print("\nMath Agent System Initialized") print("\nAvailable operations:") print("Math Agent: add, multiply, divide") - print("Stock Agent: get stock price, calculate moving average") while True: query = input("\nEnter your query (or 'exit' to quit): ") - + if query.lower() == 'exit': break - # Process with both agents + # Process with math agent math_result = math_agent.run(query) - stock_result = stock_agent.run(query) - print("\nMath Agent Response:", math_result) - print("Stock Agent Response:", stock_result) if __name__ == "__main__": - main() + main() \ No newline at end of file