Skip to main content
Glama
MyQuant MCP Server

MyQuant MCP Server

MyQuant MCP Server

基于掘金量化(MyQuant)GM API 的 MCP 服务,提供行情、基本面、账户查询和可选交易能力。

两种使用方式

  1. 直接把这个服务的 HTTP MCP endpoint 接到客户端。

  2. 使用仓库内置 skill,通过 skills/myquant-mcp/scripts/client.py 访问 HTTP 工具接口。

Related MCP server: Stock MCP

系统要求

1. Windows

推荐优先使用 Windows。

原因:

  • 掘金终端只能运行在 Windows 上。

  • 如果你希望本机直接运行掘金终端和本项目,Windows 是最简单的部署方式。

适用场景:

  • 掘金终端和本项目部署在同一台 Windows 机器上

  • 或者本项目部署在任意机器上,但远程连接另一台 Windows 掘金终端

2. Ubuntu

Ubuntu 只建议用于部署本项目服务端,不用于运行掘金终端本体。

要求:

  • 必须是 x86_64 / amd64

  • 不建议使用 arm64

原因:

  • arm64 环境下没有可用的 gm Python 包

  • 掘金终端本身仍然需要运行在 Windows 机器上

部署方式:

  • 可直接在 Ubuntu 上用 Python 运行

  • 也可以用 Docker / Docker Compose 部署

但无论哪种方式,都必须确保:

  • 有一台 Windows PC 正在运行掘金终端

  • Ubuntu 机器能够访问这台 Windows PC

  • 在 .env 中把 GM_SERV_ADDR 设置成这台 Windows 机器的地址,例如:

GM_SERV_ADDR=192.168.1.10:7001

先启动服务

git clone https://github.com/Wangshengyang2004/myquant-mcp.git
cd myquant-mcp
python -m venv .venv
. .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
python server.py

Windows PowerShell:

python -m venv .venv
.venv\Scripts\Activate.ps1
pip install -r requirements.txt
Copy-Item .env.example .env
python server.py

至少配置:

GM_TOKEN=your_gm_token_here
MCP_AUTH_TOKEN=replace_with_a_long_random_value
TRADING_ENABLED=false

如果服务端不运行在掘金终端所在的 Windows 机器上,还需要设置:

GM_SERV_ADDR=<运行掘金终端的 Windows 机器 IP>:7001

默认 endpoint:

  • Web UI: http://127.0.0.1:8001/

  • MCP: http://127.0.0.1:8001/mcp/

  • REST: http://127.0.0.1:8001/api/v1/tools

直接接入 MCP

1. Cursor

Cursor 官方文档支持项目级 .cursor/mcp.json,远程 MCP 服务器用 url 配置即可。

本仓库已经提供好:

{
  "mcpServers": {
    "myquant-mcp": {
      "url": "http://127.0.0.1:8001/mcp/"
    }
  }
}

如果服务不在本机,把 URL 改成你的实际地址,例如 http://192.168.1.10:8001/mcp/。

2. Claude Code

Claude Code 官方文档支持项目级 .mcp.json,HTTP MCP 服务器使用 type: "http" 加 url。

本仓库已经提供好:

{
  "mcpServers": {
    "myquant-mcp": {
      "type": "http",
      "url": "http://127.0.0.1:8001/mcp/"
    }
  }
}

也可以手动添加:

claude mcp add --transport http myquant-mcp http://127.0.0.1:8001/mcp/

如果你的服务跑在别的机器上,把 URL 替换成对应地址。

3. OpenClaw

OpenClaw 官方文档支持把兼容 Claude/Cursor 的 bundle 安装成 plugin bundle,并导入 bundle 里的 MCP 配置。这个仓库里已经带了 .mcp.json 和 skills/。

安装方式:

openclaw plugins install ./myquant-mcp
openclaw plugins info myquant-mcp
openclaw gateway restart

