fix: align math server tools and agent prompt with available capabilities

- Updated system prompt in `mock_multi_agent.py` to reflect only supported tools
- Added error handling in `mock_math_server.py` to reject unsupported operations
- Ensured agent behavior stays within defined context and MCP protocol limits
pull/819/head
Pavan Kumar 2 days ago committed by ascender1729
parent 6bb61361cc
commit 40cd5248d8

@ -9,22 +9,31 @@ mcp = FastMCP("Math-Mock-Server")
@mcp.tool()
def add(a: int, b: int) -> int:
"""Add two numbers together"""
time.sleep(0.1) # Simulate processing time
return a + b
try:
time.sleep(0.1) # Simulate processing time
return a + b
except Exception as e:
return {"error": f"Error adding numbers: {str(e)}"}
@mcp.tool()
def multiply(a: int, b: int) -> int:
"""Multiply two numbers together"""
time.sleep(0.1) # Simulate processing time
return a * b
try:
time.sleep(0.1) # Simulate processing time
return a * b
except Exception as e:
return {"error": f"Error multiplying numbers: {str(e)}"}
@mcp.tool()
def divide(a: int, b: int) -> float:
"""Divide two numbers"""
if b == 0:
raise ValueError("Cannot divide by zero")
time.sleep(0.1) # Simulate processing time
return a / b
try:
if b == 0:
return {"error": "Cannot divide by zero"}
time.sleep(0.1) # Simulate processing time
return a / b
except Exception as e:
return {"error": f"Error dividing numbers: {str(e)}"}
if __name__ == "__main__":
print("Starting Mock Math Server on port 8000...")

@ -14,7 +14,7 @@ class MathAgent:
self.agent = Agent(
agent_name=name,
agent_description="Math processing agent",
system_prompt=f"You are {name}, a math processing agent. Use the provided tools to solve math problems.",
system_prompt=f"You are {name}, a math processing agent. You have access to these mathematical operations ONLY: addition, multiplication, and division. Only suggest calculations using these available tools.",
max_loops=1,
mcp_servers=[self.server],
streaming_on=False,

Loading…
Cancel
Save