From 4284eab0d17e92b8351de9721744cc769dc9b77b Mon Sep 17 00:00:00 2001 From: Pavan Kumar <66913595+ascender1729@users.noreply.github.com> Date: Fri, 18 Apr 2025 15:46:09 +0000 Subject: [PATCH] docs: add presentation script explaining MCP integration with mock multi-agent math and stock servers --- .replit | 25 +++++++ examples/mcp_example/mock_stock_server.py | 2 +- examples/mcp_example/presentation_script.md | 79 +++++++++++++++++++++ 3 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 examples/mcp_example/presentation_script.md diff --git a/.replit b/.replit index c9816a16..4ed1566a 100644 --- a/.replit +++ b/.replit @@ -74,3 +74,28 @@ mode = "sequential" [[workflows.workflow.tasks]] task = "shell.exec" args = "python -m unittest tests/test_basic_example.py -v" + +[[workflows.workflow]] +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 &" + +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "sleep 2" + +[[workflows.workflow.tasks]] +task = "shell.exec" +args = "python examples/mcp_example/mock_multi_agent.py" diff --git a/examples/mcp_example/mock_stock_server.py b/examples/mcp_example/mock_stock_server.py index 3bbd6c76..6cf03946 100644 --- a/examples/mcp_example/mock_stock_server.py +++ b/examples/mcp_example/mock_stock_server.py @@ -36,4 +36,4 @@ def calculate_moving_average(prices: list[float], window: int) -> Dict[str, Unio if __name__ == "__main__": print("Starting Mock Stock Server on port 8001...") - mcp.run(transport="sse", transport_kwargs={"host": "0.0.0.0", "port": 8001}) + mcp.run(transport="sse", host="0.0.0.0", port=8001) diff --git a/examples/mcp_example/presentation_script.md b/examples/mcp_example/presentation_script.md new file mode 100644 index 00000000..98fd0e43 --- /dev/null +++ b/examples/mcp_example/presentation_script.md @@ -0,0 +1,79 @@ + +# MCP Integration Demo Script + +## 1. Setup & Architecture Overview + +```bash +# Terminal 1: Start Stock Server +python examples/mcp_example/mock_stock_server.py + +# Terminal 2: Start Math Server +python examples/mcp_example/mock_math_server.py + +# Terminal 3: Start Multi-Agent System +python examples/mcp_example/mock_multi_agent.py +``` + +## 2. Key Components + +### Server-Side: +- FastMCP servers running on ports 8000 and 8001 +- Math Server provides: add, multiply, divide operations +- Stock Server provides: price lookup, moving average calculations + +### Client-Side: +- Multi-agent system with specialized agents +- MCPServerSseParams for server connections +- Automatic task routing based on agent specialization + +## 3. Demo Flow + +1. Math Operations: +``` +Enter a math problem: 5 plus 3 +Enter a math problem: 10 times 4 +``` + +2. Stock Analysis: +``` +Enter a math problem: get price of AAPL +Enter a math problem: calculate moving average of [10,20,30,40,50] over 3 periods +``` + +## 4. Integration Highlights + +1. Server Configuration: +- FastMCP initialization +- Tool registration using decorators +- SSE transport setup + +2. Client Integration: +- MCPServerSseParams configuration +- Agent specialization +- Task routing logic + +3. Communication Flow: +- Client request → Agent processing → MCP server → Response handling + +## 5. Code Architecture + +### Server Example (Math Server): +```python +@mcp.tool() +def add(a: int, b: int) -> int: + """Add two numbers together""" + return a + b +``` + +### Client Example (Multi-Agent): +```python +calculator = MathAgent("Calculator", "http://0.0.0.0:8000") +stock_analyst = MathAgent("StockAnalyst", "http://0.0.0.0:8001") +``` + +## 6. Key Benefits + +1. Modular Architecture +2. Specialized Agents +3. Clean API Integration +4. Scalable Design