Robinhood MCP Server
Provides a comprehensive interface to the Robinhood Crypto API for account management, market data retrieval, and trading operations via REST and WebSocket.
README
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.
Table of Contents
- Features
- Prerequisites
- Installation
- Configuration
- Running the Server
- API Documentation
- Testing
- Development
- Security
- Troubleshooting
- License
- Disclaimer
Features
- REST API for account management and trading operations
- WebSocket support for real-time market data and order updates
- Comprehensive error handling and logging
- Rate limiting and security best practices
- Easy configuration via environment variables
Prerequisites
- Python 3.8 or higher
- pip (Python package manager)
- Robinhood API credentials
Installation
-
Clone the repository:
git clone https://github.com/rohitsingh-iitd/robinhood-mcp-server cd robinhood-mcp-server -
Set up a virtual environment (recommended):
# Create a virtual environment python -m venv venv # Activate the virtual environment # On macOS/Linux: source venv/bin/activate # On Windows: # .\venv\Scripts\activate -
Install dependencies:
pip install -r requirements.txt
Configuration
-
Create a
.envfile in the project root with the following content:# Required ROBINHOOD_API_KEY=your_api_key_here ROBINHOOD_PRIVATE_KEY=your_base64_encoded_private_key_here # Optional (with defaults) HOST=0.0.0.0 PORT=8000 WEBSOCKET_PORT=8001 DEBUG=False LOG_LEVEL=INFO LOG_FILE=robinhood_mcp_server.log RATE_LIMIT_ENABLED=True RATE_LIMIT_REQUESTS=100 RATE_LIMIT_PERIOD=60 -
Replace the placeholder values with your actual Robinhood API credentials.
Running the Server
Start the server with the following command:
python -m src.main
This will start:
- REST API server at
http://localhost:8000 - WebSocket server at
ws://localhost:8001
Running in Production
For production use, consider using a production-grade ASGI server like Uvicorn with Gunicorn:
pip install gunicorn uvicorn[standard]
gunicorn src.main:app --worker-class uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000
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 informationGET /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 detailsPOST /trading/orders- Place a new order- Required fields:
symbol,side,quantity - Optional fields:
type,price,time_in_force,stop_price
- Required fields:
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 keyROBINHOOD_PRIVATE_KEY- Your base64-encoded private keyHOST- 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:
- Check the log file for detailed error messages
- Verify your API credentials are correct
- Ensure you have proper network connectivity
- Check that the Robinhood API is available
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
The author is not responsible for any loss or damage that may occur as a result of using this project.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
