Used for processing and analyzing stock data, enabling operations like retrieving historical stock information, monthly price data, and financial metrics.
Handles data validation and serialization for stock information models, ensuring proper formatting of stock data and configuration settings.
Provides the runtime environment for the stock information service, supporting data processing and API functionality for stock market data.
Used for code formatting and linting to maintain code quality across the stock information service codebase.
Stock Info Service
这是一个基于 FastMCP 的股票数据服务,提供了股票历史数据、基本面信息、新闻资讯等功能。
项目结构
功能特性
- 获取股票历史数据
- 查询股票基本信息
- 获取风险警示股票列表
- 查看个股新闻
- 获取财经新闻(支持分页)
- 获取股票主营业务信息
- .....后续逐渐增加
MCP客户端配置步骤
- 拉取��码
- 使用uv建立虚拟环境 python 1.10+
- 使用本地目录方式配置MCP服务
环境要求
- Python >= 3.10
- 依赖包:
- fastmcp
- akshare
- pandas
- pydantic
- pydantic-settings
安装部署
- 创建虚拟环境:
- 激活虚拟环境:
- 安装依赖:
启动服务
工具说明
get_stock_info
: 获取指定股票代码、指定日期范围的股价信息get_stock_price_monthly
: 获取指定股票最近30天的股价信息stock_individual_basic_info
: 获取指定股票的基本信息risk_stocks
: 获取风险警示板股票列表stock_merito_data
: 获取指定股票的主营业务信息get_stock_news
: 获取指定股票的新闻资讯get_finance_news
: 获取财经精选新闻(支持分页)
项目特点
- 模块化设计:采用清晰的分层架构,便于维护和扩展
- 统一异常处理:使用自定义异常体系,提供友好的错误提示
- 配置集中管理:使用 pydantic-settings 进行配置管理
- 类型提示:全面使用 Python 类型注解,提高代码可读性
- 数据验证:使用 Pydantic 模型进行数据验证和序列化
开发规范
- 使用 ruff 进行代码格式化和 lint
- 遵循 PEP 8 编码规范
- 保持完整的类型注解
- 编写清晰的文档字符串
错误处理
服务统一返回以下格式的错误信息:
主要错误代码
STOCK_NOT_FOUND
: 股票代码不存在INVALID_DATE_FORMAT
: 日期格式错误DATA_FETCH_ERROR
: 数据获取失败INVALID_PAGINATION
: 分页参数错误SYSTEM_ERROR
: 系统内部错误
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
A FastMCP-based service that provides stock data including historical prices, fundamental information, and financial news.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that provides KOSPI/KOSDAQ stock data using FastMCP.Last updated -512PythonMIT License
- -securityAlicense-qualityAn MCP server that integrates with the AlphaVantage financial data API, providing access to stock market data, technical indicators, and fundamental financial information.Last updated -PythonMIT License
- -securityFlicense-qualityA TypeScript-based MCP server that fetches real-time stock market data and company financial information through the Alpha Vantage API.Last updated -JavaScript
- -security-license-qualityA stock data MCP server based on BaoStock that provides multiple interfaces for retrieving stock market data.Last updated -4Python