get_realtime_data
Retrieve real-time stock market data for A, B, and H shares using specified sources like eastmoney_direct or xueqiu, with support for custom stock symbols.
Instructions
Get real-time stock market data. 'eastmoney_direct' support all A,B,H shares
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | No | Data source | eastmoney_direct |
| symbol | No | Stock symbol/ticker (e.g. '000001') |
Input Schema (JSON Schema)
{
"properties": {
"source": {
"default": "eastmoney_direct",
"description": "Data source",
"enum": [
"xueqiu",
"eastmoney",
"eastmoney_direct"
],
"title": "Source",
"type": "string"
},
"symbol": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
],
"default": null,
"description": "Stock symbol/ticker (e.g. '000001')",
"title": "Symbol"
}
},
"type": "object"
}
Implementation Reference
- src/akshare_one_mcp/server.py:155-167 (handler)The @mcp.tool decorator registers the 'get_realtime_data' tool. The function defines input schema via Annotated types with descriptions and executes the core logic: fetches realtime stock data using akshare and returns it as JSON string.@mcp.tool def get_realtime_data( symbol: Annotated[ str | None, Field(description="Stock symbol/ticker (e.g. '000001')") ] = None, source: Annotated[ Literal["xueqiu", "eastmoney", "eastmoney_direct"], Field(description="Data source"), ] = "eastmoney_direct", ) -> str: """Get real-time stock market data. 'eastmoney_direct' support all A,B,H shares""" df = ako.get_realtime_data(symbol=symbol, source=source) return df.to_json(orient="records") or "[]"