subscribe_info
Plan a subscription to monitor a feed with condition and duration, returning cost and exact calls.
Instructions
Plan a specific Pythia Events subscription with cost and exact calls.
Args: feed_name: Feed name to monitor (e.g. 'pol_RSI_5M_14', 'bitcoin_EMA_1H_20') condition: 0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW days: Subscription duration in days (1-365)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| feed_name | Yes | ||
| condition | No | ||
| days | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- src/pythia_oracle_mcp/server.py:791-855 (registration)Tool 'subscribe_info' is registered via @mcp.tool() decorator on line 791. It is defined as an async function that plans a Pythia Events subscription with cost and exact calls.
@mcp.tool() async def subscribe_info( feed_name: str, condition: int = 1, days: int = 7, ) -> str: """Plan a specific Pythia Events subscription with cost and exact calls. Args: feed_name: Feed name to monitor (e.g. 'pol_RSI_5M_14', 'bitcoin_EMA_1H_20') condition: 0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW days: Subscription duration in days (1-365) """ if condition < 0 or condition > 3: return "Invalid condition. Use: 0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW" if days < 1 or days > 365: return "Days must be 1-365." data = await _fetch_data() events = data.get("events", {}) if data else {} mainnet = _get_mainnet(data) registries = events.get("registries", []) cond_name = _CONDITION_NAMES.get(condition, "UNKNOWN") lines = [f"Pythia Events — Subscription Plan\n"] lines.append(f" Feed: {feed_name}") lines.append(f" Condition: {cond_name} ({condition})") lines.append(f" Duration: {days} days") lines.append(f" Cost: {days} LINK ({events.get('pricing', '1 LINK/day')})") if condition >= 2: lines.append(f"\n WARNING: {cond_name} is accepted but not yet processed.") lines.append(" Subscription will be stored; it fires when condition is activated.") lines.append(f"\n Threshold: YOU MUST SET THIS — scaled to 8 decimals.") lines.append(" Examples:") lines.append(" RSI 30 → 3000000000") lines.append(" RSI 70 → 7000000000") lines.append(" EMA $2500 → 250000000000 (2500 * 1e8)") lines.append(" Vol 5% → 500000000 (0.05 * 1e8)") lines.append("\nExact Calls (from your contract or EOA):\n") lines.append(" // Step 1: Approve LINK spending") lines.append(f' LINK.approve(registry, {days} * 1e18);') lines.append("") lines.append(" // Step 2: Subscribe") lines.append(f' uint256 eventId = registry.subscribe(') lines.append(f' "{feed_name}",') lines.append(f" {days}, // numDays") lines.append(f" {condition}, // {cond_name}") lines.append(f" YOUR_THRESHOLD // 8 decimal places") lines.append(f" );") lines.append("") lines.append(" // Step 3: Listen for the alert") lines.append(" // Off-chain: registry.on('PythiaEvent', (eventId, value) => { ... })") if registries: lines.append("\nRegistry Addresses:") for reg in registries: lines.append(f" {reg['chain']}: {reg['address']}") lines.append(f"\nLINK Token (mainnet): {mainnet['link_token']}") lines.append(f"Refund: {events.get('refund', 'unused whole days refunded')}") lines.append(f"\nUse get_events_guide() for a complete Solidity contract.") return "\n".join(lines) - src/pythia_oracle_mcp/server.py:792-855 (handler)Handler function for 'subscribe_info' tool. Takes feed_name, condition (0-3), and days (1-365) as input, validates them, fetches live data, and returns a formatted subscription plan with cost, condition info, threshold examples, and exact Solidity calls for approval and subscription.
async def subscribe_info( feed_name: str, condition: int = 1, days: int = 7, ) -> str: """Plan a specific Pythia Events subscription with cost and exact calls. Args: feed_name: Feed name to monitor (e.g. 'pol_RSI_5M_14', 'bitcoin_EMA_1H_20') condition: 0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW days: Subscription duration in days (1-365) """ if condition < 0 or condition > 3: return "Invalid condition. Use: 0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW" if days < 1 or days > 365: return "Days must be 1-365." data = await _fetch_data() events = data.get("events", {}) if data else {} mainnet = _get_mainnet(data) registries = events.get("registries", []) cond_name = _CONDITION_NAMES.get(condition, "UNKNOWN") lines = [f"Pythia Events — Subscription Plan\n"] lines.append(f" Feed: {feed_name}") lines.append(f" Condition: {cond_name} ({condition})") lines.append(f" Duration: {days} days") lines.append(f" Cost: {days} LINK ({events.get('pricing', '1 LINK/day')})") if condition >= 2: lines.append(f"\n WARNING: {cond_name} is accepted but not yet processed.") lines.append(" Subscription will be stored; it fires when condition is activated.") lines.append(f"\n Threshold: YOU MUST SET THIS — scaled to 8 decimals.") lines.append(" Examples:") lines.append(" RSI 30 → 3000000000") lines.append(" RSI 70 → 7000000000") lines.append(" EMA $2500 → 250000000000 (2500 * 1e8)") lines.append(" Vol 5% → 500000000 (0.05 * 1e8)") lines.append("\nExact Calls (from your contract or EOA):\n") lines.append(" // Step 1: Approve LINK spending") lines.append(f' LINK.approve(registry, {days} * 1e18);') lines.append("") lines.append(" // Step 2: Subscribe") lines.append(f' uint256 eventId = registry.subscribe(') lines.append(f' "{feed_name}",') lines.append(f" {days}, // numDays") lines.append(f" {condition}, // {cond_name}") lines.append(f" YOUR_THRESHOLD // 8 decimal places") lines.append(f" );") lines.append("") lines.append(" // Step 3: Listen for the alert") lines.append(" // Off-chain: registry.on('PythiaEvent', (eventId, value) => { ... })") if registries: lines.append("\nRegistry Addresses:") for reg in registries: lines.append(f" {reg['chain']}: {reg['address']}") lines.append(f"\nLINK Token (mainnet): {mainnet['link_token']}") lines.append(f"Refund: {events.get('refund', 'unused whole days refunded')}") lines.append(f"\nUse get_events_guide() for a complete Solidity contract.") return "\n".join(lines) - _CONDITION_NAMES dict maps integer condition codes (0=ABOVE, 1=BELOW, 2=CROSSES_ABOVE, 3=CROSSES_BELOW) to human-readable names, used by subscribe_info to display the condition name.
_CONDITION_NAMES = {0: "ABOVE", 1: "BELOW", 2: "CROSSES_ABOVE", 3: "CROSSES_BELOW"}