lookup_event_feed
Reverse-lookup a Pythia Event feedId (bytes32) to its human-readable feed name, eliminating the need for dApps to maintain a feedId-to-name table.
Instructions
Reverse-lookup a Pythia Event feedId (bytes32) to its human-readable feed name.
Subscribers receive bytes32 feedId in SubscriptionCreated and PythiaEvent
events. This tool maps that hash back to the canonical feed name (e.g.
'pol_RSI_5M_14') so dApps don't need to maintain their own feedId → name
table or query the registry contract on every event.
Args: feed_id_hex: bytes32 hash, with or without '0x' prefix, any case.
Returns: Single-section report with feed_name + matching token + indicator suffix. If the hash is not in the registered lookup table, returns a diagnostic pointer.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| feed_id_hex | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- The actual implementation of the lookup_event_feed tool. It reverse-looks up a bytes32 feedId hash to its human-readable feed name by querying the feed_hash_lookup table from the live data feed.
async def lookup_event_feed(feed_id_hex: str) -> str: """Reverse-lookup a Pythia Event feedId (bytes32) to its human-readable feed name. Subscribers receive `bytes32 feedId` in SubscriptionCreated and PythiaEvent events. This tool maps that hash back to the canonical feed name (e.g. 'pol_RSI_5M_14') so dApps don't need to maintain their own feedId → name table or query the registry contract on every event. Args: feed_id_hex: bytes32 hash, with or without '0x' prefix, any case. Returns: Single-section report with feed_name + matching token + indicator suffix. If the hash is not in the registered lookup table, returns a diagnostic pointer. """ h = feed_id_hex.strip().lower() if not h.startswith("0x"): h = "0x" + h data = await _fetch_data() events = data.get("events", {}) if data else {} lookup = events.get("feed_hash_lookup", {}) feed_name = lookup.get(h) if not feed_name: return ( f"Feed id {feed_id_hex} not found in registered lookup table.\n" "Possible reasons:\n" " - Invalid hash (must be keccak256(feed_name) as bytes32)\n" " - Feed not yet registered with the Event registry\n" " - Feed deactivated\n" f"Total registered feeds: {len(lookup)}. Use list_tokens() + " "get_token_feeds(engine_id) to discover live feed names." ) parts = feed_name.split("_", 1) engine_id = parts[0] if parts else feed_name suffix = parts[1] if len(parts) > 1 else "" tokens = data.get("tokens", []) if data else [] token = next((t for t in tokens if t.get("engine_id") == engine_id), None) out = [ f"Feed name: {feed_name}", f"Feed ID: {h}", ] if token: out.append(f"Token: {token.get('symbol')} ({token.get('name')})") out.append(f"Engine id: {engine_id}") if suffix: out.append(f"Indicator: {suffix}") return "\n".join(out) - src/pythia_oracle_mcp/server.py:1218-1218 (registration)Registration of lookup_event_feed as an MCP tool via the @mcp.tool() decorator on the async function definition.
@mcp.tool() - The function signature and docstring define the input schema: feed_id_hex (str) — a bytes32 hash with or without '0x' prefix. Returns a text report with feed name, matching token, and indicator suffix.
@mcp.tool() async def lookup_event_feed(feed_id_hex: str) -> str: """Reverse-lookup a Pythia Event feedId (bytes32) to its human-readable feed name. Subscribers receive `bytes32 feedId` in SubscriptionCreated and PythiaEvent events. This tool maps that hash back to the canonical feed name (e.g. 'pol_RSI_5M_14') so dApps don't need to maintain their own feedId → name table or query the registry contract on every event. Args: feed_id_hex: bytes32 hash, with or without '0x' prefix, any case. Returns: Single-section report with feed_name + matching token + indicator suffix. If the hash is not in the registered lookup table, returns a diagnostic pointer. """ - The tool relies on _fetch_data() to get the live feed-status.json, then reads events.feed_hash_lookup to do the reverse mapping.
data = await _fetch_data() events = data.get("events", {}) if data else {} lookup = events.get("feed_hash_lookup", {})