Skip to main content
Glama
adambbhe

TDX Local MCP

by adambbhe

TDX Local MCP — 通达信本地终端 MCP 服务

直连运行中的通达信客户端(tqcenter / TPythClient.dll),将 36 个 tqcenter 公开 API 全量封装为 49 个 MCP 工具,并提供本地扩展:自动价格预警引擎与模拟交易通道。

功能概览

分组

数量

工具

连接状态

1

tdx_status

行情与报价

4

tdx_kline / tdx_snapshot / tdx_divid_factors / tdx_money_flow

基础信息

6

tdx_stock_info / tdx_stock_list / tdx_trading_calendar / tdx_trading_dates / tdx_cb_info / tdx_ipo_info

财务与专业数据

9

tdx_financial_data(_by_date) / tdx_gpjy_value(_by_date) / tdx_bkjy_value(_by_date) / tdx_scjy_value(_by_date) / tdx_gp_one_data

板块与自选股

8

tdx_sector_list / tdx_user_sector / tdx_sector_stocks / tdx_create_sector / tdx_delete_sector / tdx_rename_sector / tdx_clear_sector / tdx_send_user_block

数据维护与订阅

6

tdx_download_file / tdx_refresh_cache / tdx_refresh_kline / tdx_hq_subscribed_list / tdx_subscribe_hq / tdx_unsubscribe_hq

终端推送

4

tdx_send_warn / tdx_send_message / tdx_send_file / tdx_send_bt_data

模拟交易

6

tdx_trade_account / tdx_query_asset / tdx_query_positions / tdx_query_orders / tdx_order_stock / tdx_cancel_order

自动价格预警

5

tdx_alert_add / tdx_alert_list / tdx_alert_remove / tdx_alert_history / tdx_alert_check_now

完整接口签名与返回结构见 INTERFACE.md

Related MCP server: akshare-mcp

前置条件

  1. 已安装支持 TQ 策略的通达信终端(金融终端/专业研究版/量化模拟版/期货通),安装目录如 D:\new_tdx_mock

  2. Windows Python(3.10+,建议 3.14)已安装依赖:

    python -m pip install mcp pandas numpy
  3. 终端已启动并登录(行情登录即可;交易工具需另登录交易)

快速开始(任意 MCP 客户端)

在 MCP 客户端配置中添加(路径按你的安装位置调整):

{
  "mcpServers": {
    "tdx-local": {
      "command": "C:\\Python314\\python.exe",
      "args": ["D:\\path\\to\\tdx-local-mcp\\run_server.py"],
      "env": {
        "TDX_ROOT": "D:\\new_tdx_mock",
        "TDX_MCP_POLL_INTERVAL": "30"
      }
    }
  }
}

WSL 部署(openclaw)

WSL2 的 Linux Python 无法加载 Windows DLL(invalid ELF header),必须经 WSL interop 用 Windows Python 拉起:

{
  "mcpServers": {
    "tdx-local": {
      "command": "/mnt/c/Python314/python.exe",
      "args": ["D:/path/to/tdx-local-mcp/run_server.py"],
      "env": {
        "TDX_ROOT": "D:/new_tdx_mock",
        "TDX_MCP_POLL_INTERVAL": "30"
      }
    }
  }
}

openclaw 插件部署(源码在 D 盘会被 777 world-writable 安全策略拦截,须复制到 WSL 原生目录):

bash deploy_openclaw.sh          # 复制 4 个插件文件到 ~/.openclaw/extensions/tdx-local-mcp/
openclaw gateway restart         # 重启网关加载

环境变量

变量

默认值

说明

TDX_ROOT

D:\new_tdx_mock

通达信安装目录(tqcenter.py 与 TPythClient.dll 所在)

TDX_INIT_PATH

tdx_local_mcp_{PID}

策略连接标识(多实例并存)

TDX_MCP_POLL_INTERVAL

30

预警引擎轮询间隔(秒,最小 5)

TDX_MCP_ALERT_RULES

项目根\alerts_rules.json

预警规则持久化路径

TDX_MCP_ALERT_LOG

项目根\alerts_log.jsonl

预警触发历史路径

TDX_ROOT 必须指向终端实际运行目录——DLL 与终端经本机进程通信,路径不一致会连接失败。

数据规范

  • 证券代码:6位数字.市场后缀(600519.SH / 000001.SZ / 832566.BJ)

  • 价格单位元;成交量:快照=手、K线 Volume 列=股;成交额=万元

  • 时间:YYYYMMDD 或 YYYYMMDDHHMMSS

  • 复权:none / front / back(默认 front)

  • 周期:1m/5m/10m/15m/30m/1h/1d/1w/1mon/45d/1q/1y;K线单次上限 24000 条

测试

python smoke_test.py          # 冒烟:连接/K线/快照/板块/预警闭环/终端推送(14 项)
python mcp_client_test.py     # MCP 协议端到端(8 项)
python consistency_check.py   # 数据一致性(K线 vs .day 文件交叉比对)
python trade_test.py          # 模拟交易全链路(须交易日交易时段)
wsl python3 wsl_e2e_test.py   # WSL→Windows 跨系统 MCP 链路(在 WSL 中运行)

官方 API 对齐

三层真源:官方文档(help.tdx.com.cn/quant/docs,语义基准)→ 本地 tqcenter.py(运行真源,参数透传以此为准)→ 49 个 MCP 工具(消费契约)。两源不一致处在工具 docstring 中以 ⚠️ 标注(本地版实测差异:快照最高最低键名为 Max/Min、get_trading_dates 需 market 参数、subscribe_hq 强制回调等)。

免责声明

本项目仅供学习研究。交易工具仅在通达信模拟交易环境验证;接入实盘风险自负,作者不承担任何资金损失责任。

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

No tool schema history has been recorded yet.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    B
    maintenance
    Provides AI clients access to TdxQuant/通达信 financial data and trading capabilities through MCP. Enables retrieval of market data, financial reports, sector information, and trading operations via stdio or HTTP/SSE connections.
    29
    -
  • A
    license
    B
    quality
    C
    maintenance
    MCP server that wraps AKShare's 1000+ financial data functions, enabling LLMs to query Chinese stock, macro, futures, fund, bond, option, forex, and alternative data through standardized tools.
    14
    3
    Apache 2.0
  • A
    license
    A
    quality
    A
    maintenance
    Enables AI agents to operate a local financial terminal, including market data, backtesting, paper portfolio management, and news digest, through safe, gated tools over MCP.
    6
    MIT
  • A
    license
    Not graded
    quality
    A
    maintenance
    Provides read-only access to Chinese A-share stock market data such as quotes, K-lines, financials, capital flows, news, and research reports via a stdio MCP server for DeepSeek Harness and other MCP clients.
    GPL 3.0

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/adambbhe/TDX-local-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server