OpenClaw 读取到的 MCP 配置同样应该指向 HTTP endpoint,而不是 server.py。也就是说,仓库里的 .mcp.json 应该保持为:

{
  "mcpServers": {
    "myquant-mcp": {
      "type": "http",
      "url": "http://127.0.0.1:8001/mcp/"
    }
  }
}

如果服务部署在远端,把 URL 改成远端地址。

Skill 方式

仓库内置 skill 位于:

这个 skill 走的是 HTTP REST 接口,可以访问与 MCP 一致的工具集合。

这样设计是出于安全考虑:

  • 交易 API 暴露给通用 skill 或通用 HTTP 客户端会更脆弱,风险更高

  • 因此 skill 不会隐式读取仓库里的 .env 或自动带出 token

  • 受保护的账户、交易和 stock_do_t 工具必须显式通过命令行传入 --auth-token

  • 这个 --auth-token 应与服务端的 MCP_AUTH_TOKEN 保持一致

示例:

python skills/myquant-mcp/scripts/client.py --list-tools
python skills/myquant-mcp/scripts/client.py --info history
python skills/myquant-mcp/scripts/client.py history --symbol SHSE.600000 --frequency 1d --start-time 2024-01-01 --end-time 2024-12-31
python skills/myquant-mcp/scripts/client.py --auth-token YOUR_TOKEN get_positions
python skills/myquant-mcp/scripts/client.py --auth-token YOUR_TOKEN order_volume --symbol SZSE.000001 --volume 100 --side 1 --price 10.50

重要说明

  • TRADING_ENABLED=false 应保持默认值,除非你明确需要真实交易。

  • 账户和交易工具需要 MCP_AUTH_TOKEN。

  • skills/myquant-mcp/scripts/client.py 通过 REST API 调用与 MCP 一致的工具集。

  • 当 skill 被安装到别的 agent 工作区时,不要假设它能读到本仓库 .env;请直接在命令行传 --auth-token。

  • stock_do_t 的运行状态会持久化到本地 SQLite 文件 .local/do_t_state.sqlite3,服务重启后仍可查询。

  • stock_do_t 在 14:55 后不再开新仓;如果第一腿已经完成但第二腿还没触发,会进入强制结算流程。

项目结构

myquant-mcp/
├── server.py
├── skills/
│   └── myquant-mcp/
│       ├── SKILL.md
│       ├── agents/
│       ├── references/
│       └── scripts/
├── server/
│   ├── api/
│   ├── tools/
│   ├── app.py
│   ├── mcp_server.py
│   └── webui.html
├── tests/
├── .mcp.json
├── .cursor/
│   └── mcp.json
├── .env.example
├── Dockerfile
└── docker-compose.yml

贡献

贡献说明见 CONTRIBUTING.md。

安全策略

安全说明和漏洞披露建议见 SECURITY.md。

License

MIT,见 LICENSE。

Tool Schema Changelog

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

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Wraps the miniQMT interface to enable AI assistants to query A-share market data, account information, and place/cancel orders.
      1
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents and backends to query A-share, US equity, ETF, index, and crypto market data, run technical indicators, fundamentals, money flow, news, and filings analysis over MCP or HTTP, and export results as CSV/JSON for code-execution workflows.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents and backends to query A-share, US equity, ETF, index, and crypto market data with technical indicators, fundamentals, money flow, news search, and SEC/A-share filings through MCP tools. Also exposes CSV/JSON code-export endpoints so script-driven agents can pull data without bloating model context.
      -
    • F
      license
      Not graded
      quality
      A
      maintenance
      Enables AI agents and backends to query multi-market financial data — A-share, US equity, ETF, index, and crypto quotes, K-lines, technical indicators, fundamentals, money flow, news, and SEC/A-share filings — through MCP tools and a matching HTTP API. Includes agent-friendly artifact offloading and CSV/JSON code-export endpoints, with configurable none/token/JWT authentication and multi-provider failover.
      -