
Stock Analysis MCP Server
Enables real-time stock market analysis through AKShare API integration. Supports retrieving live stock prices, historical data, technical indicators (MA, MACD, RSI), market sentiment analysis, stock search, and financial news.
README
股票分析MCP工具
基于fastmcp和AKShare API构建的股票分析MCP服务器,支持CherryStudio的SSE标准协议。
功能特性
🚀 核心功能
- 实时行情: 获取股票实时价格、涨跌幅、成交量等数据
- 历史数据: 支持日线、周线、月线历史数据查询
- 技术指标: 计算MA、MACD、RSI等常用技术指标
- 市场情绪: 分析市场整体情绪和资金流向
- 股票搜索: 根据股票名称或代码搜索股票信息
- 新闻资讯: 获取股票相关新闻和市场资讯
🔧 技术特性
- 基于fastmcp框架,支持MCP协议
- 集成AKShare API,数据来源可靠
- 内置缓存机制,提高响应速度
- 支持CherryStudio的SSE标准协议
- 异步处理,高性能并发
安装配置
1. 安装依赖
pip install -r requirements.txt
2. 启动服务器
python stock_mcp_server.py
3. 配置CherryStudio
在CherryStudio中添加MCP服务器配置:
{
"name": "股票分析工具",
"command": "python",
"args": ["stock_mcp_server.py"],
"cwd": "/path/to/your/project"
}
工具使用说明
1. 获取实时行情
get_stock_realtime_data(symbol="000001")
symbol
: 股票代码,如 "000001"(平安银行)
2. 获取历史数据
get_stock_history_data(
symbol="000001",
period="daily",
start_date="20240101",
end_date="20241231"
)
symbol
: 股票代码period
: 数据周期 ("daily", "weekly", "monthly")start_date
: 开始日期 (YYYYMMDD格式)end_date
: 结束日期 (YYYYMMDD格式)
3. 计算技术指标
calculate_technical_indicators(
symbol="000001",
indicators=["ma", "macd", "rsi"]
)
symbol
: 股票代码indicators
: 指标列表,支持 ["ma", "macd", "rsi", "boll", "kdj"]
4. 获取市场情绪
get_market_sentiment(symbol="000001") # 个股情绪
get_market_sentiment() # 整体市场情绪
5. 搜索股票
search_stock_info(keyword="平安银行")
keyword
: 搜索关键词(股票名称或代码)
6. 获取新闻资讯
get_stock_news(symbol="000001", limit=10) # 个股新闻
get_stock_news(limit=20) # 市场新闻
数据说明
实时行情数据字段
- 股票代码、股票名称
- 最新价、涨跌幅、涨跌额
- 成交量、成交额、振幅
- 最高价、最低价、开盘价、昨收价
技术指标说明
- MA: 移动平均线 (5日、10日、20日、60日)
- MACD: 指数平滑移动平均线
- RSI: 相对强弱指标 (14日)
市场情绪指标
- 上涨/下跌股票数量和比例
- 主力资金净流入情况
- 北向资金流向数据
注意事项
- 数据来源: 数据来自AKShare API,请遵守相关使用条款
- 缓存机制: 内置5分钟缓存,避免频繁请求
- 错误处理: 包含完善的错误处理和日志记录
- 性能优化: 限制返回数据量,避免内存溢出
开发扩展
添加新的技术指标
在 calculate_technical_indicators
函数中添加新的指标计算逻辑:
# 计算布林带
if 'boll' in indicators:
df['BOLL_MID'] = df['收盘'].rolling(window=20).mean()
df['BOLL_STD'] = df['收盘'].rolling(window=20).std()
df['BOLL_UPPER'] = df['BOLL_MID'] + 2 * df['BOLL_STD']
df['BOLL_LOWER'] = df['BOLL_MID'] - 2 * df['BOLL_STD']
自定义缓存策略
修改 StockAnalyzer
类中的缓存参数:
self.cache_timeout = 300 # 缓存时间(秒)
许可证
MIT License
贡献
欢迎提交Issue和Pull Request来改进这个项目!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.