Robinhood Mcp Server

by rohitsingh-iitd

442 downloads
Not rated
GitHub

About

The Robinhood MCP Server provides a comprehensive interface to the Robinhood Crypto API. This server handles authentication, account management, market data retrieval, and trading operations through both REST API and WebSocket interfaces.

Details

Author
rohitsingh-iitd
Downloads
442
Categories
Finance

- REST API for account info, market data, and trading
- WebSocket server for real-time market data and order updates
- Rate limiting and input validation for security
- Configurable host, port, logging, and debug mode
- Ping/pong keep‑alive mechanism for WebSocket connections

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Robinhood Mcp Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install dependencies, configure environment variables (ROBINHOOD_API_KEY and ROBINHOOD_PRIVATE_KEY) in a .env file, then start the server with python -m src.main. The server exposes REST API endpoints on port 8000 and a WebSocket server on port 8001.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "robinhood mcp server": {
            "robinhood": {
                "command": "docker",
                "args": [
                    "run",
                    "-i",
                    "--rm",
                    "-p",
                    "8000:8000",
                    "-p",
                    "8001:8001",
                    "-e",
                    "ROBINHOOD_API_KEY",
                    "-e",
                    "ROBINHOOD_PRIVATE_KEY",
                    "-e",
                    "HOST=0.0.0.0",
                    "-e",
                    "PORT=8000",
                    "-e",
                    "DEBUG=False",
                    "-e",
                    "LOG_LEVEL=INFO",
                    "-e",
                    "RATE_LIMIT_ENABLED=True",
                    "-e",
                    "RATE_LIMIT_REQUESTS=100",
                    "-e",
                    "RATE_LIMIT_PERIOD=60",
                    "robinhood-mcp-server"
                ],
                "env": {
                    "ROBINHOOD_API_KEY": "<YOUR_API_KEY>",
                    "ROBINHOOD_PRIVATE_KEY": "<YOUR_BASE64_ENCODED_PRIVATE_KEY>"
                }
            }
        }
    }
}

McpServers

{
    "robinhood": {
        "command": "docker",
        "args": [
            "run",
            "-i",
            "--rm",
            "-p",
            "8000:8000",
            "-p",
            "8001:8001",
            "-e",
            "ROBINHOOD_API_KEY",
            "-e",
            "ROBINHOOD_PRIVATE_KEY",
            "-e",
            "HOST=0.0.0.0",
            "-e",
            "PORT=8000",
            "-e",
            "DEBUG=False",
            "-e",
            "LOG_LEVEL=INFO",
            "-e",
            "RATE_LIMIT_ENABLED=True",
            "-e",
            "RATE_LIMIT_REQUESTS=100",
            "-e",
            "RATE_LIMIT_PERIOD=60",
            "robinhood-mcp-server"
        ],
        "env": {
            "ROBINHOOD_API_KEY": "<YOUR_API_KEY>",
            "ROBINHOOD_PRIVATE_KEY": "<YOUR_BASE64_ENCODED_PRIVATE_KEY>"
        }
    }
}

Robinhood MCP Server - User Guide

Overview

The Robinhood MCP Server provides a comprehensive interface to the Robinhood Crypto API. This server handles authentication, account management, market data retrieval, and trading operations through both REST API and WebSocket interfaces.

Installation

Prerequisites

- Python 3.8 or higher
- pip (Python package manager)

Setup

1. Clone or download the repository:

   git clone https://github.com/rohitsingh-iitd/robinhood-mcp-server
cd robinhood-mcp-server

2. Install dependencies:

   pip install -r requirements.txt

3. Configure environment variables:
- Copy .env.example to .env
- Edit .env and add your Robinhood API credentials:

     ROBINHOOD_API_KEY=your_api_key_here
ROBINHOOD_PRIVATE_KEY=your_base64_encoded_private_key_here

Running the Server

Start the server with the following command:

python -m src.main

This will start both the REST API server (default port 8000) and the WebSocket server (default port 8001).

REST API Endpoints

Authentication

- GET /auth/status - Check authentication status

Account

- GET /account - Get account information
- GET /account/holdings - Get account holdings (optional query param: asset_code)

Market Data

- GET /market/best-price - Get best bid/ask price (optional query param: symbol)
- GET /market/estimated-price - Get estimated price for quantity (required query params: symbol, side, quantity)

Trading

- GET /trading/pairs - Get available trading pairs (optional query param: symbol)
- GET /trading/orders - Get order history (optional query param: status)
- GET /trading/orders/{id} - Get order details
- POST /trading/orders - Place a new order
- Required fields: symbol, side, quantity
- Optional fields: type, price, time_in_force, stop_price
- DELETE /trading/orders/{id} - Cancel an order

WebSocket API

The WebSocket server provides real-time updates for market data and order status.

Connection

Connect to the WebSocket server at:

ws://localhost:8001

Market Data Subscription

Subscribe to market data updates:

{
"type": "market_data",
"action": "subscribe",
"symbols": ["BTC-USD", "ETH-USD"]
}

Unsubscribe from market data updates:

{
"type": "market_data",
"action": "unsubscribe",
"symbols": ["BTC-USD", "ETH-USD"]
}

Order Updates Subscription

Subscribe to order updates:

{
"type": "orders",
"action": "subscribe"
}

Unsubscribe from order updates:

{
"type": "orders",
"action": "unsubscribe"
}

Ping/Pong

Send a ping to keep the connection alive:

{
"type": "ping"
}

The server will respond with:

{
"type": "pong"
}

Testing

Run the validation tests to ensure the server is working correctly:

python -m tests.test_server

Configuration Options

The following environment variables can be configured in the .env file:

- ROBINHOOD_API_KEY - Your Robinhood API key
- ROBINHOOD_PRIVATE_KEY - Your base64-encoded private key
- HOST - Server host (default: 0.0.0.0)
- PORT - REST API server port (default: 8000)
- DEBUG - Enable debug mode (default: False)
- LOG_LEVEL - Logging level (default: INFO)
- LOG_FILE - Log file path (default: robinhood_mcp_server.log)
- RATE_LIMIT_ENABLED - Enable rate limiting (default: True)
- RATE_LIMIT_REQUESTS - Maximum requests per period (default: 100)
- RATE_LIMIT_PERIOD - Rate limit period in seconds (default: 60)

Security Considerations

- API keys and secrets are stored in environment variables, never in code
- All sensitive data is properly handled
- Input validation is implemented for all API endpoints
- Rate limiting is enforced to prevent abuse
- Proper error handling to avoid leaking sensitive information

Troubleshooting

If you encounter issues:

1. Check the log file for detailed error messages
2. Verify your API credentials are correct
3. Ensure you have proper network connectivity
4. Check that the Robinhood API is available

License

This project is licensed under the MIT License - see the LICENSE file for details.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.