get_money_flow
Retrieve transaction count and volume data from the Wormholescan API for specified timeframes, chains, and applications, returning a structured DataFrame for analysis.
Instructions
Fetch transaction count and volume data from Wormholescan API for a specific period.
Args:
timespan: Time span for data (1h, 1d, 1mo, 1y). Default: 1d
from_date: From date in ISO 8601 format (e.g., 2024-01-01T15:04:05Z). Default: empty
to_date: To date in ISO 8601 format (e.g., 2024-01-01T15:04:05Z). Default: empty
appId: Application ID to filter results. Default: empty
sourceChain: Source chain ID to filter results. Default: empty
targetChain: Target chain ID to filter results. Default: empty
Returns:
String representation of a pandas DataFrame containing transaction count and volume data
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| appId | No | ||
| from_date | No | ||
| sourceChain | No | ||
| targetChain | No | ||
| timespan | No | 1d | |
| to_date | No |
Implementation Reference
- main.py:141-222 (handler)The handler function for the 'get_money_flow' tool. It is decorated with @mcp.tool() for registration, validates input parameters, queries the Wormholescan API for transaction tops data, transforms the response into a pandas DataFrame sorted by date, and returns it as a markdown table.# Define the get_money_flow tool @mcp.tool() async def get_money_flow( timespan: str = "1d", from_date: str = "", to_date: str = "", appId: str = "", sourceChain: str = "", targetChain: str = "" ) -> str: """ Fetch transaction count and volume data from Wormholescan API for a specific period. Args: timespan: Time span for data (1h, 1d, 1mo, 1y). Default: 1d from_date: From date in ISO 8601 format (e.g., 2024-01-01T15:04:05Z). Default: empty to_date: To date in ISO 8601 format (e.g., 2024-01-01T15:04:05Z). Default: empty appId: Application ID to filter results. Default: empty sourceChain: Source chain ID to filter results. Default: empty targetChain: Target chain ID to filter results. Default: empty Returns: String representation of a pandas DataFrame containing transaction count and volume data """ try: # Validate parameters valid_timespans = {"1h", "1d", "1mo", "1y"} if timespan not in valid_timespans: raise ValueError(f"Invalid timespan. Must be one of {valid_timespans}") # Construct query parameters params = {"timespan": timespan} if from_date: params["from"] = from_date if to_date: params["to"] = to_date if appId: params["appId"] = appId if sourceChain: params["sourceChain"] = sourceChain if targetChain: params["targetChain"] = targetChain # Make API request async with httpx.AsyncClient() as client: response = await client.get( f"{API_BASE}/api/v1/x-chain-activity/tops", params=params ) response.raise_for_status() # Parse JSON response data = response.json() # Transform data for DataFrame rows = [ { "from": item.get("from"), "to": item.get("to"), "source_chain": id2name(item.get("emitter_chain")), "volume": item.get("volume"), "count": item.get("count") } for item in data ] # Create DataFrame df = pd.DataFrame(rows) # Convert numeric columns df["volume"] = pd.to_numeric(df["volume"], errors="coerce") df["count"] = pd.to_numeric(df["count"], errors="coerce") # Sort by 'from' date for readability df = df.sort_values("from") return df.to_markdown(index=False) except Exception as e: return str(e)
- main.py:67-70 (helper)Helper function id2name used in get_money_flow to convert chain IDs to names using the WORMHOLE_CHAINS dictionary.def id2name(id) -> str: id = str(id) return WORMHOLE_CHAINS.get(id, id)