Replacing yfinance with an MCP Server

Side-by-side code comparison, migration checklist, and what each tool does better.

← Back to workflows

yfinance is a Python library that scrapes Yahoo Finance for stock data. It is free, widely used in tutorials, and works well for quick lookups. But it breaks when Yahoo changes its undocumented API, throttles requests at scale, returns inconsistent data across calls, and has no support for cross-table queries that join prices with fundamentals or insider data.

An MCP server like Shibui Finance takes a different approach. Instead of scraping a website, it gives Claude, ChatGPT, or any MCP-compatible client direct read access to a pre-loaded database: 10,000+ US equities with 64 years of daily prices, quarterly financials, 56 technical indicators, and SEC filings. You describe what you want in English. The model writes and runs the SQL. No API key, no parsing code, fair-use limits only.

This page compares the two approaches honestly, shows side-by-side code examples, and provides a migration checklist for common yfinance patterns. Shibui is not a drop-in replacement for everything yfinance does. If you need real-time data or options chains, yfinance is still the right tool. For historical analysis, screening, and multi-table queries, MCP is more reliable and requires less code.

Why yfinance breaks

yfinance does not use an official Yahoo Finance API. It reverse-engineers Yahoo's web endpoints and scrapes the responses. This works until Yahoo changes something, which happens regularly.

  • API changes. Yahoo has broken yfinance multiple times by changing endpoint URLs, response formats, or authentication requirements. The yfinance library maintainers fix these, but there is always a gap between the breakage and the patch. If your pipeline runs daily, one broken morning means missing data.
  • Rate limiting. Yahoo throttles requests from the same IP. Downloading data for hundreds of tickers in a loop triggers 429 errors or silent data truncation. Workarounds (delays, proxy rotation) add complexity and fragility.
  • Inconsistent data. Identical yfinance calls sometimes return different values across runs. Adjusted close prices shift retroactively. Fundamentals fields vary by ticker. Error handling for missing data is the caller's problem.
  • No cross-table queries. Getting a stock's price, P/E ratio, RSI, and insider transactions requires four separate yfinance calls (or a mix of yfinance and other libraries), manual joining by ticker, and custom error handling at each step.

None of this means yfinance is bad. It is free, well-maintained, and works for quick lookups. But it was not built for production pipelines that need to run reliably every day, and it was not designed for multi-table analysis.

What yfinance does that Shibui does not

Before showing what Shibui adds, here is what you lose by switching. If any of these are critical to your workflow, yfinance (or a dedicated real-time API) is the right tool for that part.

  • Real-time and intraday data. yfinance provides intraday candles (1m, 5m, 15m, 1h) and near-real-time quotes. Shibui is end-of-day only with roughly a one-day lag.
  • Options chains. yfinance exposes full options data (calls, puts, strikes, Greeks). Shibui has no options data.
  • Mutual funds and ETF holdings. yfinance covers mutual fund NAVs and ETF constituent holdings. Shibui covers ETF prices and financials but not constituent breakdowns.
  • International markets. yfinance covers global exchanges. Shibui is US equities and ETFs only (NYSE and NASDAQ).
  • Direct Python DataFrame output. yfinance returns pandas DataFrames you can manipulate immediately. Shibui returns natural language results or structured data (JSON, CSV) through Claude, which you then parse.

For workflows that mix real-time data with historical analysis, a hybrid approach works: use yfinance or a real-time API for live quotes, and Shibui for historical screening and multi-table analysis.

What Shibui does that yfinance cannot

These are capabilities that yfinance does not support at all, not features where Shibui is simply better at the same thing.

  • Cross-table queries in one pass. Join daily prices with quarterly financials, technical indicators, valuations, and SEC insider transactions in a single query. yfinance requires separate calls and manual joining.
  • 64 years of daily price history. Shibui has OHLCV data back to 1962 (31 million rows). yfinance typically returns 5 years of daily data, with max_period="max" coverage varying by ticker.
  • 56 pre-computed technical indicators. RSI, MACD, Bollinger Bands, SMA/EMA at multiple periods, ADX, ATR, and more, calculated daily for every ticker. yfinance provides raw OHLCV only. You compute indicators yourself with ta-lib or pandas.
  • SEC insider transactions. Forms 3/4/5 with buy/sell signal flags, cluster buying detection, and transaction values. yfinance has no insider data.
  • SEC filing metadata. 6.4 million filings across 342 form types. Query by company, form type, date range, or 8-K item code. yfinance has no SEC filing access.
  • Natural language interface. Describe what you want in English. The model writes the SQL. No library syntax to learn, no code to maintain when the schema changes.
  • Fair-use limits, not per-request quotas. A typical research session stays well under them. No proxy rotation, no scraping workarounds.

