Skip to main content
Glama
gtc-fx-mcp

gtc-fx-mcp

by DevDengChao
README.md
# gtc-fx-mcp

GTC Go 的 MCP 服务。通过本地 stdio 查询账户和交易数据,也可以准备资金及交易表单,由用户在 GTC 网页确认。项目由社区维护。

## 运行

需要 Node.js 22 或更新版本。发布前可从源码构建,或使用已打包的 tarball。

```sh
npm ci
npm run build
node dist/cli.js --version
```

通用 MCP 客户端配置示例。将路径替换为实际的构建文件路径。

```json
{
  "mcpServers": {
    "gtc-go": {
      "command": "node",
      "args": ["/absolute/path/to/gtc-fx-mcp/dist/cli.js"],
      "env": { "GTC_AUTH_MODE": "browser" }
    }
  }
}
```

安装发行包后,命令可以直接使用 `gtc-fx-mcp`。npm 正式发布后,也可将 `command` 设置为 `npx` 并把 `args` 设置为 `["-y", "@devdengchao/gtc-fx-mcp@0.1.0"]`。

## 授权模式

| 模式 | 配置 | 能力 |
| --- | --- | --- |
| `session` | 在 MCP 进程环境中注入 `GTC_GO_ACCESS_TOKEN` | `gtc_list_accounts` 和 `gtc_get_wallet`。Windows 与 ECS 已实测,可独立于 Chrome 发请求。 |
| `browser` | Chrome 144+。在 Chrome 打开 `chrome://inspect/#remote-debugging` 并开启调试,连接时选择 Allow,在 GTC 页面登录。 | 全部已实现查询以及浏览器预填、提交状态与回执。 |

`GTC_AUTH_MODE` 可显式选择模式。默认在提供访问令牌时启用 `session`,否则启用 `browser`。

### 获取并提供 session 令牌

