EODHD MCP Server

EODHD MCP Server

Provides access to EODHD financial APIs for stock prices, earnings, fundamentals, and index components via MCP.

Category
访问服务器

README

EODHD MCP Server

Language: English | 日本語

A Model Context Protocol (MCP) server that provides access to EODHD financial APIs. This server enables Claude Code and other MCP clients to fetch stock prices, earnings data, fundamental information, and index components through a unified interface.

Features

  • Stock Price Data: Get historical End-of-Day (EOD) OHLCV data
  • Earnings Calendar: Access earnings announcement schedules and estimates
  • Fundamental Data: Retrieve comprehensive company financial metrics
  • Index Components: Get constituent information for market indices
  • Growth Metrics: Extract and analyze growth rate data
  • Volume Analysis: Retrieve average trading volume for specified periods and volume ratios

Available Tools

1. get_stock_price

Retrieve End-of-Day stock price data for any symbol.

Parameters:

  • symbol (required): Stock symbol (e.g., 'AAPL', 'MSFT')
  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format
  • exchange (optional): Exchange code (default: 'US')

2. get_earnings_calendar

Get earnings calendar information for specified date ranges and symbols.

Parameters:

  • from_date (optional): Start date in YYYY-MM-DD format
  • to_date (optional): End date in YYYY-MM-DD format
  • symbols (optional): Comma-separated list of symbols

3. get_fundamentals

Access comprehensive fundamental data for companies.

Parameters:

  • symbol (required): Stock symbol
  • exchange (optional): Exchange code (default: 'US')

4. get_index_components

Retrieve constituent information for market indices.

Parameters:

  • index_code (required): Index code (e.g., 'MID.INDX', 'SML.INDX')

5. get_growth_rates

Extract growth rate metrics from fundamental data.

Parameters:

  • symbol (required): Stock symbol
  • exchange (optional): Exchange code (default: 'US')

6. get_volume_averages

Calculate average trading volume for given periods (default 20 & 60 days) and return the 20/60-day volume ratio.

Parameters:

  • symbol (required): Stock symbol
  • periods (optional): Comma-separated list of periods (e.g., "10,20,60")
  • exchange (optional): Exchange code (default: 'US')

Examples:

get_volume_averages(symbol="AAPL")
get_volume_averages(symbol="TSLA", periods="10,30,90")

7. get_earnings_trend

Fetch earnings results for the past n years (default 2) and analyze whether EPS and revenue show an increasing, decreasing, or mixed trend.

Parameters:

  • symbol (required): Stock symbol
  • years (optional): Number of years to look back (default: 2)
  • exchange (optional): Exchange code (default: 'US')

Example:

get_earnings_trend(symbol="AAPL", years=2)

Installation

Prerequisites

  • Python 3.8 or higher
  • EODHD API key (sign up at eodhd.com)

Setup

  1. Clone and setup the project:
# Clone the repository
git clone <repository-url>
cd eodhd-mcp-server

# Create virtual environment
python -m venv venv

# Activate virtual environment
source venv/bin/activate  # On macOS/Linux
# or
venv\\Scripts\\activate     # On Windows

# Install dependencies
pip install -r requirements.txt

# Install the package in development mode
pip install -e .
  1. Configure environment variables:
# Copy the example environment file
cp .env.example .env

# Edit .env file and add your EODHD API key
EODHD_API_KEY=your_actual_api_key_here
  1. Test the installation:
# Test if the server starts correctly (press Ctrl+C to stop)
eodhd-mcp-server

# You should see output similar to:
# 2024-06-28 16:04:42,657 - eodhd_mcp_server.server - INFO - Starting EODHD MCP Server...
# 2024-06-28 16:04:42,657 - eodhd_mcp_server.server - INFO - Configuration loaded - API key configured: True

Usage

Running the MCP Server

The server runs as a stdio-based MCP server:

eodhd-mcp-server

Integration with Cursor

Add the server to your Cursor MCP configuration (~/.cursor/mcp.json):

{
  "mcpServers": {
    "eodhd": {
      "command": "/path/to/your/project/venv/bin/eodhd-mcp-server",
      "args": [],
      "cwd": "/path/to/your/project/eodhd-mcp-server",
      "env": {
        "EODHD_API_KEY": "your_api_key_here",
        "EODHD_BASE_URL": "https://eodhd.com/api",
        "REQUEST_TIMEOUT": "30",
        "MAX_RETRIES": "3",
        "RATE_LIMIT_DELAY": "0.1",
        "DEBUG": "false"
      }
    }
  }
}

