Skip to main content
Glama
thetadata-mcp

thetadata-mcp

by drmartell

Theta Data MCP Server

A local MCP (Model Context Protocol) wrapper for the Theta Data API, providing AI models with access to real-time and historic stock, options, and index data.

Overview

This MCP server is generated from the Theta Data OpenAPI specification using FastMCP. It exposes API endpoints as MCP tools, allowing AI assistants to query market data directly.

Supported Data Types

  • Stocks: Symbols, EOD data, OHLC, trades, quotes, snapshots

  • Options: Symbols, expirations, strikes, contracts, Greeks, implied volatility

  • Indices: Symbols, prices, OHLC, market values

  • Calendar: Market open dates

Related MCP server: siftingio-mcp

Prerequisites

  1. Python 3.10+

  2. uv for package management

  3. Theta Data terminal running locally (default: http://127.0.0.1:25503)

  4. A Theta Data subscription (subscribe here)

Installation

# Create virtual environment and install all dependencies (including dev)
uv sync

Usage

Running the Server

# Run with stdio transport (default)
uv run server.py

# Run with SSE transport
uv run server.py --transport sse

# Custom base URL
uv run server.py --base-url http://localhost:25503/v3

# Custom timeout
uv run server.py --timeout 60.0

Environment Variables

Variable

Description

Default

THETADATA_BASE_URL

Theta Data API base URL

http://127.0.0.1:25503/v3

THETADATA_TIMEOUT

Request timeout in seconds

30.0

MCP Client Configuration

Add the following to your MCP client config, replacing /path/to/thetadata-mcp with the actual path to this repository:

{
  "mcpServers": {
    "thetadata": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/thetadata-mcp",
        "run",
        "server.py"
      ],
      "env": {
        "THETADATA_BASE_URL": "http://127.0.0.1:25503/v3",
        "THETADATA_TIMEOUT": "30.0"
      }
    }
  }
}

Available Tools

The server exposes all Theta Data v3 API endpoints as MCP tools, including:

Stock Data

  • stock_list_symbols - List all stock symbols

  • stock_list_dates - List available dates for a request type

  • stock_snapshot_ohlc - Real-time OHLC data

  • stock_snapshot_trade - Real-time trade data

  • stock_snapshot_quote - Real-time quote data

  • stock_history_eod - Historic EOD data

  • stock_history_ohlc - Historic OHLC bars

  • stock_history_trade - Historic trade data

  • stock_history_quote - Historic quote data

Options Data

  • option_list_symbols - List optionable symbols

  • option_list_expirations - List expirations for a symbol

  • option_list_strikes - List strikes for an expiration

  • option_list_contracts - List option contracts

  • option_snapshot_ohlc - Real-time option OHLC

  • option_snapshot_greeks_all - All Greeks (delta, gamma, theta, vega, rho)

  • option_snapshot_greeks_implied_volatility - Implied volatility

  • option_history_eod - Historic option EOD data

  • option_history_greeks_all - Historic Greeks data

Index Data

  • index_list_symbols - List index symbols

  • index_snapshot_price - Real-time index prices

  • index_history_eod - Historic index EOD data

Calendar

  • calendar_open_today - Check if market is open today

  • calendar_on_date - Check if market is open on a specific date

See the Theta Data API documentation for full details on parameters and responses.

Example Queries

Once connected to an MCP client, you can ask:

  • "List all available stock symbols"

  • "Get the current OHLC data for AAPL"

  • "What are the available option expirations for SPY?"

  • "Show me the Greeks for the SPY 500 call expiring next Friday"

  • "Is the market open today?"

Development

Pre-commit Hooks

This project uses pre-commit to run ruff linting and formatting automatically on every commit.

Setup (one-time per clone):

uv run pre-commit install

The hook will now automatically check and fix code formatting when you commit changes.

Manual Development Commands

# Run linting with uv
uv run ruff check .

# Format code with uv
uv run ruff format .

# Regenerate endpoints_by_subscription documentation
uv run python generate_endpoint_docs.py

Regenerating Endpoint Documentation

The generate_endpoint_docs.py script reads the x-min-subscription field from openapiv3_updated.yaml and regenerates the markdown files in endpoints_by_subscription/. Each tier file shows all endpoints available at that subscription level and below (cumulative):

  • endpoints_free.md - Free tier endpoints

  • endpoints_value.md - Free + Value tier endpoints

  • endpoints_standard.md - Free + Value + Standard tier endpoints

  • endpoints_professional.md - All endpoints

License

MIT License - See LICENSE file for details.

Resources

Available Tools

59 tools
calendar_on_dateC

[VALUE] Equity market schedule for a given date.

Inputs: date (required).

calendar_open_todayB

[FREE] Current day equity market schedule.

Inputs: no named parameters.

calendar_yearC

[VALUE] Equity market holidays for a given year.

Inputs: year (required).

index_at_time_priceC

[VALUE] Index price at a specific time of day.

Inputs: symbol (required), time_of_day (required), end_date, start_date.

index_history_eodB

[FREE] End-of-day report for an index. Generated at 17:15 ET daily.

