parent
9859fcfd2a
commit
d7c861604b
@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
from fastmcp import FastMCP
|
||||||
|
|
||||||
|
mcp = FastMCP("Math-Server")
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def add(a: int, b: int) -> int:
|
||||||
|
"""Add two numbers"""
|
||||||
|
return a + b
|
||||||
|
|
||||||
|
@mcp.tool()
|
||||||
|
def multiply(a: int, b: int) -> int:
|
||||||
|
"""Multiply two numbers"""
|
||||||
|
return a * b
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
mcp.run(host="0.0.0.0", port=6274, transport="sse")
|
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
from swarms import Agent
|
||||||
|
from swarms.prompts.finance_agent_sys_prompt import FINANCIAL_AGENT_SYS_PROMPT
|
||||||
|
from swarms.tools.mcp_integration import MCPServerSseParams
|
||||||
|
|
||||||
|
# Configure MCP server connection
|
||||||
|
server = MCPServerSseParams(
|
||||||
|
url="http://0.0.0.0:6274",
|
||||||
|
headers={"Content-Type": "application/json"}
|
||||||
|
)
|
||||||
|
|
||||||
|
# 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
|
||||||
|
)
|
||||||
|
|
||||||
|
# Test addition
|
||||||
|
result = agent.run("Use the add tool to add 5 and 3")
|
||||||
|
print("Addition result:", result)
|
||||||
|
|
||||||
|
# Test multiplication
|
||||||
|
result = agent.run("Use the multiply tool to multiply 4 and 6")
|
||||||
|
print("Multiplication result:", result)
|
Loading…
Reference in new issue