Important Configuration Notes:

  • Replace /path/to/your/project/ with your actual project path
  • Use the absolute path to the eodhd-mcp-server executable in your virtual environment
  • Set the cwd (current working directory) to your project root
  • Include all necessary environment variables in the env section
  • Replace your_api_key_here with your actual EODHD API key

Alternative: Using .env file If you prefer to use a .env file (recommended for security), you can simplify the configuration:

{
  "mcpServers": {
    "eodhd": {
      "command": "/path/to/your/project/venv/bin/eodhd-mcp-server",
      "args": [],
      "cwd": "/path/to/your/project/eodhd-mcp-server"
    }
  }
}

Make sure your .env file contains all required environment variables.

Example Usage in Cursor

Once the MCP server is configured and running (green icon), you can use the tools in Cursor:

Stock Price Data:

  • "Get AAPL stock price for the last 30 days"
  • "Show me Tesla's stock performance this year"

Earnings Information:

  • "Show me earnings announcements for this week"
  • "Get AAPL's past 10 earnings results"

Fundamental Analysis:

  • "Get Microsoft's fundamental data"
  • "Show me growth rates for NVDA"

Index Components:

  • "What are the components of the S&P 500?"
  • "Show me the Russell 2000 holdings"

The server will automatically handle the API calls and return formatted, readable results.

Configuration

Environment Variables

  • EODHD_API_KEY: Your EODHD API key (required)
  • EODHD_BASE_URL: Base URL for EODHD API (default: https://eodhd.com/api)
  • REQUEST_TIMEOUT: Request timeout in seconds (default: 30)
  • MAX_RETRIES: Maximum retry attempts (default: 3)
  • RATE_LIMIT_DELAY: Delay between requests in seconds (default: 0.1)
  • DEBUG: Enable debug logging (default: false)

API Key

Get your free API key from EODHD:

  1. Sign up for an account
  2. Navigate to the API section
  3. Copy your API key
  4. Add it to your .env file

Error Handling

The server includes comprehensive error handling for:

  • API Errors: Invalid API keys, rate limits, data not found
  • Network Errors: Connection timeouts, network failures
  • Data Processing Errors: Invalid data formats, parsing failures
  • Configuration Errors: Missing API keys, invalid parameters

Development

Project Structure

eodhd-mcp-server/
├── src/eodhd_mcp_server/
│   ├── __init__.py          # Package initialization
│   ├── server.py            # Main MCP server with tools
│   ├── api_client.py        # EODHD API client
│   ├── data_processor.py    # Data processing utilities
│   ├── config.py            # Configuration management
│   └── exceptions.py        # Custom exceptions
├── tests/                   # Test files (to be implemented)
├── requirements.txt         # Python dependencies
├── pyproject.toml          # Package configuration
├── .env.example            # Example environment file
└── README.md               # This file

Running Tests

# Install test dependencies
pip install pytest pytest-asyncio

# Run tests
pytest tests/

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

API Compatibility

This server maintains compatibility with existing stocktrading codebase by:

  • Preserving DataFrame structures used in existing code
  • Maintaining consistent column names and data types
  • Supporting the same API response formats
  • Following established error handling patterns

Support the Project

If you find this project helpful, consider supporting its development:

Buy Me A Coffee

License

MIT License - see LICENSE file for details.

Troubleshooting

Red Icon in Cursor (Server Not Working)

If you see a red icon next to the EODHD MCP server in Cursor:

  1. Check Configuration Path: Ensure the command path points to the correct location:

    # Find the correct path
    source venv/bin/activate
    which eodhd-mcp-server
    
  2. Verify Environment Variables: Make sure your .env file exists and contains:

    EODHD_API_KEY=your_actual_api_key
    
  3. Test Server Manually: Try running the server directly:

    source venv/bin/activate
    eodhd-mcp-server
    
  4. Check Cursor Configuration: Ensure your ~/.cursor/mcp.json includes:

    • Absolute path to the executable
    • Correct working directory (cwd)
    • Environment variables or .env file access
  5. Restart Cursor: After configuration changes, completely restart Cursor.

Common Issues

  • API Key Issues: Verify your EODHD API key is valid and has sufficient quota
  • Path Issues: Use absolute paths in Cursor configuration
  • Permission Issues: Ensure the executable has proper permissions
  • Virtual Environment: Make sure you're using the correct virtual environment path

Support

For issues and questions:

  1. Check the EODHD API documentation
  2. Review error messages in debug mode (DEBUG=true)
  3. Use the troubleshooting guide above
  4. Open an issue in the repository

Changelog

Version 1.0.0

  • Initial release
  • Support for stock prices, earnings calendar, fundamentals, and index components
  • Comprehensive error handling and data processing
  • MCP protocol integration with FastMCP

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选