E*TRADE MCP Server

E*TRADE MCP Server

Enables LLMs to retrieve real-time stock and options market data through the E\*TRADE API using natural language. It features secure OAuth 1.0 authentication, persistent token management, and comprehensive support for stock quotes, options chains, and Greeks.

Category
Visit Server

README

E*TRADE MCP Server

Model Context Protocol (MCP) server for E*TRADE API, enabling LLMs like Claude to retrieve stock and options market data.

Features

  • OAuth 1.0 Authentication - Secure, persistent token storage with automatic lifecycle management
  • Stock Quotes - Real-time and delayed stock quotes with optional earnings dates
  • Batch Quotes - Retrieve up to 25 stock quotes in a single request
  • Options Chains - Full options chain data with strikes, expirations, Greeks, and bid/ask
  • Options Quotes - Detailed quotes for specific option contracts
  • Automatic Retries - Built-in retry logic for handling API rate limits and token activation
  • MCP Integration - Seamless integration with Claude Desktop and other MCP clients

Prerequisites

Installation

1. Install uv (if not already installed)

# macOS/Linux
curl -LsSf https://astral.sh/uv/install.sh | sh

# Windows
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"

2. Clone and Setup Project

cd etrade-mcp

# Create virtual environment
uv venv

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

# Install dependencies
uv pip install -e .

3. Configure Environment

Create a .env file in the project root:

# Copy example file
cp .env.example .env

# Edit .env with your credentials

.env file:

ETRADE_CONSUMER_KEY=your_consumer_key_here
ETRADE_CONSUMER_SECRET=your_consumer_secret_here
ETRADE_ENVIRONMENT=sandbox  # Use 'production' for live trading

Important:

  • Start with sandbox environment for testing
  • Switch to production only after thorough testing
  • Production requires live E*TRADE brokerage account

OAuth Setup

OAuth authentication is handled automatically through the MCP server. When you first use the server with Claude, you'll be prompted to authorize:

  1. Claude will call the setup_oauth tool (no verification code needed initially)
  2. Your browser will open to the E*TRADE authorization page
  3. After authorizing, E*TRADE will display a 5-character verification code
  4. Provide the code to Claude, who will call setup_oauth again with the code
  5. Tokens are saved encrypted locally and automatically renewed

Alternatively, you can run the standalone OAuth setup:

python -m server.auth.setup

Running Tests

# Install dev dependencies
uv pip install -e ".[dev]"

# Run all tests
pytest

# Run with coverage
pytest --cov=server tests/

# Run specific test file
pytest tests/test_token_store.py -v

Claude Desktop Configuration

macOS: ~/Library/Application Support/Claude/claude_desktop_config.json Windows: %APPDATA%\Claude\claude_desktop_config.json

{
  "mcpServers": {
    "etrade": {
      "command": "python",
      "args": [
        "-m",
        "server.main"
      ],
      "cwd": "/absolute/path/to/etrade-mcp",
      "env": {
        "ETRADE_CONSUMER_KEY": "your_consumer_key",
        "ETRADE_CONSUMER_SECRET": "your_consumer_secret",
        "ETRADE_ENVIRONMENT": "sandbox"
      }
    }
  }
}

Replace /absolute/path/to/etrade-mcp with your actual project path and add your credentials.

Usage with Claude

Once configured, Claude can access E*TRADE data through natural language:

Stock Quotes:

  • "What's the current price of Apple stock?"
  • "Get quotes for AAPL, MSFT, and GOOGL with earnings dates"
  • "Show me the price and volume for TSLA"

Options Data:

  • "Show me the option chain for Tesla expiring in January 2025"
  • "What are the Greeks for AAPL calls at $180 strike?"
  • "Get the bid/ask spread for SPY weekly options near $450"
  • "Show me put options for NVDA expiring next month"

Available Tools

Authentication

setup_oauth - OAuth 1.0 authentication flow

  • Step 1: Call without verification_code to get authorization URL
  • Step 2: Call with verification_code (5 characters from E*TRADE) to complete auth
  • Tokens are automatically stored and managed

Stock Quotes

get_stock_quote - Get quote for a single stock

  • Input: symbol (e.g., "AAPL"), optional include_earnings (default: false)
  • Returns: Price, volume, bid/ask, change, and optionally next earnings date

get_batch_quotes - Get quotes for multiple stocks

  • Input: symbols (array, up to 25), optional include_earnings (default: false)
  • Returns: Quotes for all requested symbols

