Ashare-MCP: Powering AI-Driven Financial Analysis with Real-Time A-Share Data
In the rapidly evolving landscape of AI-driven financial analysis, access to timely and accurate market data is paramount. Ashare-MCP, now available on the UBOS Asset Marketplace, provides a robust solution for accessing real-time A-share (China’s domestic stock market) data, empowering developers and analysts to build sophisticated AI agents and applications.
What is Ashare-MCP?
Ashare-MCP is an MCP (Model Context Protocol) server designed to provide A-share market data through a standardized interface. Built upon the foundation of the mpquant/Ashare project, Ashare-MCP offers a reliable and efficient way to query a wide range of market data, making it an invaluable asset for anyone working with Chinese financial markets.
At its core, Ashare-MCP is a data service that allows AI models and agents to interact with and understand financial market data. It acts as a bridge, providing context-rich information that enables LLMs to make informed decisions, automate trading strategies, and generate insightful financial analysis.
Key Features
- Comprehensive Data Coverage: Ashare-MCP supports a variety of timeframes, including minute-level (1m, 5m, 15m, 30m, 60m), daily (1d), weekly (1w), and monthly (1M) data. This granular data allows for detailed analysis and the development of high-frequency trading strategies.
- Flexible Stock Code Formats: The server accepts both Tongdaxin (e.g.,
sh000001) and JoinQuant (e.g.,000001.XSHG) stock code formats, providing flexibility and ease of use for users with different data preferences. - Dual Data Sources: To ensure data reliability and stability, Ashare-MCP leverages both Sina Finance and Tencent Finance as data sources. This redundancy minimizes the risk of data outages and ensures consistent data availability.
- Asynchronous Processing: Ashare-MCP is designed with asynchronous processing in mind, maximizing performance and enabling rapid data retrieval. This is crucial for real-time applications and high-volume data analysis.
- Simple and Intuitive API: The server offers a straightforward API, making it easy for developers to integrate Ashare-MCP into their existing systems and workflows.
Use Cases
Ashare-MCP unlocks a wide range of use cases in the financial domain, empowering AI agents and applications to perform tasks such as:
- Algorithmic Trading: Develop and deploy automated trading strategies based on real-time market data. AI agents can use Ashare-MCP to analyze market trends, identify trading opportunities, and execute trades automatically.
- Financial Modeling and Analysis: Build sophisticated financial models and perform in-depth market analysis using historical and real-time data. Ashare-MCP provides the data foundation for AI-powered financial forecasting and risk management.
- Sentiment Analysis: Analyze market sentiment by monitoring news articles, social media feeds, and other sources of information. AI agents can use Ashare-MCP to correlate market data with sentiment data, providing a more holistic view of market dynamics.
- Portfolio Management: Optimize portfolio allocation and risk management using AI-driven insights. Ashare-MCP can provide the data needed to build AI agents that automatically rebalance portfolios based on market conditions and investment goals.
- Quantitative Research: Conduct quantitative research and develop new trading strategies using historical market data. Ashare-MCP provides a reliable data source for backtesting and validating quantitative models.
- Real-Time Market Monitoring: Create dashboards and alerts to monitor market activity in real-time. AI agents can use Ashare-MCP to detect anomalies, identify emerging trends, and alert users to potential risks or opportunities.
Installation and Usage
Ashare-MCP can be easily installed using pip:
bash pip install git+https://github.com/RusianHu/Ashare-mcp.git
Once installed, Ashare-MCP can be used as an MCP service within the UBOS platform or as a standalone service.
As an MCP Service
To use Ashare-MCP as an MCP service, add the following configuration to your MCP configuration file:
{ “mcpServers”: { “ashare-mcp”: { “command”: “python”, “args”: [ “-m”, “ashare_mcp” ], “alwaysAllow”: [ “get_price” ], “disabled”: false } } }
As a Standalone Service
Ashare-MCP can also be run as a standalone service using the following commands:
bash
Using standard input/output mode
ashare-mcp
Using HTTP mode
fastmcp serve ashare_mcp
MCP Tool Function: get_price
The primary function offered by Ashare-MCP is get_price, which allows users to retrieve stock market data for various timeframes. This function accepts the following parameters:
| Parameter | Description | Type | Default Value |
|---|---|---|---|
code | Stock code (e.g., ‘sh000001’ or ‘000001.XSHG’) | string | - |
end_date | End date (YYYY-MM-DD) | string | Current date |
count | Number of K-lines to retrieve | integer | 10 |
frequency | K-line frequency (‘1m’, ‘5m’, ‘15m’, ‘30m’, ‘60m’, ‘1d’, ‘1w’, ‘1M’) | string | ‘1d’ |
fields | List of fields to return | array | All |
The get_price function returns an object containing the stock code, market data, and processing messages.
Code Examples
python
Get the last 5 days of daily data for the Shanghai Composite Index
result = await get_price_ashare_mcp(code=“sh000001”, count=5, frequency=“1d”)
Get historical data for Kweichow Moutai on a specific date
result = await get_price_ashare_mcp(code=“sh600519”, end_date=“2023-01-01”, count=10, frequency=“1d”)
Get minute-level data
result = await get_price_ashare_mcp(code=“sh600519”, count=5, frequency=“15m”)
Dependencies
Ashare-MCP relies on the following dependencies:
fastmcp>=0.1.0pandasrequests
Contributing
Contributions to Ashare-MCP are welcome! Please submit issues and pull requests to help improve the project.
License
Ashare-MCP is licensed under the MIT License.
Copyright © 2025 RusianHu
UBOS: The Full-Stack AI Agent Development Platform
Ashare-MCP is a valuable addition to the UBOS Asset Marketplace, complementing the UBOS platform’s mission to bring AI agents to every business department. UBOS provides a comprehensive set of tools and services for orchestrating AI agents, connecting them with enterprise data, building custom AI agents with your own LLM models, and creating sophisticated multi-agent systems.
By leveraging Ashare-MCP within the UBOS ecosystem, businesses can unlock new opportunities for AI-driven financial analysis, automated trading, and enhanced decision-making. UBOS empowers organizations to harness the power of AI to gain a competitive edge in the dynamic world of finance.
Ashare Stock Market Data Service – A股数据查询
Project Details
- RusianHu/Ashare-mcp
- MIT License
- Last Updated: 4/27/2025
Recomended MCP Servers
MCP server to access Singapore's LTA data
Config files for my GitHub profile.
MCP Lucene Server
LanceDB MCP Server nodejs
This read-only MCP Server allows you to connect to Airtable data from Claude Desktop through CData JDBC Drivers....





