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.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.