Inputs: symbol (required), end_date, start_date.

index_history_ohlcC

[STANDARD] Historical OHLC bars for an index.

Inputs: symbol (required), interval (required), end_date, end_time, +2 more.

index_history_priceC

[VALUE] Historical price reports for an index. Max 1 month per request.

Inputs: symbol (required), interval (required), date, end_date, +3 more.

index_list_datesC

[FREE] List available data dates for an index by request type and symbol.

Inputs: symbol (required).

index_list_symbolsA

[FREE] List all index symbols. Updated overnight.

Inputs: no named parameters.

index_snapshot_market_valueC

[STANDARD] Real-time market value for an index.

Inputs: symbol (required), min_time.

index_snapshot_ohlcB

[STANDARD] Real-time current-day OHLC for an index.

Inputs: symbol (required), min_time.

index_snapshot_priceB

[STANDARD] Real-time last price for an index.

Inputs: symbol (required), min_time.

option_at_time_quoteC

[VALUE] Last option NBBO quote at a specific time of day.

Inputs: symbol (required), expiration (required), time_of_day (required), right, +5 more.

option_at_time_tradeC

[STANDARD] Last option trade at a specific time of day.

Inputs: symbol (required), expiration (required), time_of_day (required), right, +5 more.

option_history_eodC

[FREE] End-of-day report for options. Generated at 17:15 ET daily.

Inputs: symbol (required), expiration (required), right, strike, +4 more.

option_history_greeks_allC

[PROFESSIONAL] Historical greeks (all orders) from midpoint prices. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +11 more.

option_history_greeks_eodB

[STANDARD] EOD greeks for all contracts by symbol and expiration. Use expiration=* for all.

Inputs: symbol (required), expiration (required), right, strike, +9 more.

option_history_greeks_first_orderB

[STANDARD] Historical first-order greeks from midpoint prices. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +11 more.

option_history_greeks_implied_volatilityC

[STANDARD] Historical IV from bid, mid, and ask prices. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +11 more.

option_history_greeks_second_orderA

[PROFESSIONAL] Historical second-order greeks from midpoint prices. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +11 more.

option_history_greeks_third_orderB

[PROFESSIONAL] Historical third-order greeks from midpoint prices. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +11 more.

option_history_ohlcA

[VALUE] Historical OHLC bars for options. Max 1 month per request.

Inputs: symbol (required), interval (required), expiration (required), date, +7 more.

option_history_open_interestA

[VALUE] Historical open interest for options. Reported ~06:30 ET, reflects prior day.

Inputs: symbol (required), expiration (required), date, right, +5 more.

option_history_quoteC

[VALUE] NBBO quote history for options. Supports interval aggregation. Max 1 month, requires expiration.

Inputs: symbol (required), interval (required), expiration (required), date, +8 more.

option_history_tradeB

[STANDARD] Tick-level trade history for options. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +7 more.

option_history_trade_greeks_allB

[PROFESSIONAL] Greeks calculated at each trade. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +11 more.

option_history_trade_greeks_first_orderB

[PROFESSIONAL] First-order greeks at each trade. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +11 more.

option_history_trade_greeks_implied_volatilityC

[PROFESSIONAL] IV calculated at each trade. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +11 more.

option_history_trade_greeks_second_orderB

[PROFESSIONAL] Second-order greeks at each trade. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +11 more.

option_history_trade_greeks_third_orderA

[PROFESSIONAL] Third-order greeks at each trade. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +11 more.

option_history_trade_quoteA

[STANDARD] Trade history paired with contemporaneous NBBO quotes for options. Max 1 month, requires expiration.

Inputs: symbol (required), expiration (required), date, right, +8 more.

option_list_contractsA

[VALUE] List contracts traded or quoted on a date. Supports symbol filtering. Real-time.

Inputs: date (required), request_type (required), symbol, max_dte.

option_list_datesA

[FREE] List available data dates for an option by symbol, request type, and expiration.

Inputs: symbol (required), expiration (required), request_type (required), right, +1 more.

option_list_expirationsA

[FREE] List available expiration dates for an option symbol. Updated overnight.

Inputs: symbol (required).

option_list_strikesA

[FREE] List available strikes for an option symbol and expiration. Updated overnight.

Inputs: symbol (required), expiration (required).

option_list_symbolsA

[FREE] List all traded option underlying symbols. Updated overnight.

Inputs: no named parameters.

option_snapshot_greeks_allC

[PROFESSIONAL] Real-time greeks for all contracts on an expiration. Use expiration=* for all.

Inputs: symbol (required), expiration (required), right, strike, +8 more.

option_snapshot_greeks_first_orderC

[STANDARD] Real-time first-order greeks (delta, gamma, theta, vega, rho) for all contracts on an expiration.

Inputs: symbol (required), expiration (required), right, strike, +8 more.

option_snapshot_greeks_implied_volatilityC

[STANDARD] Real-time implied volatility from bid, mid, and ask prices.

Inputs: symbol (required), expiration (required), right, strike, +8 more.

option_snapshot_greeks_second_orderC