Side-by-side: yfinance code vs. MCP prompt

Simple: last 30 days of AAPL prices

yfinance (5 lines):

import yfinance as yf

data = yf.download("AAPL", period="1mo")
print(data[["Close", "Volume"]].tail(10))

MCP (one sentence):

Prompt

"Show AAPL's closing price and volume for the last 30 trading days."

For a single ticker lookup, yfinance is concise and returns a DataFrame you can plot immediately. The MCP approach is simpler to write but the output is text or JSON, not a DataFrame. For one-off lookups, yfinance wins on ergonomics.

Medium: compare P/E ratios across 5 tech stocks

yfinance (20+ lines):

import yfinance as yf
import pandas as pd

tickers = ["AAPL", "MSFT", "GOOGL", "META", "NVDA"]
results = []

for t in tickers:
    try:
        stock = yf.Ticker(t)
        info = stock.info
        results.append({
            "symbol": t,
            "market_cap": info.get("marketCap"),
            "trailing_pe": info.get("trailingPE"),
            "forward_pe": info.get("forwardPE"),
        })
    except Exception as e:
        print(f"Error fetching {t}: {e}")

df = pd.DataFrame(results)
print(df.sort_values("market_cap", ascending=False))

MCP (one sentence):

Prompt

"Compare AAPL, MSFT, GOOGL, META, and NVDA: show market cap, trailing P/E, and forward P/E. Sort by market cap descending."

The yfinance version requires a loop, per-ticker error handling, and manual DataFrame construction. The info dictionary has inconsistent keys across tickers, so .get() with fallbacks is necessary. The MCP version is one prompt that joins valuation and fundamentals_derived_daily data in a single query.

Complex: insider buying where RSI is below 30

yfinance: not possible in one library.

# yfinance has no insider transaction data.
# You would need:
# 1. SEC EDGAR API for insider filings (separate library)
# 2. yfinance for prices (to compute RSI manually)
# 3. ta-lib or pandas for RSI calculation
# 4. Manual join across all three data sources
# 5. Error handling at each step
#
# Estimated: 50-80 lines of Python across 3 data sources.

MCP (one sentence):

Prompt

"Find stocks where at least one insider bought shares worth over $100K in the last 30 days, the current RSI is below 30, and market cap is above $1B. Show the insider name, transaction value, RSI, and trailing P/E."

This query joins three tables (insider transactions, technical indicators, and valuations) in a single pass across 10,000+ securities. In yfinance, this is not a difficult problem. It is an impossible one, because yfinance has no insider data. You would need to pull from SEC EDGAR separately, compute RSI yourself, and write the join logic manually.

Free, no API key, works on all Claude plans.

Connect now →

How to connect

The MCP endpoint is https://mcp.shibui.finance/mcp. Full connection instructions for Claude Code, Claude web, ChatGPT, and other MCP clients are in the automated screener setup guide. The short version for Claude Code:

claude mcp add shibui-finance --transport streamable-http https://mcp.shibui.finance/mcp

Once connected, you can run queries interactively or schedule them to run daily. For structured output (JSON, CSV), see the output format guide.

Migration checklist

Common yfinance patterns and their MCP equivalents. Items marked "not available" have no Shibui equivalent. Consider a hybrid approach (yfinance for those, Shibui for the rest) if you need them.

