yahoo-finance-mcp-server

yahoo-finance-mcp-server

An MCP server that exposes comprehensive Yahoo Finance data (quotes, financials, options, news, and more) to AI agents via the yfinance library, requiring no API key.

Category
访问服务器

README

Yahoo Finance MCP Server

An MCP server that exposes the full Yahoo Finance data surface to AI agents, backed by the yfinance library. No API key required.

Note on the "Yahoo Finance API": Yahoo retired its official public finance API years ago. This server uses yfinance, which wraps Yahoo's internal query1/query2.finance.yahoo.com endpoints (handling cookie/crumb auth for you). It is the most complete free way to access Yahoo's data, but it is unofficial — endpoints can change or rate-limit without notice.

What the agent can see

Every major data category Yahoo Finance serves is exposed as a tool:

Tool Data
get_quote Fast price snapshot (last/open/high/low, volume, market cap, 52-wk range)
get_ticker_info Full company/security profile (.info): sector, ratios, margins, targets, summary
get_isin ISIN identifier
get_historical_prices OHLCV history by period or date range, any interval (1m → 3mo)
download_multiple Batch historical prices for many symbols at once
get_corporate_actions Dividends, splits, capital gains
get_financial_statements Income statement / balance sheet / cash flow (annual & quarterly)
get_earnings Earnings calendar & dates, EPS/revenue estimates, EPS trend & growth
get_analyst_data Recommendations, price targets, upgrades/downgrades
get_holders Major / institutional / mutual-fund holders + insider activity
get_shares Historical shares outstanding
get_sustainability ESG risk scores
get_option_expirations Available option expiry dates
get_option_chain Calls & puts (strike, IV, OI, volume, bid/ask) for an expiry
get_news Recent related news articles
get_sec_filings Recent SEC filings with document links
get_fund_data ETF/mutual-fund holdings, allocations, sector weights, bond ratings
search Resolve a name → symbol; matching quotes + news
lookup Enumerate instruments by type (stock/etf/index/currency/crypto/…)
get_sector Sector overview, top companies/ETFs, industries
get_industry Industry overview, top performing/growth companies
get_market_status Market open/closed status & index summary by region
screen_predefined Preset screens (day_gainers, most_actives, …)
screen_custom Custom numeric screen (e.g. market cap > $1B)

Tickers use Yahoo symbols: AAPL, MSFT, BTC-USD, ^GSPC, EURUSD=X.

Installation

Requires Python 3.10+.

python3 -m venv .venv
source .venv/bin/activate
pip install -e .

Running

The server speaks MCP over stdio:

yahoo-finance-mcp
# or
python -m yahoo_finance_mcp

Claude Desktop / Claude Code config

Add to your MCP client config (e.g. claude_desktop_config.json):

{
  "mcpServers": {
    "yahoo-finance": {
      "command": "/absolute/path/to/yahoo-finance-mcp-server/.venv/bin/python",
      "args": ["-m", "yahoo_finance_mcp"]
    }
  }
}

Or, with Claude Code:

claude mcp add yahoo-finance -- /absolute/path/to/.venv/bin/python -m yahoo_finance_mcp

Deployment (HTTP, port 8081)

For remote/agent access the server can run over streamable HTTP instead of stdio. Transport and binding are controlled by env vars:

Var Default Purpose
MCP_TRANSPORT stdio streamable-http (or sse) to serve over HTTP
MCP_HOST 0.0.0.0 bind address
MCP_PORT 8081 listen port

Run it directly:

MCP_TRANSPORT=streamable-http MCP_PORT=8081 python -m yahoo_finance_mcp
# endpoint: http://<host>:8081/mcp

Automated deploy via SSH

deploy/deploy.sh ships the code to a remote host, installs it, and (re)starts it on port 8081 with a health check. It authenticates over SSH using these GitHub repository secrets:

Secret Meaning
DEPLOY_SSH_HOST remote endpoint (host/IP)
DEPLOY_SSH_PORT SSH port
DEPLOY_SSH_USER SSH username
DEPLOY_SSH_PASSWORD SSH password

Python is auto-provisioned. The script needs Python ≥ 3.10. It first scans the remote for any installed interpreter that qualifies (python3.103.13, including /usr/local/bin). If none is found — e.g. on Raspberry Pi OS Bullseye, which ships only Python 3.9.2 — it installs build deps and compiles CPython (default 3.11.9, override with PYTHON_BUILD_VERSION) to /usr/local via make altinstall. This one-time bootstrap takes ~15–40 min on a Pi; subsequent deploys detect the installed interpreter and skip it.

Building requires root: it works if the deploy user has passwordless sudo, otherwise it falls back to sudo -S using DEPLOY_SSH_PASSWORD. You can still set PYTHON_BIN to force a specific interpreter; it's used if it qualifies.

The .github/workflows/deploy.yml workflow runs the script on every push to main (and on manual workflow_dispatch). To run it by hand:

DEPLOY_SSH_HOST=1.2.3.4 DEPLOY_SSH_PORT=22 \
DEPLOY_SSH_USER=pi DEPLOY_SSH_PASSWORD=secret \
PYTHON_BIN=python3.11 \
./deploy/deploy.sh

The script clones/updates the repo, builds a venv, stops any prior instance on the port, starts the server detached (setsid, survives disconnect, logs to server.log), then verifies POST /mcp returns 200.

Notes & limitations

  • Unofficial data source. Yahoo may rate-limit or change responses. Tools return a structured {"error": ...} payload instead of crashing when a call fails, so the agent can react.
  • Intraday history is range-limited by Yahoo (e.g. 1m data only for the last few days).
  • Data is provided for informational purposes; respect Yahoo's Terms of Service. Not investment advice.

Development

pip install -e .
python -c "from yahoo_finance_mcp.server import mcp; print(len(mcp._tool_manager.list_tools()), 'tools')"

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选