[PROFESSIONAL] Real-time second-order greeks for all contracts on an expiration.

Inputs: symbol (required), expiration (required), right, strike, +8 more.

option_snapshot_greeks_third_orderC

[PROFESSIONAL] Real-time third-order greeks for all contracts on an expiration.

Inputs: symbol (required), expiration (required), right, strike, +8 more.

option_snapshot_market_valueC

[STANDARD] Real-time market value from last NBBO quote for an option contract.

Inputs: symbol (required), expiration (required), right, strike, +3 more.

option_snapshot_ohlcB

[VALUE] Real-time current-day OHLC for an option contract.

Inputs: symbol (required), expiration (required), right, strike, +3 more.

option_snapshot_open_interestA

[VALUE] Last open interest for an option contract. Reported ~06:30 ET daily.

Inputs: symbol (required), expiration (required), right, strike, +3 more.

option_snapshot_quoteC

[VALUE] Real-time last NBBO quote for an option contract.

Inputs: symbol (required), expiration (required), right, strike, +3 more.

option_snapshot_tradeC

[STANDARD] Real-time last trade for an option contract.

Inputs: symbol (required), expiration (required), right, strike, +2 more.

stock_at_time_quoteC

[VALUE] Last quote at a specific time of day for a stock.

Inputs: symbol (required), time_of_day (required), venue, end_date, +1 more.

stock_at_time_tradeB

[STANDARD] Last trade at a specific time of day for a stock.

Inputs: symbol (required), time_of_day (required), venue, end_date, +1 more.

stock_history_eodC

[FREE] End-of-day report for a stock. Generated at 17:15 ET daily.

Inputs: symbol (required), end_date, start_date.

stock_history_ohlcC

[VALUE] Historical OHLC bars for a stock. Max 1 month per request.

Inputs: symbol (required), interval (required), date, venue, +4 more.

stock_history_quoteB

[VALUE] NBBO quote history for a stock. Supports interval aggregation. Max 1 month per request.

Inputs: symbol (required), interval (required), date, venue, +4 more.

stock_history_tradeA

[STANDARD] Tick-level trade history for a stock. Max 1 month per request.

Inputs: symbol (required), date, venue, end_date, +3 more.

stock_history_trade_quoteC

[STANDARD] Trade history paired with contemporaneous BBO quotes. Max 1 month per request.

Inputs: symbol (required), date, venue, end_date, +4 more.

stock_list_datesB

[FREE] List available data dates for a stock by request type and symbol.

Inputs: symbol (required), request_type (required).

stock_list_symbolsA

[FREE] List all traded stock symbols. Updated overnight.

Inputs: no named parameters.

stock_snapshot_market_valueB

[STANDARD] Real-time market value derived from last quote for a stock.

Inputs: symbol (required), venue, min_time.

stock_snapshot_ohlcB

[VALUE] Real-time current-day OHLC for a stock.

Inputs: symbol (required), venue, min_time.

stock_snapshot_quoteB

[VALUE] Real-time last BBO/NBBO quote for a stock.

Inputs: symbol (required), venue, min_time.

stock_snapshot_tradeC

[STANDARD] Real-time last trade for a stock.

Inputs: symbol (required), venue, min_time.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3.2/5.0

    Scored across 59 tools

    Disambiguation5/5

    Each tool follows a clear pattern of asset class (stock/option/index), data type (list/snapshot/history/at_time), and specific metric (ohlc/trade/quote/greeks/etc.), making them easily distinguishable. Even the many greeks tools are differentiated by order and trade vs. snapshot.

    Naming Consistency5/5

    All tool names use a consistent lowercase_with_underscores convention and a predictable structure (e.g., stock_snapshot_ohlc, option_history_trade_greeks_first_order). No mixed conventions or arbitrary verbs.

    Tool Count1/5

    With 59 tools, the server far exceeds even the 'too many' threshold of 25+. While the granularity may reflect the data API's breadth, it creates an overwhelming selection burden for agents and would benefit from consolidation or parameterization.

    Completeness5/5

    The tool surface comprehensively covers listing, real-time snapshots, historical data, at-time queries, greeks, and market calendar information across stocks, options, and indices. No obvious dead ends for typical market data workflows.

    Related MCP Connectors

    Related MCP Servers

    • -
      license
      Not graded
      quality
      Not graded
      maintenance
      Real-time financial market data MCP server. Stocks, crypto, technicals, sentiment, FDA calendar. No API keys required.
      -
    • A
      license
      A
      quality
      C
      maintenance
      MCP server that provides access to SiftingIO market data, including live prices, SEC filings, OHLCV bars, 13F holdings, market status, and economic calendar tools for AI assistants.
      36
      46 npm
      1
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      MCP server that exposes QuantXData's institutional crypto market data APIs to AI assistants, enabling natural language queries for trades, order books, OHLCV, options, and more across 120+ exchanges.
      12
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol (MCP) server that provides access to Alpha Vantage financial data APIs. This server enables AI assistants to fetch real-time and historical financial market data including stock prices, forex rates, cryptocurrency data, and various technical indicators.
      11 npm
      MIT