关于 my-mcp-server
my-mcp-server(README 中称 MCP Crypto Server)通过交易所行情、历史数据和加密货币新闻提供分析能力,面向加密市场研究场景。它结合 CCXT、TimescaleDB 与 RSS,并提供市场和新闻相关的工具、资源及提示词。
主要功能
- 01获取多交易所实时行情
- 02查询历史价格与成交量
- 03分析市场趋势和技术指标
- 04聚合加密货币 RSS 新闻
- 05分析新闻情绪与影响
适用场景
- 01查看特定加密货币的实时行情
- 02研究历史价格和成交量变化
- 03汇总近期新闻并评估市场影响
MCP 相关
该 MCP 服务向客户端提供市场分析、价格数据、LLM 分析和新闻分析工具,并公开行情、历史数据、币种列表及新闻资源,还包含预设提示词。
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
我们还没有获取到这个服务的安装包或远程地址,请按项目 README 中的说明安装。
工具
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
MCP Crypto Server
基于 FastMCP、CCXT、TimescaleDB 和 RSS 订阅源集成构建的高性能加密货币市场数据与分析平台。
概述
MCP Crypto Server 是一个功能强大的平台,可提供实时加密货币市场数据、高级分析、大模型驱动的洞察和加密货币新闻聚合。它基于 Model Context Protocol(MCP)构建,能够与 AI 应用无缝集成,同时借助 CCXT 提供稳健的加密货币交易所连接能力,使用 TimescaleDB 存储时间序列数据,并通过 RSS 订阅源实时更新新闻。
主要功能
- 实时市场数据:获取来自多个交易所的实时加密货币市场数据
- 历史数据分析:查询和分析历史价格与成交量数据
- 大模型集成:利用 AI 分析市场趋势并获取洞察
- MCP 协议支持:使用 Model Context Protocol 轻松集成 AI 应用
- 可扩展架构:凭借优化的性能处理大量请求
- TimescaleDB 存储:高效存储和查询时间序列数据
- 多交易所支持:通过 CCXT 连接各种加密货币交易所
- 加密货币新闻聚合:收集并分析来自多个加密货币 RSS 订阅源的新闻
- 新闻情绪分析:由 AI 驱动的加密货币新闻情绪分析
- 自定义 RSS 订阅源订阅:配置和管理新闻来源
架构
┌─────────────────────────────────────────────────────────────────┐
│ 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 │
└─────────────┘ └────────────┘ └────────────────────┘
技术栈
- FastMCP:基于 Model Context Protocol 的服务框架
- CCXT:用于连接加密货币交易所的库
- TimescaleDB:PostgreSQL 的时间序列数据库扩展
- Python:核心编程语言
- uv:用于依赖管理的高性能 Python 包管理器
- feedparser:RSS 订阅源解析库
- NLTK/spaCy:用于新闻分析的自然语言处理工具
项目结构
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
安装
先决条件
- Python 3.9+
- Docker 和 Docker Compose
- uv 包管理器
设置
-
克隆仓库:
git clone https://github.com/yourusername/mcp-crypto-server.git cd mcp-crypto-server -
如果尚未安装 uv,请先安装:
curl -LsSf https://astral.sh/uv/install.sh | sh -
创建虚拟环境并安装依赖:
uv venv uv pip sync -
使用 Docker 设置 TimescaleDB:
docker-compose up -d timescaledb -
配置环境变量:
cp .env.example .env # Edit .env with your configuration settings
配置
编辑 config/settings.py 文件以自定义应用:
- 数据库连接参数
- 交易所 API 密钥和设置
- MCP 服务配置
- 大模型服务设置
- RSS 订阅源订阅设置
- 新闻来源配置
- 日志级别和输出
配置 RSS 订阅源
系统预置了加密货币新闻来源,但你可以自定义这些来源:
# 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
]
用法
启动服务
uv run python main.py
服务默认启动后,可通过 MCP 客户端连接。
MCP 功能
该服务提供以下 MCP 功能:
工具
market_analysis- 分析市场趋势并提供技术指标price_data- 获取特定加密货币的实时或历史价格数据llm_analysis- 生成由 AI 驱动的市场洞察和预测news_analysis- 分析新闻情绪及其对特定币种的影响news_summary- 生成近期加密货币新闻摘要
资源
symbols://list- 获取所有可用的加密货币符号market_data://{symbol}- 获取特定符号的实时市场数据historical_data://{symbol}?timeframe={timeframe}&start={start}&end={end}- 根据参数获取历史数据news://recent- 获取所有来源的最新新闻news://{source}- 获取特定来源的新闻news://by-coin/{symbol}- 获取与特定加密货币相关的新闻
提示词
analyze_market_trend- 用于分析市场趋势的预定义提示词generate_trading_recommendation- 根据当前市场数据生成交易建议analyze_news_impact- 分析近期新闻可能对加密货币价格造成的影响
在 MCP 客户端中使用新闻功能
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)
开发
添加新的交易所
- 更新
services/exchange_service.py文件,添加新交易所的配置 - 实现所需的交易所专属处理逻辑
- 更新
resources/symbols.py中的可用交易对
添加新的 RSS 源
- 更新
config/settings.py文件,添加新的源配置 - 如果该源需要特殊解析,请扩展
services/news_service.py,添加自定义处理器 - (可选)在
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
创建自定义工具
- 在
tools/目录中添加新文件 - 使用 FastMCP 装饰器实现工具逻辑:
@mcp.tool() def your_tool_name(param1: str, param2: int) -> dict: """Tool description""" # Implementation return result
添加新资源
- 在相应的资源文件中创建资源函数:
@mcp.resource("resource://{parameter}") def get_resource(parameter: str) -> str: """Resource description""" # Implementation return data
使用 uv 管理依赖项
该项目使用 uv 进行快速高效的依赖项管理:
-
添加新依赖项:
uv add package_name -
更新所有依赖项:
uv pip sync -
生成锁定文件:
uv pip compile -o uv.lock
性能注意事项
- 应用利用 TimescaleDB 的时间序列优化,高效查询历史数据
- 根据数据量考虑使用具有适当分块间隔的 TimescaleDB 超表
- 为频繁访问的数据实施适当的缓存策略
- 对于 RSS 源,请根据源的更新频率调整轮询间隔,以尽量减少不必要的请求
- 考虑为 RSS 源更新实现后台任务调度器,避免阻塞主应用线程
- 通过在负载均衡器后部署多个实例实现横向扩展
许可证
致谢
- FastMCP - Model Context Protocol 服务实现
- Model Context Protocol - 面向 AI 应用的高效协议
- CCXT - 加密货币交易所交易库
- TimescaleDB - PostgreSQL 的时间序列数据库
- uv - 高性能 Python 包管理器
- feedparser - Python RSS 源解析库
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。