Skip to main content
Glama
stock-mcp-server

stock-mcp-server

🐉 Qinglong — Real-time A-share data MCP server

License Python MCP

Give any MCP-capable AI agent — Claude Code, Cursor, Codex CLI, VS Code, Windsurf, Cline, Zed — live access to mainland China A-share market data.

Chinese version below · 中文说明

What it does

Tool

Returns

get_stock_quote

Real-time snapshot: price, change %, high/low, volume, amount, turnover, PE, PB, market cap, limit-up/down

get_stock_quotes

Snapshots for up to 50 tickers in one call

get_stock_kline

Daily / weekly / monthly OHLCV bars, forward- or backward-adjusted, 1–320 bars

search_stock

Look up tickers by code, Chinese name or pinyin initials (平安, 600519, payh)

get_market_indices

SSE Composite, SZSE Component, ChiNext, STAR 50, CSI 300

check_data_source

Upstream reachability / latency check

Data comes from Tencent Finance's public quote endpoints, delayed by seconds. There is no fabricated data: if an upstream call fails, the tool returns an error instead of inventing numbers.

Related MCP server: Chinese Stock MCP

Install

Requirements: Python 3.10+ and uv.

# run straight from GitHub, no checkout needed
uvx --from git+https://github.com/niuheilong/stock-mcp-server qinglong-mcp

Or install locally:

git clone https://github.com/niuheilong/stock-mcp-server.git
cd stock-mcp-server
uv sync          # or: pip install -e .
qinglong-mcp

Connect your agent

Claude Code

claude mcp add qinglong -- uvx --from git+https://github.com/niuheilong/stock-mcp-server qinglong-mcp

Cursor / Windsurf / Cline / VS Code (.mcp.json or MCP settings)

{
  "mcpServers": {
    "qinglong": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/niuheilong/stock-mcp-server", "qinglong-mcp"]
    }
  }
}

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "qinglong": {
      "command": "uvx",
      "args": ["--from", "git+https://github.com/niuheilong/stock-mcp-server", "qinglong-mcp"]
    }
  }
}

HTTP mode (shared server)

docker build -t qinglong-mcp .
docker run -p 8000:8000 qinglong-mcp
# endpoint: http://localhost:8000/mcp

Example

User: How is Kweichow Moutai doing today?

get_stock_quote("600519")
→ price 1,680.00 CNY, +2.35% (+38.50), high 1,692.00, low 1,641.10
  volume 125,000 lots, amount 2.10B CNY, turnover 0.42%
  PE(TTM) 28.5, PB 8.1, market cap 21,100亿 CNY

User: Show me the last 5 trading days for 华胜天成.

get_stock_kline("600410", period="day", count=5)
→ 2026-11-13  open 13.40  close 14.30  high 14.30  low 12.88  volume 1,789,255 lots
  ...

Ticker formats

All of these are accepted: 600410, sh600410, 600410.SH. Shanghai starts with 6, Shenzhen with 0/2/3, Beijing with 4/8.

Data source & limitations

  • Source: qt.gtimg.cn and web.ifzq.gtimg.cn (Tencent Finance), public endpoints.

  • Quotes are real-time-ish but not exchange-grade; treat them as research data.

  • Beijing Stock Exchange coverage depends on the upstream endpoint.

  • Not affiliated with Tencent. For research and educational use only.

  • This is not investment advice.

Development

uv sync
uv run python -c "from qinglong import api; print(api.get_quote('600519'))"
uv run python -m qinglong.server          # stdio
uv run python -m qinglong.server --transport http --port 8000

License

MIT — see LICENSE.


中文说明

青龙:给 AI 助手提供实时 A 股数据的 MCP 服务器。

  • 实时行情、多股批量快照、日/周/月 K 线(前复权/后复权)、股票搜索、大盘指数

  • 只使用真实上游数据,不做任何模拟或推算:取不到数据就报错,不编造

  • 数据源为腾讯财经公开接口,有秒级延迟,仅供研究,不构成投资建议

