Skip to main content

MCP server exposing Yahoo Finance market data via yfinance

Project description

yfinance-mcp

MCP server that exposes Yahoo Finance market data to AI assistants (Claude Code, Claude Desktop, or any MCP-compatible client).

25 tools covering: price history, options chains, news, financials, analyst estimates, holders, and more.


Quick Start

Install

pip install yfinance-mcp

For local development (editable install):

git clone https://github.com/YOUR_USER/yfinance-mcp.git
cd yfinance-mcp
pip install -e .

Verify Installation

yfinance-mcp --help

If the command is found, the server is ready.


Usage

With Claude Code

Create a .mcp.json file in your project root:

{
  "mcpServers": {
    "yfinance": {
      "command": "yfinance-mcp"
    }
  }
}

Then restart Claude Code. The 25 tools will be available automatically — just ask Claude about any stock, options chain, or market news.

With Claude Desktop

Edit %APPDATA%\Claude\claude_desktop_config.json (Windows) or ~/Library/Application Support/Claude/claude_desktop_config.json (macOS):

{
  "mcpServers": {
    "yfinance": {
      "command": "yfinance-mcp"
    }
  }
}

Restart Claude Desktop. Done.

With Any MCP Client

The server uses stdio transport. Launch it with:

yfinance-mcp

Connect your MCP client to stdin/stdout of that process.


Available Tools (25)

Price

Tool Description
get_price_history OHLCV data (configurable period, interval, date range)
get_dividends Dividend history
get_splits Stock split history

Info

Tool Description
get_ticker_info Full company info (sector, industry, description, financials)
get_fast_info Quick snapshot (price, volume, market cap, 52w range)
get_ticker_summary Composite: price + fundamentals + news + analyst targets

News

Tool Description
get_ticker_news Recent news articles for a ticker
search_news General market news search by keyword

Options

Tool Description
get_options_expirations Available expiration dates
get_options_chain Calls/puts with strike, bid, ask, volume, OI, IV

Financial Statements

Tool Description
get_income_statement Income statement (yearly/quarterly/trailing)
get_balance_sheet Balance sheet (yearly/quarterly)
get_cash_flow Cash flow statement (yearly/quarterly)

Analysis & Estimates

Tool Description
get_analyst_price_targets Price targets (low, high, mean, median, current)
get_recommendations Buy/sell/hold ratings over time
get_upgrades_downgrades Analyst rating changes
get_earnings_estimate EPS estimates by period
get_revenue_estimate Revenue estimates by period
get_growth_estimates Growth rate estimates
get_eps_trend EPS trend / estimate revisions

Holders

Tool Description
get_institutional_holders Top institutional holders
get_insider_transactions Recent insider buys/sells
get_major_holders Major holder breakdown

Events & Search

Tool Description
get_earnings_dates Upcoming/past earnings dates
get_calendar Upcoming events (dividends, earnings)
search_tickers Search tickers by company name or keyword

Example Prompts

Once connected, just ask Claude naturally:

  • "Show me AAPL's options chain for the nearest expiration"
  • "What's the latest news on TSLA?"
  • "Compare MSFT and GOOGL fundamentals"
  • "Get analyst price targets for NVDA"
  • "Show me AMZN's quarterly income statement"

Publishing to PyPI

1. Prerequisites

Create a PyPI account at pypi.org and generate an API token:

  1. Go to pypi.org/manage/account
  2. Scroll to API tokens > Add API token
  3. Name: yfinance-mcp, Scope: Entire account (first time) or project-scoped later
  4. Copy the token (starts with pypi-)

2. Install Build Tools

pip install build twine

3. Build the Package

From the yfinance_mcp/ directory:

cd yfinance_mcp
python -m build

This creates two files in dist/:

  • yfinance_mcp-0.1.0.tar.gz (source distribution)
  • yfinance_mcp-0.1.0-py3-none-any.whl (wheel)

4. Test Upload (Optional but Recommended)

Upload to TestPyPI first to verify everything works:

twine upload --repository testpypi dist/*

You'll be prompted for credentials:

  • Username: __token__
  • Password: your TestPyPI API token

Test installing from TestPyPI:

pip install --index-url https://test.pypi.org/simple/ yfinance-mcp

5. Publish to PyPI

twine upload dist/*

Credentials:

  • Username: __token__
  • Password: your PyPI API token (the pypi- one from step 1)

6. Verify

pip install yfinance-mcp
yfinance-mcp  # Should start the stdio server

Updating Versions

  1. Bump version in pyproject.toml and src/yfinance_mcp/__init__.py
  2. Rebuild: python -m build
  3. Upload: twine upload dist/*

Project Structure

yfinance_mcp/
├── pyproject.toml                  # Package metadata + entry point
├── LICENSE
├── README.md
├── src/
│   └── yfinance_mcp/
│       ├── __init__.py             # Package version
│       ├── server.py               # FastMCP server + 25 tools
│       └── utils.py                # DataFrame/Series serialization
└── tests/
    └── test_server.py              # Unit tests

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

yfinance_market_mcp-0.1.0.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

yfinance_market_mcp-0.1.0-py3-none-any.whl (9.6 kB view details)

Uploaded Python 3

File details

Details for the file yfinance_market_mcp-0.1.0.tar.gz.

File metadata

  • Download URL: yfinance_market_mcp-0.1.0.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for yfinance_market_mcp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 86d06be331e8c3c33e61620ea94c795437a70f7c1e79aa5688bdfb136232167a
MD5 c1a36e944456a06b47171adb7131a95e
BLAKE2b-256 65d442503be09e04366d4aaa8a68631bd74e31ddb13cb8b2dbfd789e5a4e7177

See more details on using hashes here.

File details

Details for the file yfinance_market_mcp-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for yfinance_market_mcp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4e59a590e06b1d4ec04ffc991a5425d0270fc0f1eb29f53be41eae8b80d810c7
MD5 20ccf0bbaa9dbcd1b85f5bd3ea8dca76
BLAKE2b-256 8975145fc1b92794447d5cd2c331bd0dbbfd5ccdf85eb1e3d8d1765596809c79

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page