Yahoo Finance MCP Server
MCP server that exposes Yahoo Finance data through tools for searching instruments, fetching quotes, history, company info, financials, dividends, news, recommendations, and options. Enables AI assistants to answer market-data questions using natural language.
README
Yahoo Finance MCP Server
An MCP server that exposes Yahoo Finance
data to MCP clients (such as Claude Desktop). It runs over stdio (default,
for local clients) or an HTTP transport (for standalone / containerized
hosting). Market data is sourced through the
yfinance library, which uses
Yahoo's unofficial endpoints.
Disclaimer
- This project is not affiliated with, endorsed by, or sponsored by Yahoo. "Yahoo" and "Yahoo Finance" are trademarks of their respective owners.
- It relies on unofficial Yahoo Finance endpoints via
yfinance. Those endpoints can change or break at any time, and Yahoo may rate limit or block requests. Review Yahoo's Terms of Service before use.- Data may be delayed, incomplete, or inaccurate. Nothing here is financial advice. Do not rely on it for trading or investment decisions.
- Provided "as is", without warranty. Intended for personal and educational use. You use it at your own risk. See LICENSE.
- For commercial use, review Yahoo's Terms of Service and consider a properly licensed market-data provider instead of the unofficial endpoints.
Tools
| Tool | Description |
|---|---|
search |
Find instruments by name, ticker, or ISIN; returns Yahoo symbols. |
get_quote |
Current price and key intraday figures for a symbol. |
get_history |
Historical OHLCV data (period/interval or explicit date range). |
get_company_info |
Company profile and key statistics (sector, market cap, P/E, …). |
get_financials |
Income statement, balance sheet, or cash flow (annual/quarterly). |
get_dividends |
Dividend and stock-split history. |
get_news |
Recent news headlines (title, summary, publisher, URL). |
get_recommendations |
Analyst recommendation trend and price targets. |
get_options |
Option expiration dates and the calls/puts chain for a date. |
All get_* tools take a Yahoo Finance symbol. Use search to resolve a
name or ISIN into a symbol first.
Requirements
- Python 3.11+
- A virtual environment (all work is done inside
.venv)
Setup
The only platform difference is the venv interpreter path: Windows uses
.venv\Scripts\python.exe, Linux/macOS use .venv/bin/python.
Windows (PowerShell):
py -m venv .venv
.\.venv\Scripts\python.exe -m pip install -e .
Linux / macOS (bash):
python3 -m venv .venv
.venv/bin/python -m pip install -e .
Running
The transport is chosen on the command line. stdio is the default (used by Claude Desktop and other local clients):
Windows (PowerShell):
.\.venv\Scripts\python.exe -m yahoo_finance_mcp
Linux / macOS (bash):
.venv/bin/python -m yahoo_finance_mcp
To run it as a standalone, network-reachable service, use an HTTP transport (same flags on every OS, only the interpreter path differs):
# Streamable HTTP on http://127.0.0.1:8000/mcp
.venv/bin/python -m yahoo_finance_mcp --transport streamable-http
# Bind all interfaces on a custom port / path
.venv/bin/python -m yahoo_finance_mcp \
--transport streamable-http --host 0.0.0.0 --port 9000 --path /yf
Every option has both a CLI flag and an environment variable (handy for
containers). Precedence is CLI > environment > default (--help for the
full list):
| Flag | Env var | Default | Description |
|---|---|---|---|
--transport |
YF_MCP_TRANSPORT |
stdio |
stdio, streamable-http, or sse. |
--host |
YF_MCP_HOST |
127.0.0.1 |
Bind host for HTTP transports (0.0.0.0 for remote). |
--port |
YF_MCP_PORT |
8000 |
Port for HTTP transports. |
--path |
YF_MCP_PATH |
/mcp (/sse for sse) |
URL path for HTTP transports. |
--log-level |
YF_MCP_LOG_LEVEL |
INFO |
DEBUG/INFO/WARNING/ERROR/CRITICAL. |
--cache / --no-cache |
YF_MCP_CACHE |
off | Enable/disable the persistent result cache. |
--cache-dir |
YF_MCP_CACHE_DIR |
OS cache dir | Directory for the cache file. |
--cache-ttl <NAME>=<SECONDS> |
YF_MCP_CACHE_TTL_<NAME> |
per-tool defaults | Override one tool's TTL. |
Logging always goes to stderr, so under stdio stdout stays reserved for the JSON-RPC protocol.
Note: The HTTP transports expose the server over the network without built-in authentication. Only bind to
0.0.0.0on trusted networks, and put a reverse proxy / auth layer in front for any real deployment.
Docker
A Dockerfile builds a small image that hosts the server over the
streamable-HTTP transport (the stdio transport is for local subprocess use and
is not what you containerize).
The image is configured entirely through environment variables (see the
options table above) — it carries no default command arguments, so overriding a
single setting with -e does not disturb the others.
# Build
docker build -t yahoo-finance-mcp .
# Run with the built-in defaults (streamable-HTTP on 0.0.0.0:8000)
docker run --rm -p 8000:8000 yahoo-finance-mcp
# Server is now reachable at http://localhost:8000/mcp
# Override settings via -e; opt into the cache and persist it in a named volume
docker run --rm -p 9000:9000 \
-e YF_MCP_PORT=9000 \
-e YF_MCP_LOG_LEVEL=DEBUG \
-e YF_MCP_CACHE=1 \
-v yahoo-finance-cache:/cache \
yahoo-finance-mcp
The image runs as a non-root user and includes a healthcheck on the configured
HTTP port. The cache is off by default; enable it with -e YF_MCP_CACHE=1, in
which case it is written to /cache (declared as a volume) — mount a named
volume there to keep it across container restarts. As with any
HTTP deployment, there is no built-in authentication — front it with a reverse
proxy / auth layer before exposing it publicly.
Docker Compose
A compose.yaml is provided (settings under environment:, cache in a named
volume):
docker compose up -d # build (if needed) and start in the background
docker compose logs -f # follow logs
docker compose down # stop and remove
This requires Docker Compose v2 (the compose CLI plugin). The server is then
reachable at http://localhost:8000/mcp.
Claude Desktop configuration
Add the server to your claude_desktop_config.json, using the absolute path to
the venv interpreter.
Windows:
{
"mcpServers": {
"yahoo-finance": {
"command": "C:\\path\\to\\xt-yahoo-finance-mcp\\.venv\\Scripts\\python.exe",
"args": ["-m", "yahoo_finance_mcp"]
}
}
}
Linux / macOS:
{
"mcpServers": {
"yahoo-finance": {
"command": "/path/to/xt-yahoo-finance-mcp/.venv/bin/python",
"args": ["-m", "yahoo_finance_mcp"]
}
}
}
Example prompts
Once the server is connected, you can ask the client natural-language
questions and it will pick the right tools. Replace the bracketed placeholders
(e.g. [Ticker], [ISIN]) with concrete values.
Price & quote (get_quote, get_history)
- "What's the current price of [Ticker] and how has it moved over the last 24h?"
- "Get the daily closing prices of [Ticker] for the last 6 months and compute RSI, MACD, and the 50/200-day moving averages."
- "What was the max drawdown of [Ticker] since inception, and how long was it underwater?"
- "Compare the performance of [Ticker A] against [Index] over 1, 3, and 6 months (relative strength)."
- "How far is [Ticker] currently from its 52-week high?"
Company data & valuation (get_company_info, get_financials)
- "Give me P/E, beta, market cap, and dividend yield for [Ticker]."
- "Are the fundamentals (ROE, leverage, margins) for [Ticker] available via Yahoo? If not, flag the metric as unavailable."
- "How liquid is [Ticker]? Average daily volume and market cap."
Analysts & sentiment (get_recommendations, get_news)
- "What's the current analyst consensus for [Ticker], and any up-/downgrades from the last few weeks?"
- "How far is the average price target for [Ticker] above/below the current price?"
- "Any recent news on [Ticker], and is the sentiment positive or negative?"
Dividends (get_dividends)
- "List the distribution history of [Ticker] and compute the total-return recovery including reinvested dividends from [year]."
- "From which year does Yahoo cover dividends for [Ticker]?"
Search / resolution (search)
- "Resolve the ISIN [ISIN] to a Yahoo ticker."
- "Which Yahoo ticker belongs to [security name] on [exchange]?"
Combined daily update (multiple tools)
- "For the asset list [Ticker, Ticker, …]: for each name, pull the price history (6 months), quote, company info, and analyst recommendations, then summarize the current technical and sentiment picture per asset."
The server only returns raw market data; any derived metrics (RSI, MACD, drawdown, sentiment, total return) are computed by the client/model from that data, not by the tools themselves.
Symbol resolution
All get_* tools expect a Yahoo Finance symbol (e.g. AAPL, SAP.DE).
To resolve a company name or an ISIN to a symbol, call search first — the
same Yahoo search endpoint handles free text, tickers, and ISINs.
Caching
An opt-in persistent cache. When enabled, successful tool results are cached in a small SQLite file with a per-tool time-to-live (TTL) to reduce load on Yahoo's endpoints and survive restarts. Fast-moving data has a short TTL, stable data a long one.
Within a single running process yfinance already reuses identical requests, so the cache mainly helps across restarts and as rate-limit protection — that is why it is off by default.
Cache names (used for --cache-ttl <NAME>=<SECONDS> and
YF_MCP_CACHE_TTL_<NAME>) and their default TTLs:
| Name | Tool | Default TTL |
|---|---|---|
quote |
get_quote |
30 s |
history |
get_history |
10 min |
news |
get_news |
10 min |
options |
get_options |
10 min |
search |
search |
1 h |
company_info |
get_company_info |
6 h |
dividends |
get_dividends |
6 h |
recommendations |
get_recommendations |
6 h |
financials |
get_financials |
24 h |
- Off by default; enable with
--cacheorYF_MCP_CACHE=1. - Location: the OS user cache directory, or
--cache-dir/YF_MCP_CACHE_DIR. - Override a TTL:
--cache-ttl quote=15(repeatable) or theYF_MCP_CACHE_TTL_<NAME>env var (e.g.YF_MCP_CACHE_TTL_QUOTE=15). Set a TTL to0to bypass caching for that tool.
Precedence is CLI > environment > default. Errors are never cached.
When to enable it
Enable the cache (--cache / YF_MCP_CACHE=1) if you:
- run the server as a long-running or containerized HTTP service that restarts periodically (the cache survives restarts → instant repeat results);
- hit Yahoo rate limits or make many repeated identical requests over time;
- mostly query slow-changing data (search, company info, financials), where staleness is irrelevant.
Leave it off (the default) if you:
- run it locally over stdio for interactive sessions — yfinance already reuses identical requests within a single process, so the cache adds little;
- need the freshest possible data;
- use it only occasionally.
Development
Install the dev extras, then run the test, lint, and type-check steps (the same
ones CI runs). Replace .venv/bin/python with .venv\Scripts\python.exe on
Windows:
.venv/bin/python -m pip install -e ".[dev]"
.venv/bin/python -m pytest -q # unit tests (offline)
.venv/bin/python -m ruff check . # lint
.venv/bin/python -m ruff format . # format
.venv/bin/python -m mypy # type check
.venv/bin/python -m pytest --cov=yahoo_finance_mcp # coverage
The unit tests mock yfinance and run fully offline. tests/smoke.py performs
an ad-hoc check against live Yahoo Finance and is not part of the unit suite.
CI also runs across Python 3.11–3.13 and enforces an 80% coverage floor.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。