Skip to main content

MCP server for yfinance

Project description

MCP Server YFinance

A Model Context Protocol (MCP) server that provides stock market data using YFinance.

Features

  • Get basic stock information (price, market cap, sector, etc.)
  • Fetch historical price data with customizable periods
  • Retrieve analyst recommendations
  • Download data for multiple stocks simultaneously
  • Access dividend history

Usage

This MCP server can be used with various LLM applications that support the Model Context Protocol:

  • Claude Desktop: Anthropic's desktop application for Claude
  • Cursor: AI-powered code editor with MCP support
  • Custom MCP clients: Any application implementing the MCP client specification

Usage with Claude Desktop

  1. Install Claude Desktop from https://claude.ai/download

  2. Open your Claude Desktop configuration:

    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  3. Add the following configuration:

{
  "mcpServers": {
    "yfinance": {
      "command": "uvx",
      "args": [
        "mcp-server-yfinance@latest"
      ]
    }
  }
}
  1. Restart Claude Desktop

Usage with VS Code

For quick installation, use one of the one-click installation buttons below:

Install with UVX in VS Code Install with UVX in VS Code Insiders

For manual installation, add the following JSON block to your User Settings (JSON) file in VS Code. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open Settings (JSON).

Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

Note that the mcp key is not needed in the .vscode/mcp.json file.

UVX

{
  "mcp": {
    "servers": {
      "yfinance": {
        "command": "uvx",
        "args": [
          "mcp-server-yfinance@latest"
        ]
      }
    }
  }
}

Available Tools

  1. get_stock_info(ticker: str)

    • Get basic information about a stock
    • Example: get_stock_info("AAPL")
  2. get_historical_data(ticker: str, period: str = "1mo", interval: str = "1d")

    • Get historical price data
    • Periods: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max
    • Intervals: 1m, 2m, 5m, 15m, 30m, 60m, 90m, 1h, 1d, 5d, 1wk, 1mo, 3mo
  3. get_recommendations(ticker: str)

    • Get analyst recommendations for a stock
  4. get_multiple_tickers(tickers: list[str], period: str = "1d")

    • Get data for multiple stocks at once
    • Example: get_multiple_tickers(["AAPL", "GOOGL"])
  5. get_dividends(ticker: str)

    • Get dividend history for a stock

Development

To test the MCP server locally, install the uvx and npx and run the following command:

npx @modelcontextprotocol/inspector uvx mcp-server-yfinance@latest

This command will start the MCP server and open the MCP Inspector in your default web browser. You can then interact with the server and test its functionality.

License

AGPLv3+ License - see LICENSE for details.

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Commit your changes
  4. Push to the branch
  5. Create a pull request

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

mcp_server_yfinance-0.1.0.dev38.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

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

mcp_server_yfinance-0.1.0.dev38-py3-none-any.whl (38.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_server_yfinance-0.1.0.dev38.tar.gz.

File metadata

File hashes

Hashes for mcp_server_yfinance-0.1.0.dev38.tar.gz
Algorithm Hash digest
SHA256 d84b7c4888db69725ba369620897f722407647bcafd697e1c766ec9dad3a47d5
MD5 33f967c6b37b1e060dbc80a5c1d20d86
BLAKE2b-256 9f31864c83328e9864c64e88aea6e55c7410ea7f9c58fbfdd703eb279cf961f0

See more details on using hashes here.

File details

Details for the file mcp_server_yfinance-0.1.0.dev38-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_server_yfinance-0.1.0.dev38-py3-none-any.whl
Algorithm Hash digest
SHA256 62628f9f85c69f64f2da531147cad6e4e3679ca706da588f1fc4a7726d78f9d3
MD5 22a084a351990f4bcb5ac395ecdb269f
BLAKE2b-256 f76716ad946f7ecbf487f8331425185fdaffa163f57c6a8c13986431d52b8ce7

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