Skip to main content
Glama
pythia-the-oracle

pythia-oracle-mcp

Official

get_visions_guide

Get Solidity code to subscribe to Pythia Visions and listen for VisionFired events. Free subscription with no LINK needed.

Instructions

Get Solidity code to subscribe to Pythia Visions and listen for VisionFired events.

Returns a complete contract that subscribes to the PythiaVisionRegistry, receives VisionFired events with pattern type, confidence, direction, price, and full analysis payload. Subscription is FREE (no LINK required).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'get_visions_guide' tool. It fetches live data from feed-status.json, retrieves the Vision Registry address, and returns a complete Solidity contract for subscribing to Pythia Visions and listening for VisionFired events.
    @mcp.tool()
    async def get_visions_guide() -> str:
        """Get Solidity code to subscribe to Pythia Visions and listen for VisionFired events.
    
        Returns a complete contract that subscribes to the PythiaVisionRegistry,
        receives VisionFired events with pattern type, confidence, direction, price,
        and full analysis payload. Subscription is FREE (no LINK required).
        """
        data = await _fetch_data()
        visions = data.get("visions", {})
        registry = visions.get("registry", "")
        if not registry:
            raise RuntimeError(
                "Pythia Visions registry address is missing from live data. "
                "Visions may not be deployed on this environment yet. "
                "Check https://pythia.c3x-solutions.com/feed-status.json visions.registry."
            )
        mainnet = _get_mainnet(data)
        link_token = mainnet["link_token"]
    
        return f"""Pythia Visions Integration — Walk-Forward Validated Market Intelligence On-Chain
    
    Vision Registry (Mainnet): {registry}
    LINK Token: {link_token}
    
    ```solidity
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.19;
    
    interface IPythiaVisionRegistry {{
        function subscribe(bytes32 tokenId) external;
        function unsubscribe(bytes32 tokenId) external;
        function isSubscribed(address subscriber, bytes32 tokenId) external view returns (bool);
        function getSubscriberCount(bytes32 tokenId) external view returns (uint256);
        function getVisionCount(bytes32 tokenId) external view returns (uint256);
        function getLastVisionAt(bytes32 tokenId) external view returns (uint256);
    }}
    
    contract MyVisionSubscriber {{
        IPythiaVisionRegistry public immutable registry;
    
        // Token IDs are keccak256 hashes of the token name
        bytes32 public constant BTC = keccak256("BTC");
        bytes32 public constant ETH = keccak256("ETH");
    
        // Fired by PythiaVisionRegistry when a pattern is detected
        event VisionFired(
            bytes32 indexed tokenId,   // keccak256("BTC") or keccak256("ETH")
            uint8 patternType,          // per-token high nibble: BTC=0x1_, ETH=0x2_
            uint8 confidence,           // Confidence score within pattern's historical range
            uint8 direction,            // 1 = BULLISH
            uint256 price,              // 18 decimals
            bytes payload               // Full JSON (indicators + analysis)
        );
    
        constructor(address _registry) {{
            registry = IPythiaVisionRegistry(_registry);
        }}
    
        /// @notice Subscribe to Visions for a token. FREE — no LINK required.
        function subscribeToken(bytes32 tokenId) external {{
            registry.subscribe(tokenId);
        }}
    
        /// @notice Unsubscribe.
        function unsubscribeToken(bytes32 tokenId) external {{
            registry.unsubscribe(tokenId);
        }}
    
        /// @notice Subscribe to BTC Visions.
        function subscribeBTC() external {{
            registry.subscribe(BTC);
        }}
    
        /// @notice Subscribe to ETH Visions.
        function subscribeETH() external {{
            registry.subscribe(ETH);
        }}
    }}
    ```
    
    Steps:
    1. Deploy with (_registry) = {registry}
    2. Call subscribeBTC() / subscribeETH() — no LINK needed, subscription is FREE
    3. Listen for VisionFired events on the registry contract via RPC/WebSocket
    4. Decode the payload bytes to get the full analysis JSON
    
    Pattern Types (walk-forward validated):
      Per-token high nibble: BTC=0x1_, ETH=0x2_, next token=0x3_, etc.
      Live pattern catalog (codes, accuracy ranges, fold validation, fires/yr,
      failure profile) — call get_visions_info() for the current set.
    
    Payload JSON includes: indicators (RSI, EMA, Bollinger, VWAP, ATR),
    pattern details, confidence score, analysis narrative,
    and feeds-to-watch for confirmation.
    
    Token IDs: keccak256 of the token name.
      BTC = keccak256("BTC") = 0xe98e2830be1a7e4156d656a7505e65d08c67660dc618072422e9c78053c261e9
      ETH = keccak256("ETH") = 0xaaaebeba3810b1e6b70781f14b2d72c1cb89c0b2b320c43bb67ff79f562f5ff4
    
    Deployment:
      Mainnet: _registry={registry}"""
  • Registered as an MCP tool via the @mcp.tool() decorator on line 929. The FastMCP instance ('mcp') is defined on line 17.
    @mcp.tool()
    async def get_visions_guide() -> str:
        """Get Solidity code to subscribe to Pythia Visions and listen for VisionFired events.
  • The _fetch_data() helper used by get_visions_guide to retrieve live data from the Pythia data engine with caching.
    async def _fetch_data() -> dict:
        """Fetch feed-status.json from the live Pythia data engine.
    
        Cached for CACHE_TTL_SECONDS to keep tool responses fast. Raises RuntimeError
        with a clear message if the live URL is unreachable — there is no baked-in
        fallback. AI consumers should retry shortly or check status; serving stale
        data silently would be worse than a clear failure.
        """
        now = datetime.now(timezone.utc)
        cached = _cache.get("data")
        if cached and (now - cached["at"]).total_seconds() < CACHE_TTL_SECONDS:
            return cached["data"]
    
        try:
            async with httpx.AsyncClient(timeout=15) as client:
                resp = await client.get(DATA_URL)
                resp.raise_for_status()
                data = resp.json()
        except httpx.HTTPError as e:
            raise RuntimeError(
                f"Pythia data unreachable: GET {DATA_URL} failed with "
                f"{type(e).__name__}: {e}. "
                "MCP cannot serve token, pattern, pricing, or contract data without the "
                "live JSON. Retry shortly, or check https://pythia.c3x-solutions.com/status."
            ) from e
    
        _cache["data"] = {"data": data, "at": now}
        return data
  • The _get_contracts() helper used indirectly through _get_mainnet() to resolve contract addresses for the integration guide.
    def _get_contracts(data: dict) -> dict:
        """Extract normalized contracts from live feed-status.json data.
    
        Raises RuntimeError if the data is missing the developer.contracts section
        (would only happen if generate_site_data.py is broken or schema changed).
        """
        contracts = data.get("developer", {}).get("contracts")
        if not contracts:
            raise RuntimeError(
                "feed-status.json is missing developer.contracts. "
                "This is a structural error in the live data — check the data engine."
            )
    
        result = {}
        for chain_key, chain_data in contracts.items():
            consumers_raw = chain_data.get("consumers", {})
            result[chain_key] = {
                "display_name": chain_data.get("display_name", chain_key),
                "chain_id": chain_data.get("chain_id"),
                "explorer": chain_data.get("explorer", ""),
                "operator": chain_data.get("operator", ""),
                "link_token": chain_data.get("link_token", ""),
                "consumers": _parse_consumers(consumers_raw),
            }
        return result
  • The related get_visions_info() tool which provides the overview of Pythia Visions and references get_visions_guide() for Solidity code.
    @mcp.tool()
    async def get_visions_info() -> str:
        """Get overview of Pythia Visions — walk-forward validated market intelligence on-chain.
    
        Returns the walk-forward validated patterns with accuracy stats, the Vision Registry
        contract address, subscription info (FREE), evaluation frequency, and
        supported tokens. Visions are pattern detections that passed walk-forward
        validation across multiple years of history. Live token + pattern set is
        returned in the response (canonical source: feed-status.json visions section).
        """
        data = await _fetch_data()
        visions = data.get("visions", {})
    
        registry = visions.get("registry", "")
        patterns = visions.get("patterns", [])
        tokens = visions.get("tokens", [])
        stats = visions.get("stats", {})
    
        if not patterns:
            return (
                "Pythia Visions catalog is empty in the live data. "
                "This may mean Visions are not yet deployed on this environment, "
                "or feed-status.json is missing the visions.patterns section. "
                "Check https://pythia.c3x-solutions.com/feed-status.json directly."
            )
    
        lines = ["Pythia Visions — Walk-Forward Validated Market Intelligence On-Chain\n"]
        lines.append(
            "Walk-forward validated pattern detections delivered on-chain via "
            "Chainlink. FREE to subscribe."
        )
        lines.append("")
    
        lines.append("Detected Patterns (validated 2017-2026, 75K+ candles):\n")
        lines.append(f"  {'Token':<5} {'Pattern':<22} {'Code':<6} {'Accuracy':<10} {'Avg Return':<14} {'Frequency':<14} {'Folds'}")
        lines.append(f"  {'-'*5} {'-'*22} {'-'*6} {'-'*10} {'-'*14} {'-'*14} {'-'*5}")
        for p in patterns:
            lines.append(
                f"  {p.get('token', '?'):<5} {p['name']:<22} {p['code']:<6} {p['accuracy']:<10} "
                f"{p['avg_return']:<14} {p['frequency']:<14} {p.get('fold_validation', '?')}"
            )
        lines.append("")
    
        lines.append("How to Use:")
        lines.append("  1. Subscribe — one call, free, permissionless: subscribe(keccak256(\"BTC\"))")
        lines.append("  2. Receive — your contract gets VisionFired events with pattern, confidence, indicators, analysis, and feeds-to-watch")
        lines.append("  3. React — read the payload on-chain, auto-subscribe to confirmation Events, trigger your strategy")
        lines.append("")
    
        lines.append(f"Vision Registry: {registry}")
        lines.append(f"Chain: Polygon PoS (mainnet)")
        lines.append(f"Subscription fee: FREE")
        lines.append(f"Tokens: {', '.join(tokens)}")
        lines.append(f"Signal frequency: ~107 Visions/year for BTC (100 OVERSOLD + 7 CAPITULATION), ~13/year for ETH")
        lines.append("")
    
        if stats.get("total_fired"):
            lines.append(f"Stats: {stats['total_fired']} total fired, "
                         f"avg confidence {stats.get('avg_confidence', 'N/A')}")
            lines.append("")
    
        lines.append("Use get_visions_guide() for Solidity integration code.")
        lines.append("Use get_vision_history() for recent Visions fired.")
        return "\n".join(lines)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses that the subscription is free (no LINK required) and that it returns a complete contract. However, it does not mention other behavioral aspects like side effects, rate limits, or that it is a read-only operation. The score reflects good but not exhaustive transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences long, front-loads the purpose, and every sentence provides essential information without waste.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple nature (no parameters, returns Solidity code), the description fully covers the tool's purpose and key details (free subscription, events). The output schema existence is noted but not needed for completeness here.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, and schema description coverage is 100% (since no parameters exist). The description does not need to add parameter info, and baseline for 0 params is 4. No additional value needed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool returns Solidity code to subscribe to Pythia Visions and listen for VisionFired events, with a specific verb ('Get') and resource. It distinguishes from sibling tools like get_contracts (generic) and get_events_guide.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for subscribing to Pythia Visions but does not explicitly mention when to use this tool versus alternatives or provide exclusion criteria. The context is clear from the name and description, but explicit guidance would improve the score.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pythia-the-oracle/pythia-oracle-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server