agentis-dev/Token-Prices-MCP
If you are the rightful owner of Token-Prices-MCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
Message Control Protocol (MCP) server for retrieving cryptocurrency token prices from multiple blockchain sources.
get_token_price
Get current token price.
get_multiple_prices
Get multiple token prices.
get_token_data
Get detailed token data.
get_dex_price
Get price from specific DEX.
get_chainlink_price
Get price from Chainlink price feeds.
token-prices-mcp
Message Control Protocol (MCP) server for retrieving cryptocurrency token prices from multiple blockchain sources. Built with fastmcp and supports real-time price data from CoinGecko, on-chain DEX aggregators, and blockchain price feeds.
Features
- MCP server for token price data with multiple data sources
- Support for multiple transport protocols (stdio, SSE, WebSocket)
- Real-time price feeds from CoinGecko API
- On-chain price data from DEX aggregators (Uniswap, PancakeSwap, etc.)
- Chainlink price feed integration
- Easy-to-use client for interacting with the MCP server
- Command-line interface for running the server
- Integration with Claude Desktop
- Comprehensive caching with TTL
- Rate limiting and circuit breaker patterns
- Multi-chain support (Ethereum, BSC, Polygon, Arbitrum, etc.)
Quick Start
# Install the package
pip install token-prices-mcp
# Run the server (stdio transport for Claude Desktop)
token-prices-mcp --transport stdio
# Or run with SSE transport
token-prices-mcp --transport sse --host 127.0.0.1 --port 8000
Basic Usage
Client with Network Transport
import asyncio
import os
from token_prices_mcp.client import TokenPricesMCPClient
async def main():
# Set the server URL (or use environment variable)
server_url = "http://localhost:8000/sse"
os.environ["TOKEN_PRICES_MCP_URL"] = server_url
async with TokenPricesMCPClient() as client:
# Get token price from CoinGecko
btc_price = await client.get_token_price("bitcoin")
print("BTC Price:", btc_price)
# Get multiple token prices
prices = await client.get_multiple_prices(["ethereum", "bitcoin", "cardano"])
print("Multiple prices:", prices)
# Get token price with historical data
eth_data = await client.get_token_data("ethereum", include_24h_change=True)
print("ETH Data:", eth_data)
# Get price from specific DEX
uniswap_price = await client.get_dex_price("0xA0b86a33E6D0bBa464", "uniswap_v3")
print("Uniswap price:", uniswap_price)
if __name__ == "__main__":
asyncio.run(main())
Server Configuration
from token_prices_mcp.server import create_server
import asyncio
# Create the server with custom configuration
server = create_server(
name="Token Prices API",
cache_ttl=300, # 5 minutes cache
rate_limit=100 # 100 requests per minute
)
# Run the server with desired transport
if __name__ == "__main__":
asyncio.run(
server.run(
transport="stdio", # or "sse"
host="127.0.0.1", # for network transports
port=8000 # for network transports
)
)
Available Tools
Price Data
get_token_price(token_id: str, vs_currency: str = "usd")
: Get current token priceget_multiple_prices(token_ids: list, vs_currency: str = "usd")
: Get multiple token pricesget_token_data(token_id: str, include_24h_change: bool = False)
: Get detailed token dataget_price_history(token_id: str, days: int = 7)
: Get historical price datasearch_tokens(query: str)
: Search for tokens by name or symbol
DEX Integration
get_dex_price(token_address: str, dex: str, chain: str = "ethereum")
: Get price from specific DEXget_liquidity_pools(token_address: str, chain: str = "ethereum")
: Get liquidity pool informationget_dex_volume(token_address: str, timeframe: str = "24h")
: Get trading volume from DEXs
On-Chain Data
get_chainlink_price(pair: str)
: Get price from Chainlink price feedsget_token_supply(token_address: str, chain: str = "ethereum")
: Get token supply informationget_token_holders(token_address: str, chain: str = "ethereum")
: Get top token holdersget_market_cap(token_id: str)
: Get real-time market cap
Market Analytics
get_trending_tokens(limit: int = 10)
: Get trending tokensget_top_gainers(limit: int = 10, timeframe: str = "24h")
: Get top gainersget_top_losers(limit: int = 10, timeframe: str = "24h")
: Get top losersget_market_overview()
: Get overall market statistics
Resources
prices://tokens
: Get all supported tokensprices://tokens/{token_id}
: Get specific token informationprices://markets
: Get all markets informationprices://chains
: Get supported blockchain networksprices://dexes
: Get supported DEX platforms
Environment Variables
# CoinGecko API (optional, for higher rate limits)
COINGECKO_API_KEY=your_api_key_here
# Ethereum RPC endpoint (for on-chain data)
ETHEREUM_RPC_URL=https://mainnet.infura.io/v3/your_project_id
# BSC RPC endpoint
BSC_RPC_URL=https://bsc-dataseed.binance.org/
# Polygon RPC endpoint
POLYGON_RPC_URL=https://polygon-rpc.com/
# Arbitrum RPC endpoint
ARBITRUM_RPC_URL=https://arb1.arbitrum.io/rpc
# Cache settings
CACHE_TTL=300
RATE_LIMIT_PER_MINUTE=100
# Server settings
TOKEN_PRICES_MCP_URL=http://localhost:8000/sse
Command-line Interface
# Show help
token-prices-mcp --help
# Run with stdio transport (for Claude Desktop)
token-prices-mcp --transport stdio
# Run with SSE transport
token-prices-mcp --transport sse --host localhost --port 8000
# Run with custom cache TTL
token-prices-mcp --transport stdio --cache-ttl 600
# Run with debug logging
token-prices-mcp --transport stdio --debug
Supported Chains
- Ethereum
- Binance Smart Chain (BSC)
- Polygon
- Arbitrum
- Optimism
- Avalanche
- Fantom
- Cronos
- Aurora
Supported DEXs
- Uniswap V2/V3
- PancakeSwap V2/V3
- SushiSwap
- QuickSwap
- TraderJoe
- SpookySwap
- Curve Finance
- Balancer
- 1inch
Data Sources
- CoinGecko API: Primary source for token prices and market data
- On-chain DEX Data: Real-time prices from decentralized exchanges
- Chainlink Price Feeds: Decentralized oracle price data
- Blockchain RPCs: Direct on-chain token and contract data
Caching Strategy
- Price data cached for 5 minutes by default
- Market data cached for 10 minutes
- Token metadata cached for 1 hour
- Historical data cached for 24 hours
- Configurable TTL per data type
Rate Limiting
- CoinGecko API: 100 requests/minute (free tier)
- On-chain calls: 50 requests/minute per RPC
- Internal rate limiting with exponential backoff
- Circuit breaker pattern for failed requests
Development
# Clone the repository
git clone https://github.com/tokenprices/token-prices-mcp.git
cd token-prices-mcp
# Install development dependencies
pip install -e ".[dev]"
# Install pre-commit hooks
pre-commit install
# Run tests
pytest
# Run type checking
pyright src/token_prices_mcp
# Run linting
ruff check .
Examples
Check the examples/
directory for more usage examples:
claude_desktop_server.py
: Run the server with stdio transport for Claude Desktopclaude_desktop_client.py
: Client for connecting to a stdio serversse_server.py
: Run the server with SSE transportsse_client.py
: Client for connecting to an SSE serverprice_monitoring.py
: Real-time price monitoring exampledex_arbitrage.py
: DEX price comparison example
API Rate Limits
CoinGecko (Free Tier)
- 100 requests/minute
- 1000 requests/hour
CoinGecko (Pro Tier)
- 500 requests/minute
- 10000 requests/hour
On-Chain RPCs
- Varies by provider
- Built-in rate limiting and retry logic
Error Handling
The server implements comprehensive error handling:
- Automatic retry with exponential backoff
- Circuit breaker for failed API endpoints
- Fallback to cached data when APIs are unavailable
- Graceful degradation of service quality
- Detailed error logging and monitoring
License
Apache License 2.0
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Support
- Documentation: GitHub README
- Issues: GitHub Issues
- Community: Discussions