yfinance pattern MCP equivalent Notes
yf.download("AAPL", period="1y") "Get AAPL daily prices for the last year" 64 years of history available
ticker.financials "Show AAPL's last 4 quarterly income statements" Also covers balance sheet and cash flow
ticker.info["marketCap"] "What is AAPL's current market cap?" Daily market cap history back to 1993
ticker.info["trailingPE"] "Show AAPL's trailing P/E" Available via fundamentals_derived_daily
ticker.dividends "Show AAPL's dividend history" Cash flow dividends_paid field
ticker.insider_transactions "Show insider transactions for AAPL in the last 90 days" SEC Forms 3/4/5 with signal flags
ticker.recommendations Partial: analyst EPS estimates available No buy/sell/hold ratings
ticker.options Not available Use yfinance or a dedicated options API
yf.download(tickers, period="1d") (real-time) Not available Shibui is end-of-day only
RSI, MACD, SMA (manual calc with ta-lib) "Show AAPL's RSI, MACD, and 50-day SMA" 56 indicators pre-computed daily

How it compares to other yfinance alternatives

If you are moving away from yfinance, these are the main alternatives. For a deeper comparison of financial data APIs specifically, see the financial data API guide.

Feature yfinance Shibui MCP Alpha Vantage Polygon Twelve Data
Price Free Free Free (limited) $29+/mo Free (limited)
Real-time data Yes No (EOD) 15-min delay Yes Yes
Historical depth ~5 years 64 years 20 years 5+ years 30 years
Fundamentals Basic (.info dict) Full quarterly/annual Limited Limited Limited
Pre-computed technicals No (manual calc) 56 indicators Yes No Yes
Cross-table queries No (manual joins) Built-in No No No
Rate limits Unofficial, throttled Fair use 5-25/min Varies by plan 8/min free
Auth required No No API key API key API key
Interface Python library Natural language (MCP) REST API REST API REST API

For more MCP-specific comparisons, see Shibui vs Alpha Vantage MCP. For the full feature list or data coverage, see those pages.

Limitations: Shibui provides end-of-day US equity and ETF data with roughly a one-day lag. No intraday, no real-time, no options, no international markets. If your workflow needs any of those, yfinance or a dedicated API covers them. Full coverage details on the data sources page. This is a data tool, not financial advice.

Frequently asked questions

Is there a free alternative to yfinance?

Yes. Shibui Finance is a free MCP server with 10,000+ US equities, 64 years of daily prices, quarterly financials, 56 technical indicators, and SEC filings. No API key, no scraping, fair-use limits only. Connect via Claude, ChatGPT, or any MCP-compatible client. For other alternatives, see the financial data API comparison.

Can I use Shibui Finance from Python?

Yes. Connect via Claude Code (claude mcp add shibui-finance --transport streamable-http https://mcp.shibui.finance/mcp) and run queries with claude -p. The output can be piped to a file as JSON or CSV. You can also connect any MCP client library in Python to the same endpoint for programmatic access. See the connection guide for details.

Does Shibui have real-time or intraday data?

No. Shibui provides end-of-day data with roughly a one-day lag. If you need real-time quotes, intraday candles, or streaming prices, yfinance or a real-time API like Polygon is the right tool. Shibui is built for historical analysis, screening, and research that works on daily resolution.

What data does Shibui have that yfinance doesn't?

64 years of daily prices (vs. ~5 in yfinance), full quarterly and annual financial statements back to 1993, 56 pre-computed technical indicators, daily valuations with market cap and P/E history, SEC insider transactions (Forms 3/4/5), 6.4 million SEC filing records, and analyst estimates. All pre-joined and queryable in one pass. Full details on the data sources page.

Does this work with ChatGPT or only Claude?

Works with any MCP-compatible client: Claude (web, desktop, Code), ChatGPT, Codex, and custom agents. Connect via streamable HTTP transport to https://mcp.shibui.finance/mcp. See ChatGPT setup or Claude setup for step-by-step instructions.

How often is Shibui data updated?

Daily. Prices, technicals, and valuations update after US market close. Fundamentals update within days of earnings releases. SEC filings update every 5 minutes from the EDGAR feed.

Connect Shibui to Claude in 2 minutes

Shibui is free. Connect it to Claude, ChatGPT, or any MCP-compatible client and start querying 64 years of US market data.

Connect to Claude →