1. 在 [GTC Go 仪表盘](https://web.mygtc.app/dashboard) 登录自己的账户。
2. 打开 Chrome 开发者工具,在 **Network(网络)** 中选择 **Fetch/XHR**,然后刷新仪表盘。
3. 在请求列表中选择 `POST /api/exchange/opt_my_account` 或 `POST /api/report/my_wallet_report`。打开 **Headers(标头)** 下的 **Request Headers(请求标头)**,复制 `Authorization` 值中 `Bearer ` 后面的令牌。
4. 将上面的 MCP 配置示例中的 `GTC_AUTH_MODE` 改为 `session`,并让 MCP 子进程收到环境变量 `GTC_GO_ACCESS_TOKEN`。如果客户端提供受保护的密钥注入功能,可以在那里设置实际令牌。

如需从终端启动客户端,可用以下命令隐藏令牌输入。设置后从同一终端启动客户端。如果客户端限制 stdio 子进程继承的环境变量,在客户端配置中显式转发 `GTC_GO_ACCESS_TOKEN`。

**Bash**

```bash
read -rsp 'GTC Go access token ' GTC_GO_ACCESS_TOKEN
printf '\n'
export GTC_GO_ACCESS_TOKEN
export GTC_AUTH_MODE=session
```

**PowerShell**

```powershell
$gtcTokenInput = Read-Host 'GTC Go access token' -AsSecureString
$env:GTC_GO_ACCESS_TOKEN = [System.Net.NetworkCredential]::new('', $gtcTokenInput).Password
Remove-Variable gtcTokenInput
$env:GTC_AUTH_MODE = 'session'
```

收到 `AUTH_REQUIRED` 时,在 GTC Go 重新登录并复制新令牌,更新环境变量后重启 MCP 服务。

### 浏览器模式

浏览器模式使用当前 Chrome 配置。`GTC_CHROME_USER_DATA_DIR` 可指定 Chrome 数据目录。`GTC_CHROME_CDP_URL` 可配置通过本机回环访问的调试 WebSocket,适用于自管的私有隧道。`GTC_APP_LANG` 默认为 GTC Go 的 `zhCn`,浏览器模式优先使用实际会话中的语言。

## 工具

- 账户和资料使用 `gtc_list_accounts`、`gtc_list_external_accounts`、`gtc_get_profile`、`gtc_get_kyc_status`。
- 钱包、资金和报表使用 `gtc_get_wallet`、`gtc_list_fund_movements`、`gtc_get_funds_summary`、`gtc_get_trade_funds_report`、`gtc_get_trade_statistics`。
- 行情和交易查询使用 `gtc_get_symbol`、`gtc_get_candles`、`gtc_list_positions`、`gtc_list_closed_trades`。
- 其他查询覆盖入出金渠道、工单、通知、活动、课程、跟单和 PAMM 信号。

### 资金与交易确认

`gtc_prepare_funding` 支持入金、出金和站内转账。`gtc_prepare_trade` 支持市价单、挂单、改单、撤单和平仓。输入在 `action` 对象内,金额、价格和手数以十进制字符串传入。入金金额与原站表单一致,单位为 USD,`currency` 指支付渠道币种。

下面的合成参数演示站内转账表单准备。

```json
{ "action": { "operation": "internal_transfer", "fromAccount": "1000001", "toAccount": "1000002", "currency": "USD", "amount": "14.25" } }
```

工具在独立 GTC 标签页预填能识别的字段。`filled` 和 `needsInput` 显示结果。可在原站选择支付渠道或打开订单编辑框,再用 `gtc_fill_pending_action` 继续预填。实际金额、账户、支付方式、密码和验证码在 GTC 页核对与处理,最终提交由用户操作。

用 `gtc_action_status` 按 `actionId` 查看匹配的回执。`accepted` 表示 GTC 接口已受理。对于外部支付渠道、参数变动、连接中断或无法关联的回执,使用 GTC 资金流水或订单核对。在网页取消操作或对账后,可用 `gtc_release_action` 释放当前准备。每个 MCP 进程保留一笔待处理操作。

## 验证与发行

```sh
npm test
npm pack --dry-run
npm pack
```

CI 在 Node.js 22 和 24 执行测试,并从 tarball 安装后验证两种模式的 MCP stdio 初始化和工具调用。资金写入使用本地模拟回执验收,真实资金通道和券商模拟账户交易验收单独记录。

建立目标 GitHub 仓库后推送 `main`,核对 CI、确认包名及发布权限,再将已验证的 tarball 发布到 npm。

- [GTC Go 请求目录](docs/requests.md)

TDQS

C2.9/5.0

Scored across 26 tools

Disambiguation4/5

Most tools target a clearly distinct resource (deposit channels vs withdrawal channels, positions vs closed trades, courses vs copy signals vs PAMM signals). The only fuzzy cluster is the reporting group — gtc_list_fund_movements, gtc_get_funds_summary, gtc_get_trade_funds_report, and gtc_get_trade_statistics overlap conceptually, though the descriptions do differentiate them by granularity and source. The prepare/fill/status/release quartet forms a coherent lifecycle rather than a redundant set.

Naming Consistency4/5

Nearly all tools follow a consistent gtc_verb_noun snake_case pattern with a uniform prefix, which is predictable and easy to scan. The one deviation is gtc_action_status, which drops the verb and reads as a noun phrase in an otherwise verb-first namespace, and gtc_fill_pending_action is slightly more verbose than its siblings.

Tool Count3/5

At 26 tools the surface is on the heavy side for what is essentially a read-oriented trading dashboard plus a four-step order-preparation workflow. The breadth is real (accounts, funding, trading, reports, signals, support), but several list-only tools for peripheral domains (courses, notifications, activities) pad the count beyond what earns its place.

Completeness4/5

Coverage of the trading domain is broad: accounts, wallet, symbol/candles, positions, closed trades, fund movements, reports, KYC, and a full prepare→fill→status→release order workflow. Gaps remain around mutating operations — no cancel order, no close position, no notification read-state update, and no detail-level fetch for a single trade or order — but these appear intentionally delegated to the Chrome-confirm step and are workable.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues