Yahoo Finance

Un servidor MCP para consultar datos de Yahoo Finance utilizando la biblioteca yfinance.

Documentación

Servidor MCP de Yahoo Finance

Este proyecto proporciona un servidor de Protocolo de Contexto de Modelo (MCP) que expone varias funciones de la biblioteca yfinance como herramientas individuales. Esto permite que un cliente MCP (como Claude Desktop) consulte datos de Yahoo Finance.

Requisitos previos

  • Python: Asegúrate de tener Python instalado (se recomienda Python 3.8+).
  • uv: Este proyecto utiliza uv para la gestión de entornos y paquetes. Si no lo tienes, instálalo siguiendo las instrucciones aquí: https://github.com/astral-sh/uv

Configuración

  1. Clona el repositorio:

    git clone git@github.com:a05031113/yahoo-fianace-mcp.git
    cd yahoo-finance # Or your repository directory name
    
  2. Crea un entorno virtual: Es muy recomendable utilizar un entorno virtual. Crea uno usando uv:

    uv venv
    

    Esto creará un directorio .venv.

  3. Activa el entorno virtual:

    • En macOS/Linux:
      source .venv/bin/activate
      
    • En Windows (Git Bash/WSL):
      source .venv/Scripts/activate
      
    • En Windows (Símbolo del sistema/PowerShell):
      .venv\Scripts\activate
      

    Deberías ver (.venv) al principio del prompt de tu terminal.

  4. Instala las dependencias: Instala los paquetes de Python requeridos usando uv:

    uv pip install -r requirements.txt
    

Ejecutar el servidor

Este servidor se comunica a través de entrada/salida estándar (stdio) como espera MCP. Para ejecutar el servidor, simplemente ejecuta el script main.py usando el intérprete de Python de tu entorno virtual activado:

python main.py

El servidor se iniciará e imprimirá mensajes de registro en el error estándar (stderr), esperando solicitudes JSON-RPC en la entrada estándar (stdin).

Normalmente configurarías tu cliente MCP (por ejemplo, en su archivo JSON de configuración) para ejecutar este comando:

{
  "mcpServers": {
    "yahoo_finance_engine": {
      "command": "/path/to/your/yahoo-finance/.venv/bin/python", // Adjust path accordingly
      "args": [
        "/path/to/your/yahoo-finance/main.py" // Adjust path accordingly
      ]
    }
    // ... other servers
  }
}

El cliente MCP gestionará entonces el inicio y la comunicación con este proceso del servidor.

Herramientas disponibles

El servidor expone los métodos públicos de la clase YahooFinance (definida en src/tool.py) como herramientas MCP individuales. Estas incluyen (pero no se limitan a):

  • get_current_stock_price(symbol: str)
  • get_stock_price_by_date(symbol: str, date: str)
  • get_stock_price_date_range(symbol: str, start_date: str, end_date: str)
  • get_historical_stock_prices(symbol: str, period: str = "1mo", interval: str = "1d")
  • get_dividends(symbol: str)
  • get_income_statement(symbol: str, freq: str = "yearly")
  • get_cashflow(symbol: str, freq: str = "yearly")
  • get_balance_sheet(symbol: str, freq: str = "yearly")
  • get_earning_dates(symbol: str, limit: int = 12)
  • get_news(symbol: str)
  • get_company_info(symbol: str)
  • get_splits(symbol: str)
  • get_recommendations(symbol: str)
  • get_analyst_price_targets(symbol: str)
  • get_major_holders(symbol: str)
  • get_institutional_holders(symbol: str)
  • get_mutualfund_holders(symbol: str)
  • get_option_expiration_dates(symbol: str)
  • get_option_chain(symbol: str, date: str)
  • get_sustainability(symbol: str)

Consulta las cadenas de documentación dentro de main.py o src/tool.py para obtener detalles sobre los parámetros de cada herramienta.

Certificado por Revisión MCP. https://mcpreview.com/mcp-servers/a05031113/yahoo-fianace-mcp