Options Data

get_option_chains - Get options chain data

  • Input: symbol, optional filters:
    • expiry_year, expiry_month, expiry_day - Filter by expiration date
    • chain_type - "CALL", "PUT", or "CALLPUT" (default)
    • strike_price_near - Get strikes near a specific price
    • no_of_strikes - Limit number of strikes returned
    • include_weekly - Include weekly options (default: false)
    • skip_adjusted - Skip adjusted options (default: true)
    • option_category - "STANDARD" (default), "ALL", or "MINI"
    • price_type - "ATNM" (at-the-money, default) or "ALL"
  • Returns: Available strikes, expirations, bid/ask, Greeks, open interest, volume

get_option_quote - Get specific option quotes

  • Input: option_symbols (array of OSI format symbols, up to 25)
  • Returns: Detailed option quote data including Greeks and theoretical values

Project Structure

etrade-mcp/
├── server/
│   ├── auth/
│   │   ├── oauth_manager.py    # OAuth session & token lifecycle
│   │   ├── token_store.py      # Encrypted token storage
│   │   └── setup.py            # Standalone OAuth setup
│   ├── tools/
│   │   ├── oauth_tools.py      # MCP OAuth tool
│   │   ├── stock_quotes.py     # Stock quote tools
│   │   └── options_quotes.py   # Options chain & quote tools
│   ├── utils/
│   │   └── retry.py            # Automatic retry logic
│   ├── config.py               # Configuration management
│   └── main.py                 # MCP server entry point
├── tests/
│   ├── test_token_store.py     # Token storage tests
│   └── test_auth.py            # OAuth manager tests
├── .env.example                # Example environment config
├── pyproject.toml              # Project metadata & dependencies
└── README.md

Development Status

✅ v0.1.0 - All Core Features Complete

Foundation

  • [x] Project setup with modern tooling (uv, pyproject.toml)
  • [x] Environment-based configuration management
  • [x] Encrypted token storage with lifecycle management
  • [x] OAuth 1.0 authentication flow
  • [x] Unit tests for auth components

Stock Market Data

  • [x] Single stock quote tool with earnings support
  • [x] Batch quotes (up to 25 symbols)
  • [x] Real-time and delayed quote handling

Options Data

  • [x] Options chains with comprehensive filtering
  • [x] Options quotes by OSI symbol
  • [x] Greeks, theoretical values, and open interest
  • [x] Support for standard, weekly, and mini options

MCP Integration

  • [x] Two-step OAuth flow via MCP tools
  • [x] Automatic retry logic for API rate limits
  • [x] Token activation delay handling
  • [x] Full integration with Claude Desktop

Quality & Reliability

  • [x] Comprehensive error handling
  • [x] Debug logging to file and stderr
  • [x] Automatic token renewal
  • [x] Production-ready for E*TRADE live accounts

Security Notes

  • Never commit .env file - Contains sensitive credentials
  • Tokens are encrypted - Stored in .etrade_tokens.enc
  • Use sandbox first - Test thoroughly before production
  • Environment variable for key - Set ETRADE_TOKEN_KEY in production

Troubleshooting

OAuth Setup Fails

  • Verify consumer key and secret are correct
  • Check you're using the right environment (sandbox/production)
  • Ensure your E*TRADE account has API access

"No tokens found" Error

  • Run python -m server.auth.setup to authenticate
  • Check .etrade_tokens.enc file exists
  • Verify ETRADE_TOKEN_KEY is consistent

Import Errors

  • Ensure virtual environment is activated
  • Run uv pip install -e . to install dependencies

Recent Improvements

Token Lifecycle Management (Latest)

  • Automatic token renewal on expiration
  • Graceful handling of token activation delays
  • Persistent session state across restarts

Enhanced Options Support

  • Full E*TRADE API spec compliance
  • Support for weekly and mini options
  • Flexible filtering by expiration and strike price
  • Complete Greeks and theoretical pricing data

Reliability Enhancements

  • Automatic retry logic for API rate limits
  • Exponential backoff for token activation
  • Comprehensive error handling and logging
  • Production-tested with live E*TRADE accounts

Resources

License

MIT

Contributing

Contributions welcome! Please:

  1. Follow test-driven development
  2. Add tests for new features
  3. Update documentation
  4. Test with sandbox environment first

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
E2B

E2B

Using MCP to run code via e2b.

Official
Featured