Financial Datasets

官方

專為AI代理設計的股市API

你可以用 Financial Datasets MCP 做什麼?

  • 擷取損益表 — 使用 get_income_statements 取得公司的損益表。
  • 擷取資產負債表 — 使用 get_balance_sheets 取得公司的資產負債表。
  • 擷取現金流量表 — 使用 get_cash_flow_statements 取得公司的現金流量表。
  • 取得當前股票或加密貨幣價格 — 透過 get_current_stock_priceget_current_crypto_price 查詢某標的的最新價格。
  • 取得歷史股票或加密貨幣價格 — 使用 get_historical_stock_pricesget_historical_crypto_prices 拉取指定日期範圍的歷史價格資料。
  • 取得公司新聞 — 使用 get_company_news 擷取公司的最新新聞文章。

文件

Financial Datasets MCP 伺服器

簡介

這是一個模型上下文協定 (Model Context Protocol, MCP) 伺服器,可透過 Financial Datasets 提供股票市場資料的存取。

它允許 Claude 和其他 AI 助理直接透過 MCP 介面擷取損益表、資產負債表、現金流量表、股票價格和市場新聞。

可用工具

此 MCP 伺服器提供以下工具:

  • get_income_statements:取得公司的損益表。
  • get_balance_sheets:取得公司的資產負債表。
  • get_cash_flow_statements:取得公司的現金流量表。
  • get_current_stock_price:取得公司目前/最新的價格。
  • get_historical_stock_prices:取得公司的歷史股價。
  • get_company_news:取得公司的新聞。
  • get_available_crypto_tickers:取得所有可用的加密貨幣代碼。
  • get_crypto_prices:取得加密貨幣的歷史價格。
  • get_historical_crypto_prices:取得加密貨幣的歷史價格。
  • get_current_crypto_price:取得加密貨幣目前/最新的價格。

設定

先決條件

  • Python 3.10 或更高版本
  • uv 套件管理器

安裝

  1. 複製此儲存庫:

    git clone https://github.com/financial-datasets/mcp-server
    cd mcp-server
    
  2. 如果您尚未安裝 uv,請安裝它:

    # macOS/Linux
    curl -LsSf https://astral.sh/uv/install.sh | sh
    
    # Windows
    curl -LsSf https://astral.sh/uv/install.ps1 | powershell
    
  3. 安裝相依套件:

    # Create virtual env and activate it
    uv venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
    # Install dependencies
    uv add "mcp[cli]" httpx  # On Windows: uv add mcp[cli] httpx
    
    
  4. 設定環境變數:

    # Create .env file for your API keys
    cp .env.example .env
    
    # Set API key in .env
    FINANCIAL_DATASETS_API_KEY=your-financial-datasets-api-key
    
  5. 執行伺服器:

    uv run server.py
    

連接到 Claude Desktop

  1. 如果您尚未安裝,請安裝 Claude Desktop

  2. 建立或編輯 Claude Desktop 設定檔:

    # macOS
    mkdir -p ~/Library/Application\ Support/Claude/
    nano ~/Library/Application\ Support/Claude/claude_desktop_config.json
    
  3. 新增以下設定:

    {
      "mcpServers": {
        "financial-datasets": {
          "command": "/path/to/uv",
          "args": [
            "--directory",
            "/absolute/path/to/financial-datasets-mcp",
            "run",
            "server.py"
          ]
        }
      }
    }
    

    /path/to/uv 替換為 which uv 的結果,並將 /absolute/path/to/financial-datasets-mcp 替換為此專案的絕對路徑。

  4. 重新啟動 Claude Desktop

  5. 您現在應該可以在 Claude Desktop 的工具選單(鎚子圖示)中看到這些財務工具

  6. 嘗試向 Claude 提出以下問題:

    • 「Apple 最近的損益表是什麼?」
    • 「顯示 Tesla 股票的目前價格」
    • 「取得 MSFT 從 2024-01-01 到 2024-12-31 的歷史價格」