claude mcp add qinglong -- uvx --from git+https://github.com/niuheilong/stock-mcp-server qinglong-mcp

如果这个项目对你有帮助,欢迎点个 Star ⭐

Available Tools

7 tools
get_market_indexA

获取 A 股大盘指数实时行情(上证指数、深证成指、创业板指、沪深300 等)。

Args: codes: 可选,逗号分隔的指数代码,如 "sh000001,sz399001"。 留空则返回上证指数 / 深证成指 / 创业板指 / 沪深300。

Inputs: codes. Returns: result

get_stock_fundamentalsB

获取单只 A 股的估值与基本面指标。

返回:市盈率(TTM)、市净率、总市值、流通市值、换手率、振幅、涨跌停价等。

Args: symbol: 股票代码,如 "600519"。

Inputs: symbol (required). Returns: result

get_stock_historyA

获取单只 A 股的历史 K 线数据(前复权)。

Args: symbol: 股票代码,如 "600519"。 period: 周期,"daily"(日K,默认)| "weekly"(周K)| "monthly"(月K)。 count: 返回的 K 线根数,默认 30,最大 320。

Inputs: symbol (required), count, period. Returns: result

get_stock_quoteA

获取单只 A 股股票的实时行情。

默认自动选源(新浪优先,失败后回退腾讯);也可用 source 强制指定数据源。

Args: symbol: 股票代码,如 "600519"(贵州茅台)、"000001"(平安银行)。 source: 数据源,"auto"(默认,自动回退)| "sina" | "tencent"。

Inputs: symbol (required), source. Returns: result

get_stock_quotesA

批量获取多只 A 股股票的实时行情(最多 10 只)。

Args: symbols: 逗号分隔的股票代码,如 "600519,000001,000858"。中英文逗号均可。

Inputs: symbols (required). Returns: result

get_usage_statsA

获取本 MCP 服务器的工具调用统计(本地记录)。

返回最近 N 天的调用总数、错误数、各工具调用次数、按天分布。 统计只覆盖有写入日志文件的实例;日志路径可用环境变量 STOCK_MCP_USAGE_LOG 指定。

Args: days: 统计最近多少天,默认 7,最大 365。

Inputs: days. Returns: result

search_stockA

按关键字搜索 A 股股票(支持名称、代码、拼音首字母模糊匹配)。

Args: keyword: 搜索词,如 "茅台"、"600519"、"PAYH"(平安银行拼音首字母)。

Inputs: keyword (required). Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each stock-related tool targets a distinct purpose (index, fundamentals, history, single quote, batch quote, search), with singular/plural clearly distinguishing get_stock_quote from get_stock_quotes. The only unrelated tool, get_usage_stats, is clearly named and separate from the stock domain.

    Naming Consistency5/5

    All tools use a consistent snake_case verb_noun pattern (get_* and search_*). No mixed conventions or ambiguous verb styles are present.

    Tool Count5/5

    Seven tools is well within the ideal range for a focused A-share data server. Each tool earns its place, covering real-time quotes, history, fundamentals, index, and search without redundancy.

    Completeness4/5

    The surface covers core market data: real-time quotes, historical K-lines, fundamentals, index quotes, and stock search. Minor gaps exist for advanced data like minute-level bars, financial statements, or news, but the core domain is well served.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time A-share (Chinese stock market) data through AKShare integration, enabling access to market overviews, company information, real-time quotes, and historical price data for Shanghai and Shenzhen stock exchanges.
      1
      Apache 2.0
    • F
      license
      Not graded
      quality
      D
      maintenance
      Provides real-time quotes, fund flows, and corporate announcements for Chinese A-share stocks. It enables users to search for stocks, analyze financial indicators, and summarize quarterly reports through natural language.
      -
    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables users to query Chinese A-share stock data, including stock basics, historical prices, financial reports, and macroeconomic indicators.
      1
      MIT
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI assistants to query real-time A-share stock data, including quotes, fund flows, sector flows, and K-line history, without needing an API key.
      5
      19
      MIT