bull-milker-mcp
Enables agents to view moomoo market data, run the Bull Milker stock screener, and assess portfolio risk/exposure without placing orders. Also offers optional gated order execution and quarterly tax summaries.
README
bull-milker-mcp
A read-only MCP server exposing moomoo market data, the Bull Milker screener, and portfolio risk/exposure tools to Claude Desktop.
What it exposes
| Tool | What it does |
|---|---|
check_health |
Confirms OpenD is reachable |
get_account_positions |
Current paper/live positions |
get_market_snapshot |
Live price/volume/change for given codes |
run_bull_milker_screener |
Screener: turnover, volume, and % change filters, configurable via .env |
run_bull_milker_extended_screener |
Bull Milker + PE ratio and short-interest enrichment (see caveats below) |
get_portfolio_sector_exposure |
Deterministic concentration calc across your current positions, grouped by real moomoo industry-plate sectors |
get_sector_technical_outlook_tool |
RSI/SMA technical signals aggregated per sector, holdings-weighted (see below) |
get_quarterly_transaction_summary_tool |
Trade counts by quarter (Q126 format), no cost-basis matching |
get_quarterly_tax_summary_tool |
Realized gain/loss by quarter, FIFO cost basis, LIVE account only (opt-in) |
Important caveats — read before wiring up the "suggest investments" agent
- Sector grouping:
get_portfolio_sector_exposureandget_sector_technical_outlook_toolgroup holdings by moomoo's real industry-type plates (viaget_owner_plate), not GICS. Concept/thematic plates are excluded. A symbol with no industry-plate match is grouped under an explicitly-labeled"Unknown (no industry plate mapping)"bucket — never silently folded into a real sector. - Sector technical signals are a proxy, not an index quote:
get_sector_technical_outlook_tool'sweighted_rsi_14and SMA figures are a market-value-weighted average of each holding's own locally computed RSI/SMA, not a real sector-index feed — moomoo doesn't expose one through this API. Daily kline history is cached underdata/kline_cache/because moomoo's historical-kline quota takes 7 days to release per symbol; don't delete that cache casually or you'll burn quota re-fetching it. - PE ratio: available directly from moomoo (
pe_ttm_ratioon snapshots, or as aFinancialFilterin the screener). Included and working. - Short volume / short interest: moomoo's snapshot endpoint exposes
short_sell_rateandshort_available_volumeper symbol. These are fetched as an enrichment step after the screener runs (not filterable insideget_stock_filteritself, since it's not one of the screenableStockFieldoptions as far as the public API docs show). - Institutional investment %: moomoo's app has an "Institutional
Tracker" based on 13F filings, but as of writing this doesn't appear to be
exposed through the public OpenAPI — 13F data is also inherently quarterly
and reported with up to a 45-day lag, so even where available it's a
lagging indicator, not real-time.
indicators.pyhas a stubbedget_institutional_ownership()that raisesNotImplementedErrorwith a clear TODO — plug in a third-party data provider there (e.g. a paid fundamentals API) if you want this metric. Don't let the agent silently treat a missing/stubbed value as "0% institutional ownership" — the tool returnsNoneexplicitly so that distinction is visible upstream.
Setup
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .
cp .env.example .env # fill in values
Requires moomoo OpenD running and logged in (see the main Bull Milker
project's opend/README.md if you have it, or
https://openapi.moomoo.com/moomoo-api-doc/en/intro/).
Developing in VS Code
- Open this folder in VS Code.
.vscode/launch.jsonis set up to runsrc/bull_milker_mcp/server.pydirectly under the debugger — set breakpoints in any tool function and step through a call.- For a protocol-level test without any client, use the MCP Inspector:
npx @modelcontextprotocol/inspector python -m bull_milker_mcp.server - Run
python -m bull_milker_mcp.screenerfor a quick manual smoke test of the screener logic alone, without going through MCP at all.
Wiring into Claude Desktop
Copy the relevant block from claude_desktop_config.example.json into your
Claude Desktop MCP config, updating the cwd path. Restart Claude Desktop,
then confirm the tools show up (Claude Desktop's MCP tool picker, or just
ask "what tools do you have from bull-milker-mcp?").
Suggested build/test order
check_health— confirm the OpenD round trip works at all.get_market_snapshot— one real symbol, verify data shape.get_account_positions— paper account.run_bull_milker_screener— verify against the existing Bull Milker project's results.get_portfolio_sector_exposure— test with a small known portfolio, check the math by hand.run_bull_milker_extended_screener— add PE + short interest enrichment.get_sector_technical_outlook_tool— first call will be slow (fetches ~380 days of daily klines per holding); re-run it and confirm the second call is fast, using the cache instead of re-fetching.- Wire into Claude Desktop, test each tool interactively in chat.
- Only then: build the standing prompt and set up a Cowork scheduled task.
Safety
See SAFETY.md for the full threat model and user stories. In short:
this server is read-only by design and by enforcement — guardrails.py
checks for trade-execution symbols at startup, and
tests/test_no_trading_capability.py fails the build if any creep in.
Every tool call is logged to data/audit_log.jsonl (see audit.py).
Before adding any new tool, ask: does this need to place, modify, or cancel an order? If yes, stop and read SAFETY.md US-2 first.
Run the safety test any time: pytest tests/test_no_trading_capability.py -v
MCP SDK version note
This project targets mcp v2 (MCPServer, not the older FastMCP class
— the official SDK renamed it in its July 2026 v2 release; v1 is now
maintenance-only). If you're following older MCP tutorials that show
from mcp.server.fastmcp import FastMCP, that's the v1 API — this repo
uses from mcp.server import MCPServer instead. If your installed mcp
resolves to <2.0, either upgrade (pip install "mcp[cli]>=2.0") or pin
your own project to mcp>=1.28,<2 and revert this file's import — don't
mix the two.
Tax reporting (live account)
get_quarterly_tax_summary computes realized capital gains/losses by
quarter (Q126 format) using FIFO cost-basis matching against your LIVE
account's deal history — genuinely different from
get_quarterly_transaction_summary, which just counts trades on whichever
account (paper by default) and does no cost-basis matching at all.
This is gated behind TAX_AUDIT_ENABLE_LIVE=true in .env — it's off by
default and raises a clear PermissionError if you call it without
enabling it first. See SAFETY.md US-8/US-9/US-10 before turning this on.
Not tax advice. FIFO cost basis, no wash-sale handling, no corporate actions, no dividends. Reconcile against your broker's 1099-B and talk to an actual tax professional before filing anything.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。