mcp-crypto-server
If you are the rightful owner of mcp-crypto-server 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.
MCP Crypto Server is a high-performance platform for cryptocurrency market data and analysis, integrating FastMCP, CCXT, TimescaleDB, and RSS feeds.
MCP Crypto Server
A high-performance cryptocurrency market data and analysis platform built with FastMCP, CCXT, TimescaleDB, and RSS feed integration.
Overview
MCP Crypto Server is a powerful platform that provides real-time cryptocurrency market data, advanced analytics, LLM-powered insights, and crypto news aggregation. Built on the Model Context Protocol (MCP), it enables seamless integration with AI applications while offering robust cryptocurrency exchange connectivity via CCXT, time-series data storage with TimescaleDB, and real-time news updates through RSS feeds.
Key Features
- Real-time Market Data: Access live cryptocurrency market data from multiple exchanges
- Historical Data Analysis: Query and analyze historical price and volume data
- LLM Integration: Leverage AI for market trend analysis and insights
- MCP Protocol Support: Easily integrate with AI applications using the Model Context Protocol
- Scalable Architecture: Handle high request volumes with optimized performance
- TimescaleDB Storage: Efficient time-series data storage and querying
- Multi-Exchange Support: Connect to various cryptocurrency exchanges via CCXT
- Crypto News Aggregation: Collect and analyze news from multiple crypto RSS feeds
- News Sentiment Analysis: AI-powered sentiment analysis of crypto news
- Custom RSS Feed Subscriptions: Configure and manage news sources
Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Client Applications โ
โ (Claude Desktop, Custom AI Applications, Analysis Tools) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ FastMCP Server โ
โโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโค
โ Resources โ Tools โ Prompts โ Schemas โ
โ โ โ โ โ
โ Market Data โ Market Analysis โ Trading Rec. โ Input/ โ
โ Symbols โ Price Data โ Market Trend โ Output โ
โ Historical โ LLM Analysis โ Analysis โ Validation โ
โ News Feed โ News Analysis โ News Impact โ โ
โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโ
โ โ โ
โผ โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
โ Exchange โ โ RSS โ โ Database Service โ
โ Service โ โ Service โ โ โ
โ โ โ โ โ TimescaleDB โ
โ CCXT โ โ Feed Parserโ โ Time-series โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโ
Technology Stack
- FastMCP: Server framework based on the Model Context Protocol
- CCXT: Library for cryptocurrency exchange connectivity
- TimescaleDB: Time-series database extension for PostgreSQL
- Python: Core programming language
- uv: High-performance Python package manager for dependency management
- feedparser: RSS feed parsing library
- NLTK/spaCy: Natural language processing for news analysis
Project Structure
mcp-crypto-server/
โโโ main.py # Main entry point with FastMCP server definition
โโโ config/ # Configuration directory
โ โโโ __init__.py
โ โโโ settings.py # Application settings and configuration
โ โโโ logging_config.py # Logging configuration
โโโ resources/ # MCP resources
โ โโโ __init__.py
โ โโโ market_data.py # Market data resources
โ โโโ symbols.py # Cryptocurrency symbols resources
โ โโโ schemas.py # Schema resources for the client
โ โโโ news.py # News feed resources and endpoints
โโโ tools/ # MCP tools
โ โโโ __init__.py
โ โโโ market_analysis.py # Market analysis tools
โ โโโ price_data.py # Price retrieval tools
โ โโโ llm_analysis.py # LLM integration for data analysis
โ โโโ news_analysis.py # News analysis and sentiment tools
โโโ services/ # Service integrations
โ โโโ __init__.py
โ โโโ exchange_service.py # Exchange API integration
โ โโโ database_service.py # Database service for storing data
โ โโโ llm_service.py # LLM service integration
โ โโโ news_service.py # RSS feed management and processing
โโโ models/ # Data models
โ โโโ __init__.py
โ โโโ market_data.py # Data models for market data
โ โโโ analysis.py # Models for analysis results
โ โโโ news.py # Models for news data and analysis
โโโ utils/ # Utility functions
โ โโโ __init__.py
โ โโโ formatters.py # Data formatting utilities
โ โโโ validators.py # Input validation utilities
โ โโโ feed_utils.py # RSS feed utility functions
โโโ prompts/ # MCP prompts
โ โโโ __init__.py
โ โโโ analysis_prompts.py # Prompt templates for analysis
โ โโโ news_prompts.py # Prompt templates for news analysis
โโโ pyproject.toml # Project configuration and dependencies
โโโ uv.lock # Lock file for dependencies managed by uv
Installation
Prerequisites
- Python 3.9+
- Docker and Docker Compose
- uv package manager
Setup
-
Clone the repository:
git clone https://github.com/yourusername/mcp-crypto-server.git cd mcp-crypto-server
-
Install uv if you don't already have it:
curl -LsSf https://astral.sh/uv/install.sh | sh
-
Create a virtual environment and install dependencies:
uv venv uv pip sync
-
Set up TimescaleDB using Docker:
docker-compose up -d timescaledb
-
Configure your environment variables:
cp .env.example .env # Edit .env with your configuration settings
Configuration
Edit the config/settings.py
file to customize your application:
- Database connection parameters
- Exchange API keys and settings
- MCP server configuration
- LLM service settings
- RSS feed subscription settings
- News source configurations
- Logging levels and outputs
Configuring RSS Feeds
The system comes with predefined crypto news sources, but you can customize them:
# In config/settings.py
RSS_FEEDS = [
{
"name": "CoinDesk",
"url": "https://www.coindesk.com/arc/outboundfeeds/rss/",
"update_interval": 900, # 15 minutes
"categories": ["news", "markets", "business"]
},
{
"name": "Cointelegraph",
"url": "https://cointelegraph.com/rss",
"update_interval": 600, # 10 minutes
"categories": ["news", "analysis"]
},
# Add your custom RSS feeds here
]
Usage
Starting the Server
uv run python main.py
The server will start by default and be available for connection via MCP clients.
MCP Capabilities
The server exposes the following MCP capabilities:
Tools
market_analysis
- Analyze market trends and provide technical indicatorsprice_data
- Get real-time or historical price data for specific cryptocurrenciesllm_analysis
- Generate AI-driven market insights and predictionsnews_analysis
- Analyze news sentiment and impact on specific coinsnews_summary
- Generate summaries of recent crypto news
Resources
symbols://list
- Get all available cryptocurrency symbolsmarket_data://{symbol}
- Get real-time market data for a specific symbolhistorical_data://{symbol}?timeframe={timeframe}&start={start}&end={end}
- Get historical data with parametersnews://recent
- Get most recent news across all sourcesnews://{source}
- Get news from a specific sourcenews://by-coin/{symbol}
- Get news related to a specific cryptocurrency
Prompts
analyze_market_trend
- Pre-defined prompt for analyzing market trendsgenerate_trading_recommendation
- Generate trading recommendations based on current market dataanalyze_news_impact
- Analyze how recent news might impact cryptocurrency prices
Using News Features with MCP Clients
from mcp import Client
# Get recent news for a specific cryptocurrency
client = Client("http://localhost:8000")
news_response = await client.query(
inputs=[{"symbol": "BTC/USD"}],
resources=["news://by-coin/BTC"]
)
print(news_response.outputs)
# Analyze news sentiment and potential market impact
analysis_response = await client.query(
inputs=[{"symbol": "BTC/USD", "timeframe": "24h"}],
tools=["news_analysis"]
)
print(analysis_response.outputs)
Development
Adding a New Exchange
- Update the
services/exchange_service.py
file to add the new exchange configuration - Implement any exchange-specific handling required
- Update the available symbols in
resources/symbols.py
Adding a New RSS Feed Source
- Update the
config/settings.py
file to add the new feed configuration - If the feed requires special parsing, extend the
services/news_service.py
with custom handlers - (Optional) Add source-specific endpoints in
resources/news.py
# Example of adding a custom parser in services/news_service.py
def parse_custom_feed(feed_data, source_config):
"""Custom parser for a specific news source"""
articles = []
for entry in feed_data.entries:
# Custom parsing logic
articles.append({
"title": entry.title,
"url": entry.link,
"published": parse_date(entry.published),
"summary": entry.summary,
"source": source_config["name"]
})
return articles
Creating Custom Tools
- Add a new file in the
tools/
directory - Implement your tool logic using the FastMCP decorator:
@mcp.tool() def your_tool_name(param1: str, param2: int) -> dict: """Tool description""" # Implementation return result
Adding New Resources
- Create your resource function in the appropriate resources file:
@mcp.resource("resource://{parameter}") def get_resource(parameter: str) -> str: """Resource description""" # Implementation return data
Managing Dependencies with uv
The project uses uv for fast and efficient dependency management:
-
Add a new dependency:
uv add package_name
-
Update all dependencies:
uv pip sync
-
Generate lock file:
uv pip compile -o uv.lock
Performance Considerations
- The application leverages TimescaleDB's time-series optimization for efficient historical data queries
- Consider using TimescaleDB hypertables with appropriate chunk intervals based on your data volume
- Implement appropriate caching strategies for frequently accessed data
- For RSS feeds, adjust polling intervals based on source update frequency to minimize unnecessary requests
- Consider implementing a background task scheduler for RSS feed updates to avoid blocking main application threads
- Scale horizontally by deploying multiple instances behind a load balancer
License
Acknowledgements
- FastMCP - Model Context Protocol server implementation
- Model Context Protocol - Efficient protocol for AI applications
- CCXT - Cryptocurrency exchange trading library
- TimescaleDB - Time-series database for PostgreSQL
- uv - High-performance Python package manager
- feedparser - Python RSS feed parsing library