robinhood-options-mobile

Robinhood Model Context Protocol (MCP) Integration

RealizeAlpha integrates a highly secure, local Model Context Protocol (MCP) execution framework powered by package:mcp_dart. This integration enables conversational generative models (specifically Gemini 3.1 Flash-Lite) to interact natively with your active Robinhood trading accounts on-device without exposing private tokens, brokerage API credentials, or trading secrets to untrusted remote cloud environments.


1. Architectural Design & Security Flow

The app establishes a local client-driven JSON-RPC channel with the secure sandbox server endpoints. Unlike typical SaaS tools that process client data remotely, this architecture keeps all token exchanges, request composition, and validation steps on-device.

Data Flow Diagram

sequenceDiagram
    participant User as User
    box On-Device Mobile Sandbox
    participant App as Chat Screen (chat_widget)
    participant Gen as Generative Service
    end
    box Secure Networks
    participant API as Robinhood Brokerage API
    participant AI as Remote Gemini LLM
    end

    User->>App: Submits chat prompt: "What are my current holdings?"
    App->>Gen: Sends query to chat processing pipeline
    Gen->>Gen: Initiates local MCP Client connection using logged-in token
    Gen->>Gen: Queries list of dynamic tools from local transport
    Gen->>AI: Sends system prompt of tools and user message
    AI-->>Gen: Returns JSON function call request for `list_positions`
    Gen-->>App: Dispatches visual indicator "Calling Tool list_positions..."
    Gen->>Gen: Executes tool natively via `mcp_client.callTool('list_positions')`
    Gen->>API: Sends authorized on-device fetch requests
    API-->>Gen: Returns raw JSON array of positions and margins
    Gen->>AI: Serializes raw results and appends to prompt conversation stream
    AI-->>Gen: Responds with comprehensive text report about holdings
    Gen->>App: Parses proposals, strips system tags, and renders report
    App->>User: Displays text card with interactive trading recommendations

2. Integrated Webview OAuth Authentication Flow

To authorized local trading capabilities, users can prompt an OAuth authentication screen from within their User Settings.


3. Robinhood MCP Tools Reference

The Model Context Protocol server exposes high-fidelity tools dynamically mapped for LLM execution, providing perfect parity with top-tier quantitative and brokerage platforms.

Account & Portfolio Tools

get_accounts

Lists the user’s connected brokerage accounts detailing account numbers, profile type (e.g. margin, cash, options), and agentic suitability status.

get_portfolio

Retrieves a detailed real-time market value breakdown by asset class, cash balance, margin requirements, custody hold boundaries, and buying power.


Watchlist Management Tools

get_watchlists

Lists the user’s custom and followed watchlists.

get_watchlist_items

Lists all tracked securities configured inside a designated user watchlist.

create_watchlist

Creates a brand new custom watchlist for the user.

update_watchlist

Modifies the display details of a custom watchlist.

add_to_watchlist

Appends assets directly into a target watchlist. Exactly one of symbols, currency_pair_ids, or index_ids is required.

remove_from_watchlist

Removes assets from a designated watchlist. Exactly one of symbols, currency_pair_ids, or index_ids is required.

follow_watchlist

Displays a curated pre-existing Robinhood list under the user’s watchlists.

unfollow_watchlist

Stops displaying a followed curated list under details lists.

Discovers popular curated market sectors or collections to browse or follow.

get_option_watchlist

Queries single-leg options contracts stored on the user’s options watchlist.

add_option_to_watchlist

Adds single-leg options contracts to the options watchlist.


Options Market & Orders Tools

get_option_instruments

Retrieves options contracts matching specific underlying tickers, expiration schedules, strikes, and call/put directions.

get_option_quotes

Fetch real-time option market quotes and prices for a set of options contract instrument UUIDs.

get_option_positions

Fetches a list of active options legs, multi-leg spreads, or single contracts.

get_option_orders

Fetches a history list of options trades, filled positions, or cancelled order entries for a portfolio.

review_option_order

Simulates an options contract transaction to retrieve fees, collateral metrics, and pre-trade rules check.

place_option_order

Executes single-leg or complex multi-leg options strategies.

cancel_option_order

Submits a secure cancel request for an active, pending options transaction.


Equity Market & Orders Tools

get_equity_positions

Fetches a list of active equity, ETF, and mutual fund holdings.

get_equity_quotes

Fetch real-time quoted figures for underlying equity instruments.

get_equity_historicals

Retrieves historical price data candles for equities.

get_equity_orders

Fetches historical stock orders, trades, and pending items.

get_equity_fundamentals

Retrieves comprehensive daily fundamental metrics and ratios for one or more stock symbols.

get_equity_tradability

Checks detailed eligibility and fractional trading status constraints for a set of stock symbols under a specified account.

review_equity_order

Simulates a stock, ETF, or trust order without executing it, returning pre-trade warnings, cash costs, and margin impact.

place_equity_order

Constructs and logs trade transactions directly with the broker.


Market Indices & Calendars

get_index_quotes

Fetch real-time values, stamps, and state changes for major indices.

get_earnings_calendar

Discovers macro earnings schedules across the entire market over a given date range.

get_earnings_results

Retrieves detailed corporate earnings history, EPS surprise statistics, and report timings for a single ticker.


Scans & Market Screening Tools

create_scan

Creates a brand new saved scanner configuration on the user’s account, allowing custom dynamic filters to parse the market.

get_scans

Lists all saved market scanners and screeners registered.

run_scan

Executes an existing pre-registered market screener evaluation against live realtime quote aggregates.


4. UI Tracing & Execution Visualboards

As Gemini process requests, the conversational interface inside src/robinhood_options_mobile/lib/widgets/chat_widget.dart provides deep visual tracking:

  1. Tool Execution Trace Cards: Renders individual ToolExecutionCard widgets revealing precisely what tools were called and what parameters were populated.
  2. Collapsible JSON Log Inspector: Users can toggle expanders to inspect the exact input arguments and raw returned responses, pretty-print JSON metrics, or copy details to clipboard.
  3. Active Progress Chips: Displays state indicators like Calling local tool list_accounts... to maintain user awareness of model actions in real-time.

5. Conversational Proposals & Quick Checkout

When Gemini detects a programmatic order request, it formats responses utilizing structured proposal blocks:

Our chat widget automatically intercepts these proposal patterns before compiling message bubbles, transforming the raw text blocks into elegant Interactive Proposal Card overlays.