内容
# Stock Analysis MCP
[](https://www.python.org/)
[](LICENSE)
Stock research for Claude Code, Codex, and other MCP clients. Get buy, wait, or
avoid guidance, plus hold/sell signals for positions you own—with valuation,
chart signals, risks, and earnings context.
Decision-card hard gates can block a buy for a falling knife, earnings risk, weak
liquidity, poor data quality, or unsupported instruments—even if the narrative is
positive.
Yahoo Finance data via `yfinance`. No market-data API key required. Does not place orders.
## How to use
Once connected, just ask your agent:
```text
Analyze HOOD
```
No extra parameters needed. For more specific questions:
| Question | What you get |
|---|---|
| “Analyze MSFT. What supports buying, and what would make you wait?” | A decision card, supporting evidence, blockers, and conditions to revisit. |
| “I own 20 AAPL shares bought at $150 on 2025-01-02. Should I hold or sell?” | Mid-term holder guidance from `analyze`, plus position P&L and holding-period context. |
| “Compare MSFT, AAPL, and GOOGL.” | Valuation, growth, profitability, and momentum side by side. |
| “Any swing setup on HOOD? Account $3,000, risk 1%, position cap 10%.” | Entry, stop, targets, and stop-based sizing when a setup is actionable. |
| “Add AAPL and MSFT to my watchlist, then scan for setups.” | A saved watchlist and setup screen; later scans highlight changes. |
**Real example:** shortened v0.2.0 `analyze` output for RIVN, recorded after the close
on **2026-10-12**. Historical output, not a current recommendation.
```text
RIVN — $13.54
Action: wait
Blocker: falling_knife
Reason: severe decline with broken trends — wait for stabilization
Price: daily_close, as of 2026-10-12
Data gap: pe_not_meaningful
```
## Set up
Requires [uv](https://docs.astral.sh/uv/getting-started/installation/) and Git.
uv can [download Python automatically](https://docs.astral.sh/uv/concepts/python-versions/#installing-python-versions).
Choose your client:
**Claude Code**
```bash
claude mcp add -s user stock-analysis -- uvx --from git+https://github.com/nickzren/stock-analysis-mcp@v0.3.0 stock-analysis
```
**Codex**
```bash
codex mcp add stock-analysis -- uvx --from git+https://github.com/nickzren/stock-analysis-mcp@v0.3.0 stock-analysis
```
These commands are pinned to **v0.3.0**. Other MCP clients can use the same `uvx`
command as a stdio server.
## For agents
Start with `analyze(symbol="MSFT")`. It accepts a ticker or company name;
use `search_symbol` to resolve names before calling other tools.
| Task | Tool |
|---|---|
| General stock decision | `analyze`: `detail="standard"` by default; `"decision"` for a smaller response, `"full"` for the audit detail. |
| Long-only swing trade, days to weeks | `analyze_trade_setup` |
| Existing holding | `analyze` for `decision_card.if_held`; `analyze_my_position` for P&L and tax context (`symbol`, `cost_basis`, `purchase_date`; optional `shares`). |
| Compare 2–5 stocks / review portfolio exposure | `compare` / `analyze_portfolio` |
| Recheck a stock | Save `watchlist_snapshot`; pass it as `previous_snapshot` to `detect_changes`. |
| Maintain and scan up to 25 symbols | `manage_watchlist` / `scan_watchlist` |
| Inspect a specific input | `get_stock_summary`, `get_price_history`, `get_technicals`, `get_fundamentals`, `get_events`, `get_news`, `get_ownership`, `get_options_signals`, `check_data_quality` |
Read `decision_card` with its hard gates, `summary.price_provenance`, and
`data_quality`. Keep timestamps, blockers, and missing-data warnings in the answer;
do not promote a positive narrative into a buy when a gate blocks it.
For swing cards, preserve `action` and `blockers`. Show the returned `plan` only
for `trade_now` or `enter_on_trigger`. `trade_now` requires fresh regular-session
data; unverifiable earnings cap the card at `watch`.
`account_size` enables dollar/share sizing. `analyze` sizes are estimates, not a
guarantee that every suggestion fits the risk budget. Use `analyze_trade_setup`
for stop-based risk sizing; `risk_per_trade_pct=1` means 1% of the account.
Responses use schema **6**; snapshots use **3.0.0**.
[CHANGELOG.md](CHANGELOG.md) covers field meanings, migration, and known limitations.
## Decision
`decision_card` holds one decision, made after the hard gates:
- `new_money`: what to do with new money over 3–12 months (one year defaults here unless long term is explicit);
- `if_held`: what to do if you already own it: `hold`, `reduce`, `review_exit` or `insufficient_data`;
- `long_term.new_money`: new money over 1–5 years.
For a holding, `analyze`'s `if_held` is mid-term; `analyze_my_position` adds P/L,
holding period and tax status. There is no long-term holder decision.
`blocked_by` lists the gates that fired and `decided_by` the one that set the action;
never upgrade past them. Read sizing only from `decision_card.sizing`: mid-term new
money only (no long-term or holder size), null unless new money is `buy` or `starter`. `policy_action` moved to
`diagnostics.pre_gate_policy` (`detail="full"`): pre-gate input, not advice.
| `new_money.action` | Meaning |
|---|---|
| `buy` | Entry allowed, up to full size. |
| `starter` | Entry allowed at starter size only. |
| `wait` | No entry now: the evidence, earnings risk or the 52-week-high band says wait. |
| `wait_for_data` | No entry: required data is missing or stale. |
| `insufficient_data` | No entry: too little data to decide. |
| `watch` | No entry: outside the supported instruments or currencies. |
| `avoid` | No entry: a poor setup, falling knife, weak liquidity or broken thesis. |
Gates, by rank: `stale_data`, `freshness_unverifiable`, `data_quality_critical`,
`missing_runway`, `thesis_unverifiable`, `liquidity_missing` → `wait_for_data`; `falling_knife`,
`weak_liquidity`, `thesis_broken` → `avoid`; `unsupported_instrument`,
`unsupported_currency` → `watch`; `earnings_blackout`, `earnings_unverifiable` →
`wait`; `near_52w_high` → `wait` (mid-term only). The `profile` argument (`core`,
`balanced`, `speculative`) changes sizing only, never an action.
If required business or cash-runway evidence cannot be checked, `thesis_unverifiable`
blocks new money at both horizons. Re-run `analyze` when the evidence is available;
clearing that check alone does not mean buy. Known unsupported instruments do not get this gate.
| Class | Fields | Read as |
|---|---|---|
| A | `decision_card` actions, modes, dislocation and dip actions | The decision, per horizon. |
| S | `decision_card.sizing`, `entry`, sizing ranges | Mid-term new-money size, only for an entry. |
| C | `conditions`, `earliest_reassessment`, `next_review` | Necessary, not sufficient; re-run `analyze`. |
| D | `price_zone`, levels, verdict, data quality | Context, not advice. |
| N | `executive_summary` | Our summary: new money, if held, long term. |
| P | `diagnostics` | Pre-gate input, not advice. |
| T | Analyst, news, ownership and options data | Third-party data, attributed. |
| E | Mode labels and descriptions | Static configuration. |
In `watchlist_snapshot`, `new_money_action` and `if_held_action` are the mid-term
decision and `long_term_action` the long-term one; `scan_watchlist` state holds
swing-card actions.
## Data and limits
- **Supported decisions:** USD-priced common stocks, including USD ADRs. Unsupported
or unverified instruments/currencies block new buying and dollar/share sizing;
existing-holder actions can remain. ETFs, preferreds, and non-USD listings are
outside the supported decision rules.
- **`analyze` price basis:** uses a fresh intraday bar during regular hours when
available, otherwise the completed daily close, then a labelled quote fallback.
Yahoo data can be delayed or incomplete; check the reported source and age.
- **Units and gaps:** dividend yields are fractions (`0.005 = 0.5%`); debt-to-equity
is a ratio (`1.2 = 120%`). Undefined or unverified ratios are null;
`metric_status` marks ratios excluded from scoring. Read cash-flow period labels:
a field named `*_ttm` can contain an annual fallback.
- **Limits remain:** some statement reads become missing fields after failure.
Scores and sizing are rule-based estimates; holder guidance is stateless.
See the [known limitations](CHANGELOG.md#known-limitations-030).
- **Local state:** watchlist and scan state persist in `$STOCK_ANALYSIS_DATA_DIR`,
otherwise `$XDG_DATA_HOME/stock-analysis`, otherwise `~/.local/share/stock-analysis`.
Price-history `price://` resources last only in the server process that fetched
them; use `include_preview=true` for the last five inline bars if resource reads fail.
## Development
[Tests](tests/) run offline against synthetic data and a stubbed Yahoo transport.
They cover failures, earnings dates, price freshness, decision gates, and snapshots.
```bash
uv sync --extra dev --locked
uv run --frozen pytest
uv run --frozen ruff check src tests
```
## Disclaimer
This tool is for **informational purposes only**. It is not financial advice. Always do your own research and consult a qualified financial advisor before making investment decisions. The authors are not responsible for any financial losses incurred from using this tool.
MCP 配置
以下是此 MCP Server 的配置信息,可直接复制到 Cursor 或其他 MCP 客户端中使用。
mcp.json
连接信息
猜你喜欢
worldmonitor
实时全球情报仪表盘。基于人工智能的新闻聚合、地缘政治监测和基础设施跟踪,提供统一的态势感知界面。
Vibe-Trading
Vibe-Trading:您的个人交易代理
ai-berkshire
AI 时代的伯克希尔:基于 Claude Code 的价值投资研究框架。巴菲特·芒格·段永平·李录四大师方法论 + 多Agent并行研究。
HexStrike AI
HexStrike AI是一个AI驱动的MCP网络安全自动化平台,拥有150多个工具。
valuecell
Valuecell是一个用于高效数据管理的Python项目。
tradingview-mcp
AI辅助TradingView图表分析 — 将Claude Code连接到您的TradingView Desktop,实现个人工作流自动化