from crewai import Agent, Task, Crew
from crewai.tools import tool
import subprocess
import json
@tool("Agent Wallet")
def wallet(method: str) -> str:
"""Manage crypto wallet via FDX. Pass an MCP method name and arguments.
Example: 'getWalletOverview --chainKey ethereum' or 'transferTokens --chainKey ethereum --recipientAddress 0x... --amount 5'"""
result = subprocess.run(
["fdx", "call"] + method.split(),
capture_output=True, text=True
)
return result.stdout
financial_agent = Agent(
role="Financial Agent",
goal="Manage wallet operations and execute transactions",
tools=[wallet],
verbose=True
)
task = Task(
description="Check the wallet balance and swap 10 USDC for ETH if balance allows",
agent=financial_agent
)
crew = Crew(agents=[financial_agent], tasks=[task])
result = crew.kickoff()