Skip to main content
Glama
angeliaz

finance-data-mcp

by angeliaz

finance-data-mcp

A Model Context Protocol (MCP) server that provides unified financial data access across multiple markets and data sources.

Features

  • ๐Ÿ‡บ๐Ÿ‡ธ US / ETF: Alpha Vantage (primary) โ†’ yfinance (fallback)

  • ๐Ÿ‡จ๐Ÿ‡ณ A-share: Tushare (primary) โ†’ AKShare (fallback) โ†’ yfinance

  • ๐Ÿ‡ญ๐Ÿ‡ฐ HK stocks: AKShare (primary) โ†’ yfinance (fallback)

  • ๐Ÿ’ฑ FX rates: exchangerate-api โ†’ AKShare โ†’ Alpha Vantage โ†’ yfinance

  • ๐Ÿ”„ Automatic fallback across data sources on failure

  • ๐Ÿ”‘ Multi-key rotation for Alpha Vantage (extends daily quota)

  • ๐ŸŒ Proxy support for AKShare (useful when running overseas)

Related MCP server: Stock Data MCP Server

MCP Tools

Tool

Description

get_stock_price

Real-time stock price with market routing

get_financial_report

Income statement, balance sheet, cash flow

get_financial_summary

PE, PB, ROE, market cap, EPS, etc.

get_fx_rate

Currency exchange rates

Quick Start

1. Install dependencies

pip install -r requirements.txt

Note: Not all data sources are required. Install only what you need:

  • akshare โ€” for A-share and HK stocks

  • tushare โ€” for A-share (needs token, no IP restriction)

  • yfinance โ€” for all markets (fallback, no key needed)

  • requests โ€” required for Alpha Vantage

2. Configure environment

cp .env.example .env
# Edit .env with your API keys

3. Run the server

python finance_data_server.py

The server runs in stdio mode (standard MCP transport).

4. Configure in your MCP client

Example configuration for MCP clients:

{
  "mcpServers": {
    "finance-data": {
      "command": "python",
      "args": ["/path/to/finance-data-mcp/finance_data_server.py"],
      "env": {}
    }
  }
}

Environment Variables

Variable

Required

Description

ALPHAVANTAGE_API_KEYS

For US stocks

Comma-separated Alpha Vantage API keys

TUSHARE_TOKEN

For A-share

Tushare Pro API token

AKSHARE_PROXY

Optional

HTTP proxy for AKShare (format: http://user:pass@host:port)

Architecture

finance_data_server.py          # MCP Server entry point + MarketRouter
โ”œโ”€โ”€ datasources/
โ”‚   โ”œโ”€โ”€ alpha_vantage_adapter.py  # US/ETF stocks (Alpha Vantage API)
โ”‚   โ”œโ”€โ”€ akshare_adapter.py        # A-share / HK stocks (AKShare + East Money)
โ”‚   โ”œโ”€โ”€ tushare_adapter.py        # A-share stocks (Tushare Pro API)
โ”‚   โ””โ”€โ”€ yfinance_adapter.py       # All markets fallback (Yahoo Finance)
โ”œโ”€โ”€ alpha_vantage_client.py       # Alpha Vantage HTTP client
โ””โ”€โ”€ alpha_vantage_rate_limiter.py # Per-key rate limiting with persistence

Data Flow

MCP Client Request
       โ”‚
       โ–ผ
  MarketRouter (routes by market type)
       โ”‚
       โ”œโ”€ US/ETF โ”€โ”€โ†’ AlphaVantage โ†’ yfinance
       โ”œโ”€ A-share โ”€โ”€โ†’ Tushare โ†’ AKShare โ†’ yfinance
       โ””โ”€ HK โ”€โ”€โ”€โ”€โ”€โ”€โ†’ AKShare โ†’ yfinance

Standardized Output

All adapters return data in a unified format:

Price Response

{
  "symbol": "AAPL",
  "market": "US",
  "price": 185.50,
  "change": 2.30,
  "change_pct": 1.25,
  "volume": 52340000,
  "high": 186.20,
  "low": 183.10,
  "open": 183.80,
  "previous_close": 183.20,
  "currency": "USD",
  "source": "alpha_vantage"
}

Financial Report Response

{
  "symbol": "AAPL",
  "market": "US",
  "report_type": "income_statement",
  "period": "annual",
  "data": [
    {
      "period": "2024-09-30",
      "revenue": 391035000000,
      "net_income": 93736000000,
      "eps_basic": 6.11
    }
  ],
  "count": 5,
  "source": "alpha_vantage"
}

License

MIT

Related MCP Connectors

Related MCP Servers

  • F
    license
    D
    quality
    D
    maintenance
    Provides real-time stock data and AI-powered analysis for A-shares, Hong Kong stocks, and US stocks. Features sentiment analysis of financial news, deep research reports, and comprehensive market data through multiple integrated data sources.
    22
    174
    -
  • F
    license
    Not graded
    quality
    C
    maintenance
    Provides comprehensive stock market data across US, Hong Kong, and Chinese markets, combining real-time quotes, historical data, fundamentals, and financial statements from multiple sources including Yahoo Finance, Finnhub, Tushare, and Futu OpenAPI.
    -
  • A
    license
    B
    quality
    C
    maintenance
    Provides comprehensive data for A-shares, Hong Kong, and US stocks alongside cryptocurrency markets, supporting technical indicators, news, and financial statements. It features automatic failover across multiple data sources to ensure reliable access to real-time and historical market information.
    47
    34
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Unified real-time & historical market data API for Forex, stocks (US/HK/A-share), crypto, indices & precious metals. Tick, order book depth & K-line via REST + WebSocket. AI-native: MCP server, Skill & CLI.
    769
    MIT