> ## Documentation Index
> Fetch the complete documentation index at: https://docs.llmquantdata.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> AI-native 金融数据的 knowledge harness —— 一次配置，所有 agent 自动接入。

<Note icon="sparkles">
  **`@llmquant/data-mcp`** —— 一份配置，让所有 MCP 客户端获得 26 个金融数据与个人 context 工具。源码：[`LLMQuant/data-mcp`](https://github.com/LLMQuant/data-mcp)。
</Note>

<Badge color="green" icon="circle-check">已上线</Badge>
 
<Badge color="blue" size="sm">npm · @llmquant/data-mcp</Badge>

## 为什么是 MCP

LLMQuant Data 是 **agent-first** 设计。REST API 是 fallback；规范接口是 [Model Context Protocol](https://modelcontextprotocol.io) —— 这套标准让所有 agent runtime（Claude / Cursor / Codex / Gemini CLI / OpenClaw / ChatGPT custom GPT…）以**结构化参数 + 类型化结果**的方式直接调用我们的数据工具，**不需要任何 glue code**。

<Tip>
  **配置一次，下面所有环境自动接入。**
</Tip>

## 在哪里能用

<Columns cols={3}>
  <Card title="Chatbot" icon="message">
    ChatGPT · Claude · Cursor
  </Card>

  <Card title="Agent CLI" icon="terminal">
    Claude Code · Codex · Gemini CLI · OpenClaw
  </Card>

  <Card title="SDK" icon="code">
    LangGraph · Google ADK · Vercel AI SDK
  </Card>
</Columns>

只要你的 runtime 支持 MCP，LLMQuant Data 就只差一份配置。

## Remote connectors

Claude web、Claude iOS 和其他云端 agent 不能运行本地 `npx` stdio server。改用 hosted Streamable HTTP endpoint：

<Steps>
  <Step title="生成 Remote MCP URL" icon="link">
    登录 [Dashboard](https://llmquantdata.com/dashboard) → **Connect** → **Remote MCP URL**。创建时复制一次 URL。

    ```text theme={null}
    https://mcp.llmquantdata.com/u/lqd_mcp_.../mcp
    ```
  </Step>

  <Step title="粘到 Claude custom connectors" icon="plug">
    选择 Claude 的 **No Authentication** connector mode，粘贴完整 URL。token 放在 URL path 里，LLMQuant Data 只存 hash，可在 Dashboard 独立吊销，不需要轮换 API key。
  </Step>

  <Step title="验证 credit 和 revoke" icon="circle-check">
    跑一次付费 search 或 read tool，确认 Dashboard 余额变化；再 revoke 一条测试 URL，确认它立即失败。
  </Step>
</Steps>

<Note>
  本地桌面端和 CLI 客户端可以继续用下面的 stdio 配置。Remote URL 面向需要公网 HTTPS MCP endpoint 的云端客户端和通过 Claude 同步的 connector。
</Note>

## 快速接入

<Steps>
  <Step title="获取 API key" icon="key">
    登录 [Dashboard](https://llmquantdata.com/dashboard) → **API Keys** → **Create API key**。保存为环境变量 `LLMQUANT_API_KEY`。
  </Step>

  <Step title="把 data-mcp 加进客户端" icon="plug">
    **把下面这段 prompt 丢进 agent —— 它会从 GitHub 读 canonical 配置：**

    ```text theme={null}
    Install the LLMQuant data-mcp server in this environment by following https://github.com/LLMQuant/data-mcp
    ```

    <Accordion title="或者手动安装" icon="terminal">
      选你的 runtime，下面是 canonical 配置 —— 直接复制粘贴，保存，重启客户端。

      <Tabs>
        <Tab title="Claude Code">
          ```bash theme={null}
          claude mcp add llmquant-data \
            -e LLMQUANT_API_KEY=$LLMQUANT_API_KEY \
            -- npx -y @llmquant/data-mcp
          ```
        </Tab>

        <Tab title="Cursor">
          添加到 `.cursor/mcp.json`（项目级）或 `~/.cursor/mcp.json`（全局）：
          JSON 配置文件通常不会展开 shell 变量，请直接填真实 API key。

          ```json title=".cursor/mcp.json" theme={null}
          {
            "mcpServers": {
              "llmquant-data": {
                "command": "npx",
                "args": ["-y", "@llmquant/data-mcp"],
                "env": {
                  "LLMQUANT_API_KEY": "your_api_key_here"
                }
              }
            }
          }
          ```
        </Tab>

        <Tab title="Codex CLI">
          ```bash theme={null}
          codex mcp add llmquant-data \
            --env LLMQUANT_API_KEY=$LLMQUANT_API_KEY \
            -- npx -y @llmquant/data-mcp
          ```
        </Tab>

        <Tab title="Gemini CLI">
          ```bash theme={null}
          gemini mcp add -s user \
            -e LLMQUANT_API_KEY=$LLMQUANT_API_KEY \
            llmquant-data \
            npx -y @llmquant/data-mcp
          ```
        </Tab>

        <Tab title="Claude Desktop">
          编辑 `claude_desktop_config.json`（macOS：`~/Library/Application Support/Claude/`）：
          JSON 配置文件通常不会展开 shell 变量，请直接填真实 API key。

          ```json title="claude_desktop_config.json" theme={null}
          {
            "mcpServers": {
              "llmquant-data": {
                "command": "npx",
                "args": ["-y", "@llmquant/data-mcp"],
                "env": {
                  "LLMQUANT_API_KEY": "your_api_key_here"
                }
              }
            }
          }
          ```
        </Tab>

        <Tab title="其他 (stdio)">
          任何支持 stdio transport 的 MCP 客户端都接受这份通用配置：
          JSON 配置文件通常不会展开 shell 变量，请直接填真实 API key。

          ```json theme={null}
          {
            "mcpServers": {
              "llmquant-data": {
                "command": "npx",
                "args": ["-y", "@llmquant/data-mcp"],
                "env": {
                  "LLMQUANT_API_KEY": "your_api_key_here"
                }
              }
            }
          }
          ```

          没看到你的客户端？[提个 issue](https://github.com/LLMQuant/data-mcp/issues) 我们补。
        </Tab>
      </Tabs>
    </Accordion>
  </Step>

  <Step title="问 agent 一个它现在该会的问题" icon="sparkles">
    重启客户端。把下面任意一句丢进 chat / agent session —— agent 会自动发现新工具、选对工具、返回结构化结果。

    <Prompt description="Wiki 两步检索">
      在 Quant Wiki 搜一下"动量因子"，把 top hit 完整读出来。
    </Prompt>

    <Prompt description="实时加密行情">
      BTC 现在多少？24 小时涨跌多少？
    </Prompt>

    <Prompt description="研究发现">
      找最近关于 transformer-based factor model 的论文。
    </Prompt>
  </Step>
</Steps>

## 可用工具

每个 tool 是 agent 可调用的一个 MCP 能力。按调用次数计费（credit）。

| Tool                            | 它做什么                                                                      | Credits |
| ------------------------------- | ------------------------------------------------------------------------- | :-----: |
| `wiki_search`                   | 在 50,000+ 篇 Quant Wiki 上做语义检索                                             |    1    |
| `wiki_read`                     | 按 ID 加载完整 markdown 正文                                                     |    0    |
| `paper_search`                  | 在 1,200+ 篇研究论文摘要上做语义检索                                                    |    1    |
| `paper_read`                    | 按章节读取论文（intro / methods / conclusion…）                                    |    0    |
| `crypto_historical_klines`      | 加密货币 OHLCV 蜡烛，可配置周期                                                       |    1    |
| `crypto_snapshot`               | 加密货币交易对当前价 + 24h 行情                                                       |    0    |
| `polymarket_event_browse`       | 列举或精确筛选金融范围内的预测市场事件                                                       |    1    |
| `polymarket_event_search`       | 语义搜索金融范围内的预测市场事件                                                          |    2    |
| `polymarket_event_read`         | 读取一个预测市场事件卡片和它下面的 market 预览                                               |    0    |
| `polymarket_market_read`        | 读取一个预测市场 market 卡片、outcomes 和 outcome token ids                           |    0    |
| `polymarket_price_history`      | 查询一个 outcome token 的小时或日度隐含概率历史                                           |    0    |
| `equity_historical_prices`      | 美股日线 OHLCV + 分红 / 拆股复权。ETF 价格历史也走这里。                                      |    0    |
| `equity_intraday_prices`        | 美股 `1h` 常规交易时段 OHLCV bar（最近 N 根或短日期范围）                                    |    1    |
| `etf_lookup`                    | ETF 基本信息 + top holdings 摘要 + 行业 / 国家 / 资产类型分布                             |    0    |
| `etf_holdings`                  | 单只 ETF 完整持仓（来自 SEC 官方监管披露的最近一份快照，按权重降序）。覆盖不到的 ticker 仍返回 `200`，不扣 credit。 |    1    |
| `macro_indicator_search`        | 浏览 50+ 精选宏观指标                                                             |    0    |
| `macro_indicator_history`       | 宏观指标历史观测序列                                                                |    1    |
| `macro_indicator_snapshot`      | 宏观指标最新一期数值                                                                |    0    |
| `sec_filing_browse`             | 浏览 SEC 10-K / 10-Q / 8-K 申报文件元信息                                          |    0    |
| `sec_filing_read`               | 读取 SEC 申报文件指定章节                                                           |    1    |
| `sec_13f_list_manager_holdings` | 某机构 13F 持仓（Top 1,000 × 至少最近 4 季度）                                         |    1    |
| `sec_13f_list_ticker_holders`   | 某 ticker 的机构持有人（Top 1,000 × 至少最近 4 季度）                                    |    1    |
| `sec_13f_list_top_managers`     | 按 13F 申报市值排名的 top N smart money                                           |    0    |
| `news_browse`                   | 按 ticker、事件、主题或日期浏览近期公司新闻                                                 |    2    |
| `personal_holdings`             | 读取你在 Dashboard → Profile 保存的持仓（仅限你自己的账号）                                  |    0    |
| `personal_profile`              | 读取你在 Dashboard → Profile 保存的财务背景（仅限你自己的账号）                                |    0    |

<Tip>
  更多数据产品（包括基本面和财报会议纪要）见 [roadmap](https://github.com/LLMQuant/data-mcp#roadmap)。
</Tip>

## 环境变量

<ParamField path="LLMQUANT_API_KEY" type="string" required>
  你的 LLMQuant Data API key。在 [Dashboard → API Keys](https://llmquantdata.com/dashboard) 生成。
</ParamField>

<ParamField path="LLMQUANT_BASE_URL" type="string" default="https://api.llmquantdata.com">
  覆盖 API base URL。自托管代理或其他兼容的 LLMQuant Data 部署可使用。
</ParamField>

<ParamField path="LLMQUANT_API_TIMEOUT_MS" type="number" default={15000}>
  请求超时（毫秒）。最大 `120000`。
</ParamField>

## 下一步

<Columns cols={2}>
  <Card title="浏览所有数据工具" icon="book-open" href="/zh-CN/api/knowledge/wiki-search">
    每个 tool 都有对应的 endpoint 页面，含 Agent flow 流程图与字段定义。
  </Card>

  <Card title="GitHub 源码" icon="github" href="https://github.com/LLMQuant/data-mcp">
    读源码、提 issue、看 roadmap。
  </Card>
</Columns>
