npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

linker-position-mcp

v0.1.0

Published

MCP server for Linker Position & PnL queries - portfolio overview, owner detail, risk status

Readme

linker-position-mcp

Linker 持仓 + 盈亏 + VAR 风险查询 MCP Server。

面向 AI Agent / 大模型,提供公司级和个人级的持仓、盈亏、VAR 风险查询能力。所有工具只认人名不认 ID,对大模型友好。

快速开始

环境变量

TRADING_API_BASE=http://hub.linker.net/trading-api
TRADING_API_KEY=trading-prod-20260323

配置方式

npx(发布后):

{
  "mcpServers": {
    "linker-position": {
      "command": "npx",
      "args": ["-y", "linker-position-mcp@latest"],
      "env": {
        "TRADING_API_BASE": "http://hub.linker.net/trading-api",
        "TRADING_API_KEY": "trading-prod-20260323"
      }
    }
  }
}

本地开发(直接用编译产物):

{
  "mcpServers": {
    "linker-position": {
      "command": "node",
      "args": ["C:/Users/94503/Documents/GitHub/linker_mcp/packages/linker-position-mcp/dist/index.js"],
      "env": {
        "TRADING_API_BASE": "http://hub.linker.net/trading-api",
        "TRADING_API_KEY": "trading-prod-20260323"
      }
    }
  }
}

工具列表

| Tool | 说明 | 参数 | |------|------|------| | get_pnl_overview | 公司整体盈亏+持仓+VAR 快照 | 无 | | get_owner_detail | 某人持仓+盈亏+VAR 明细 | owner: string | | get_risk_status | VAR 风险状态 | owner?: string | | list_owners | 列出所有持仓人姓名 | 无 |

覆盖维度

| 维度 | 全局 | 某人 | |------|------|------| | 持仓+盈亏 | get_pnl_overview() — 各人一行汇总排名 | get_owner_detail(owner) — 策略→legs 明细 | | VAR 风险 | get_risk_status() — 全员概览+超限告警 | get_risk_status(owner) — 某人 30 日趋势 | | 辅助 | list_owners() — 确认人名 | — |

场景对照表

| 用户问 | 调哪个工具 | |--------|-----------| | "公司现在整体什么情况" | get_pnl_overview | | "各人盈亏排名" | get_pnl_overview | | "谁在赚谁在亏" | get_pnl_overview | | "任志华持仓什么" | get_owner_detail(owner:"任志华") | | "任志华赚了多少" | get_owner_detail(owner:"任志华") | | "某人各策略盈亏明细" | get_owner_detail(owner:"某人") | | "某人浮盈多少" | get_owner_detail(owner:"某人") | | "谁的 VAR 超限了" | get_risk_status() | | "全员风险概览" | get_risk_status() | | "某人 VAR 趋势" | get_risk_status(owner:"某人") | | "有哪些交易员" | list_owners |

各工具返回结构

get_pnl_overview

{
  "company": {
    "realized_pnl": 89555573.88,
    "floating_pnl": -37185340.99,
    "total_pnl": 52370232.89,
    "var_used": 52398632.93,
    "var_remain": 23451367.07,
    "var_limit": "7585万",
    "var_usage": "69%"
  },
  "owners": [
    {
      "owner": "任志华",
      "active_strategies": 15,
      "total_strategies": 83,
      "total_pnl": 101024976.04,
      "floating_pnl": 13381939.35,
      "var": 12942379.87,
      "var_usage": 0.43,
      "alert": "normal"
    }
  ]
}

get_owner_detail

