Skip to main content
Glama
resources.py5.21 kB
"""Resource definitions for Pyth Network MCP Server.""" from mcp.types import Resource import json def get_resource_definitions() -> list[Resource]: """Get all available Pyth Network resource definitions.""" return [ Resource( uri="pyth://network/info", name="Pyth Network Information", description="General information about Pyth Network, including supported blockchains and data providers", mimeType="text/plain" ), Resource( uri="pyth://feeds/popular", name="Popular Price Feeds", description="List of most commonly used Pyth Network price feed IDs", mimeType="application/json" ), Resource( uri="pyth://docs/api", name="API Documentation Reference", description="Quick reference for Pyth Hermes API endpoints and parameters", mimeType="text/markdown" ) ] def handle_read_resource(uri: str) -> str: """Read the content of a specific Pyth Network resource.""" if uri == "pyth://network/info": return """Pyth Network Information ====================== Overview: --------- Pyth Network is a decentralized oracle protocol that delivers real-time market data to smart contracts across 107+ blockchains. Data Providers: -------------- 125+ first-party publishers including: - Major exchanges (Binance, Coinbase, OKX, etc.) - Market makers and trading firms - Financial institutions Coverage: --------- - 1,930+ price feeds - 107+ supported blockchains - Asset types: crypto, equity, fx, metal, rates - Update frequency: ~400ms Key Features: ------------ - Pull-based oracle model - Universal price feed IDs (same ID across all chains) - High-frequency updates - Confidence intervals for data quality - Cryptographic proof verification Official Resources: ------------------ - Website: https://pyth.network - Documentation: https://docs.pyth.network - API: https://hermes.pyth.network """ elif uri == "pyth://feeds/popular": popular_feeds = { "crypto": { "BTC/USD": "e62df6c8b4a85fe1a67db44dc12de5db330f7ac66b72dc658afedf0f4a415b43", "ETH/USD": "ff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace", "SOL/USD": "ef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d", "USDC/USD": "eaa020c61cc479712813461ce153894a96a6c00b21ed0cfc2798d1f9a9e9c94a", "USDT/USD": "2b89b9dc8fdf9f34709a5b106b472f0f39bb6ca9ce04b0fd7f2e971688e2e53b", "BNB/USD": "2f95862b045670cd22bee3114c39763a4a08beeb663b145d283c31d7d1101c4f" }, "equity": { "AAPL": "49f6b65cb1de6b10eaf75e7c03ca029c306d0357e91b5311b175084a5ad55688", "TSLA": "16dad506d7db6da91dd82d0f2ca0b925f12551e6e0bb9bb6c5e22e7dcf3b5d78", "MSFT": "4fe0e47c5e96bb9e95e3d4d2c9a6dc7e7d9c0e69d8e8e3d3e3e3e3e3e3e3e3e3" }, "fx": { "EUR/USD": "a995d00bb36a63cef7fd2c287dc105fc8f3d93779f062f09551b0af3e81ec30b", "GBP/USD": "84c2dde9633d93d1bcad84e7dc41c25d98f59a5c0e3d76e8f7ae8e4c9e9e9e9e" }, "metal": { "Gold": "765d2ba906dbc32ca17cc11f5310a89e9ee1f6420508c63861f2f8ba4ee34bb2", "Silver": "f2fb02c32b055c805e7238d628e5e9dadef274376114eb1f012337cabe93871e" } } return json.dumps(popular_feeds, indent=2) elif uri == "pyth://docs/api": return """# Pyth Hermes API Quick Reference Base URL: `https://hermes.pyth.network` ## Endpoints ### Get Price Feeds ``` GET /v2/price_feeds Query params: - query: string (optional) - Filter by symbol - asset_type: string (optional) - Filter by type (crypto, equity, fx, metal, rates) ``` ### Get Latest Price Updates ``` GET /v2/updates/price/latest Query params: - ids[]: array of price feed IDs (required) - encoding: hex | base64 (default: hex) - parsed: boolean (default: true) - ignore_invalid_price_ids: boolean (default: false) ``` ### Get Price Updates at Time ``` GET /v2/updates/price/{timestamp} Path params: - timestamp: Unix timestamp in seconds Query params: - ids[]: array of price feed IDs (required) - encoding: hex | base64 - parsed: boolean ``` ### Get Publisher Stake Caps ``` GET /v2/updates/publisher_stake_caps/latest Query params: - encoding: hex | base64 - parsed: boolean ``` ### Get TWAP ``` GET /v2/updates/twap/{window_seconds}/latest Path params: - window_seconds: 1-600 (time window) Query params: - ids[]: array of price feed IDs (required) - encoding: hex | base64 - parsed: boolean ``` ## Price Format Prices are returned with an exponent: - `price`: the raw price value - `expo`: exponent (usually -8) - `conf`: confidence interval **Actual Price = price × 10^expo** Example: price=11339522000000, expo=-8 Result: 113,395.22 ## Resources - Full API Docs: https://hermes.pyth.network/docs - Price Feeds List: https://pyth.network/price-feeds - Developer Docs: https://docs.pyth.network """ else: raise ValueError(f"Unknown resource: {uri}")

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/itsOmSarraf/pyth-network-mcp'

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