stockdata-mcp
An MCP server for stock research with 52 tools across FMP and Qualtrim backends, providing raw financial data plus derived analytics, DCF, AI commentary, and portfolio management. It handles caching, API budgeting, and credential management.
README
stockdata-mcp
An MCP server for stock research. Two backends, one tool surface.
FMP (fmp_*) |
Raw data — statements, quotes, ratios, estimates, prices, dividends. Documented public API. Always on. |
Qualtrim (qualtrim_*) |
Only what Qualtrim derives on top of FMP — their DCF, curated KPI charts, AI commentary, dip finder, plus your own portfolios and watchlists. Optional. |
The split is deliberate. Qualtrim is an FMP customer: it buys the raw data and adds a layer. So this server goes to FMP directly for anything raw, and spends Qualtrim calls only on what is uniquely Qualtrim's.
52 tools — 30 FMP, 22 Qualtrim.
Before you enable the Qualtrim backend
The FMP half of this server is ordinary: a documented public API, a key you sign up for, use it however you like.
The Qualtrim half is not. Qualtrim publishes no API — those routes were read off their shipped JavaScript, and their Terms of Service prohibit both reverse engineering the platform and using automated means to retrieve data from it without prior written consent.
That consent is not transferable and this repository does not grant it. If you want to run the Qualtrim backend, you need your own paid Qualtrim account and your own written permission from Qualtrim, obtained yourself. Ask them directly at support@qualtrim.com.
Without that, run the server with
QUALTRIM_USERNAME/QUALTRIM_PASSWORDunset. The FMP tools work fine on their own and nothing here depends on Qualtrim.The code is published as a reference for how such a client is structured, not as an invitation to point it at someone else's service. Qualtrim's stated remedy for violations is account termination, and their fees are non-refundable.
Install
cd ~/Projects/stockdata-mcp
uv venv && uv pip install -e .
./scripts/set-credentials.sh # prompts; password input is hidden
set-credentials.sh writes .env with 0600 permissions. It is gitignored.
Get a free FMP key at
https://site.financialmodelingprep.com/developer/docs.
Register once, for every session on the machine:
claude mcp add stockdata --scope user -- ~/Projects/stockdata-mcp/.venv/bin/stockdata-mcp
No -e flags — the server reads .env itself, so credentials stay out of
~/.claude.json. Real environment variables still override the file, so an MCP
client can pass -e if you'd rather.
Check it from any session with backend_status.
Guidance for the model
The server ships its own usage instructions over the MCP protocol — backend choice, free-tier limits, Qualtrim's quirks, how to report figures. Every MCP client receives these automatically, with no extra setup.
There is also a fuller skill at .claude/skills/stock-research/ covering
research workflows in more depth. Claude Code reads it from
~/.claude/skills/ (symlink it there). Claude Desktop manages skills in its own
location and will not pick it up from that directory — it relies on the server
instructions above, which carry the decision-critical parts.
Caching and budget
Responses are cached in a SQLite store at ~/.cache/stockdata-mcp/cache.db.
The store is global, not per client — every server process for this user
opens the same file, so Claude Code and Claude Desktop share one cache and one
daily total. That is required for correctness, not just efficiency: the FMP
quota belongs to the API key, and both apps use the same key.
TTL is chosen per endpoint. Quotes last a minute; profiles a week; reference data a month. Historical bars whose date range ended before today never expire, because a close that already happened cannot change. A range running up to today still has a moving edge and gets 15 minutes.
Three tools manage this:
| Tool | Purpose |
|---|---|
usage_status |
Requests sent today, remaining, reset time, cache stats |
estimate_cost |
What a set of planned calls will cost upstream, before running |
cache_clear |
Drop expired entries (safe) or a whole backend |
estimate_cost exists because the tool-to-request ratio is not 1:1 and is
invisible from the caller's side: fmp_search issues 2 requests,
fmp_price_target 3, and fmp_quote one per symbol on a free key. It reports
worst-case requests, how many legs are already cached, and the net against
today's remaining budget. Verified: its prediction matched actual spend exactly
on a mixed five-call plan, and returned 0 for the same plan re-run warm.
Measured across six independent processes requesting the same symbol concurrently: 1 upstream request, 5 cache hits, no lock contention.
Configuration
| Variable | Default | Purpose |
|---|---|---|
FMP_API_KEY |
— | Required for the fmp_* tools |
QUALTRIM_USERNAME / QUALTRIM_PASSWORD |
— | Enables the qualtrim_* tools |
QUALTRIM_ENABLE_WRITES |
false |
Allow tools that modify your portfolios/watchlists |
QUALTRIM_MIN_INTERVAL |
1.0 |
Minimum seconds between Qualtrim requests |
FMP_MIN_INTERVAL |
0.1 |
Minimum seconds between FMP requests |
MAX_RESPONSE_CHARS |
50000 |
Trim oversized tool payloads |
STOCKDATA_ENV_FILE |
./.env |
Alternate path to the env file |
FMP tools
Search and reference: fmp_search, fmp_profile, fmp_quote, fmp_peers,
fmp_reference.
Fundamentals: fmp_income_statement, fmp_balance_sheet, fmp_cash_flow,
fmp_key_metrics, fmp_ratios, fmp_financial_growth, fmp_financial_scores,
fmp_revenue_segmentation, fmp_enterprise_values.
Analysts and valuation: fmp_analyst_estimates, fmp_price_target,
fmp_grades, fmp_dcf.
Events and markets: fmp_dividends, fmp_earnings, fmp_earnings_calendar,
fmp_historical_prices, fmp_technical_indicator, fmp_screener,
fmp_market_movers, fmp_sector_performance, fmp_insider_trading, fmp_news.
fmp_request(endpoint, params) reaches any of FMP's ~250 stable endpoints —
ETF holdings, 13F, senate trades, economic indicators, SEC filings, transcripts —
without a dedicated wrapper.
What the free tier actually covers
Verified against a live free key: 22 of 29 tools work.
Paid plan required: fmp_screener, fmp_reference, fmp_news,
fmp_insider_trading, fmp_technical_indicator. Each returns a clear error
naming the plan as the cause.
Two notes:
- Multi-symbol
fmp_quotefalls back to per-symbol requests, because the batch route is paid. Capped at 20 symbols to protect the daily quota. fmp_technical_indicatorbeing paid is easy to route around —fmp_historical_pricesis free, so indicators can be computed from OHLCV locally.
The free tier allows roughly 250 requests/day. Pass limit and
from_date/to_date; the default on price history is the entire series.
Qualtrim tools
Per-symbol: qualtrim_overview, qualtrim_profile, qualtrim_quote,
qualtrim_dcf, qualtrim_kpi_charts, qualtrim_chart, qualtrim_ai_analysis,
qualtrim_analyst_estimates.
Comparison: qualtrim_available_kpis, qualtrim_compare.
Your account: qualtrim_portfolios, qualtrim_portfolio,
qualtrim_portfolio_look_through_earnings, qualtrim_portfolio_ai_analysis,
qualtrim_portfolio_dividends, qualtrim_watchlists, qualtrim_watchlist,
qualtrim_dip_finder, qualtrim_watchlist_valuation_ranges.
Escape hatch: qualtrim_request(path), GET only.
Writes (qualtrim_add_watchlist_stock, qualtrim_add_portfolio_holding) refuse
to run unless QUALTRIM_ENABLE_WRITES=true.
How the Qualtrim auth actually works
Their shipped bundle looks like bearer-token auth — authTokens in
localStorage, Authorization: Bearer. It isn't. Login returns the user object
and sets an Express session cookie (connect.sid); that cookie is what
authorises normal requests. The bundle's token path is exercised only by its
refresh call.
This client keeps a cookie jar, caches the session at
~/.cache/stockdata-mcp/qualtrim-session.json (0600), and logs in again
automatically on a 401.
Known drift
Their deployed backend has already diverged from the bundle the routes were read from:
| Route in bundle | Reality |
|---|---|
/api/insights/{sym}/overview |
404 — use overview-flexible |
/api/insights/{sym}/dcf-calculator |
Returns only a saved calculator; use dcf-calculator-flexible |
Both tools already use the working variants. Expect more of this over time — a 404 from a Qualtrim tool means the route moved, not that the ticker is wrong.
qualtrim_dcf returning empty is not a failure; it means no DCF is saved for
that symbol in your account.
Qualtrim and their Terms of Service
Qualtrim publishes no API. These routes were read off their shipped JavaScript. Two consequences:
It can break without notice. See "Known drift" above — it already has.
It is restricted by their terms. Their acceptable-use section prohibits using automated means to systematically retrieve data from the site without prior written consent, and separately prohibits reverse engineering the platform. Their enforcement lever is account termination, and their fees are non-refundable.
Consent is obtainable — the prohibition is conditional on it. Ask Qualtrim directly at support@qualtrim.com, and keep their reply.
Defaults here are conservative: 1 request/sec, 2 concurrent max, browser-matching user agent, GET by default, no bulk enumeration. Keep it to interactive research volumes.
Layout
src/stockdata_mcp/
server.py tool definitions for both backends
fmp.py FMP stable-API client
qualtrim.py Qualtrim cookie-session client
util.py throttling, response trimming, .env loading
scripts/
set-credentials.sh
.claude/skills/stock-research/SKILL.md
Not investment advice
Data for your own research. Neither source guarantees accuracy, and nothing here is a recommendation to buy or sell.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。