README.md•1.99 kB
# MCP Stock Assistant
A Model Context Protocol (MCP) server that provides real-time stock information using the Xueqiu API.
## Features
- Fetch real-time stock data by stock code
- Support for Chinese stocks (e.g., SH600519) and US stocks (e.g., AAPL)
- Returns comprehensive stock information including:
- Stock name
- Current price
- Increase/decrease percentage
- Additional market data
## Installation
1. Clone the repository:
```
git clone <repository-url>
cd mcp-stock
```
2. Install dependencies:
```
npm install
```
3. Build the project:
```
npm run build
```
## Usage
### Running the Server
Start the MCP server:
```
npm start
```
### Using with MCP Clients
"mcp-stock": {
"command": "node",
"args": [
"/Users/zhangyanhua/Documents/augment-projects/mcp-stock/build/index.js"
]
}
This server implements the Model Context Protocol and can be used with any MCP client, such as Claude Desktop.
The server provides the following tool:
- `get-stock-info`: Get real-time stock information
- Parameter: `stock_code` - The stock code (e.g., SH600519, AAPL)
### Example Response
```json
{
"stock_code": "SH600519",
"stock_name": "贵州茅台",
"current_price": 1800.50,
"increase_percent": 2.35,
"decrease_percent": 0.00,
"volume": 1234567,
"amount": 1234567890.0,
"open": 1780.0,
"high": 1805.0,
"low": 1775.0,
"last_close": 1760.0,
"market_capital": 2260000000000.0,
"timestamp": "2023-06-01T12:34:56",
"year_percent": -5.2
}
```
## Stock Codes
- Chinese A-shares: Prefix with exchange code
- Shanghai: `SH` (e.g., `SH600519`)
- Shenzhen: `SZ` (e.g., `SZ000858`)
- US stocks: Use ticker symbol directly (e.g., `AAPL`, `MSFT`)
## Notes
- This server uses the Xueqiu API to fetch real-time stock data
- The server runs on stdio transport, making it compatible with MCP clients
- No API key is required for basic usage, but there may be rate limits
## License
ISC