{
  "owner": "任志华",
  "realized_pnl": 190948992.89,
  "floating_pnl": 13381939.35,
  "total_pnl": 204330932.24,
  "var": {
    "total": 12942379.87,
    "hedge": null,
    "arbitrage": null,
    "outright": 12942379.87
  },
  "var_limit": 30000000,
  "var_usage_rate": 0.43,
  "var_alert": "normal",
  "active_strategies": 15,
  "total_strategies": 83,
  "strategies": [
    {
      "strategy": "AU_单边策略_趋势跟踪_AU2606",
      "category": "单边策略",
      "product": "AU",
      "total_pnl": -6368497,
      "floating_pnl": -4397171,
      "var": 3200000,
      "legs": [
        {
          "contract": "AU2608",
          "direction": "BUY",
          "remaining_qty": 36,
          "avg_price": 996.38,
          "market_price": 874.24,
          "unrealized_pnl": -4397171,
          "realized_pnl": 0
        }
      ]
    }
  ]
}

get_risk_status(全员)

{
  "owners": [
    {
      "owner": "汪浩",
      "department": "交易三部",
      "var_value": 1318.1,
      "var_limit": 150,
      "usage_rate": 8.79,
      "alert_level": "overlimit"
    }
  ],
  "alerts": [
    {
      "owner": "汪浩",
      "var_value": 1318.1,
      "var_limit": 150,
      "usage_rate": 8.79,
      "alert_level": "overlimit"
    }
  ]
}

get_risk_status(某人趋势)

{
  "owner": "黄皓生",
  "days": 30,
  "trend": [
    { "date": "2026-06-20", "var_value": 52.3, "var_limit": 300, "usage_rate": 0.17, "alert_level": "normal" },
    { "date": "2026-07-19", "var_value": 64.29, "var_limit": 300, "usage_rate": 0.21, "alert_level": "normal" }
  ]
}

list_owners

["任志华", "于熙", "何佳驹", "吴培", "周菲", "..."]

技术细节

  • 数据来源:所有数据走服务端聚合接口,不拉明细(无 60 万行查询)
    • /api/v1/pnl/report — 持仓 + 盈亏 + VAR(服务端聚合 owner→strategies→legs)
    • /api/v1/risk/dashboard/overview — VAR 概览
    • /api/v1/risk/dashboard/alerts — 超限告警
    • /api/v1/risk/dashboard/history — VAR 趋势
    • /api/v1/owners — 持仓人列表
  • 认证X-API-Key header
  • 只读:所有工具 readOnly,不做任何写操作
  • owner 解析:内部缓存 ownerMap(name↔id),用户只需传姓名

与 trading-mcp-v2 的关系

本 MCP 专注持仓/盈亏/风险查询,可独立运行,也可与 trading-mcp-v2 并行使用。

| 能力 | trading-mcp-v2 | position-mcp | |------|---------------|--------------| | 持仓+盈亏快照 | ✅ get_owner_pnl/get_pnl_summary | ✅ get_pnl_overview/get_owner_detail | | VAR 风险仪表盘 | 部分(嵌在盈亏报告里) | ✅ 独立维度 get_risk_status | | 策略详情/公式/评分 | ✅ | ❌ | | 行情/历史价格 | ✅ | ❌ | | 经济数据库 | ✅ | ❌ | | 外盘实时行情 | ✅ | ❌ |

开发

cd packages/linker-position-mcp
npm install
npm run build     # tsc 编译
npm run watch     # 开发热编译
node test_tool.mjs  # 运行工具测试

测试

node test_tool.mjs

输出示例:

=== linker-position-mcp Tool Tests ===
═══ Test 1: list_owners ═══
✓ 39 owners found

═══ Test 2: get_pnl_overview ═══
✓ grand_total: realized=89555573, floating=-37185340, total=52370232
✓ 37 owners summarized

═══ Test 3: get_owner_detail(任志华) ═══
✓ 任志华: 15 active strategies, total_pnl=204330932

═══ Test 4: get_risk_status (全员) ═══
✓ 25 owners, 5 alerts (overlimit)

═══ Test 5: get_risk_status(任志华) — VAR趋势 ═══
✓ 任志华 近30日无VAR记录

✅ All tests passed