Supports environment variable configuration through .env files for storing Alpaca API credentials securely.
Offers repository access for cloning the server code, with support for issues tracking and contribution workflows.
Verified compatibility with macOS running on Apple Silicon M1 Pro hardware.
Uses Python to run the MCP server, enabling access to Alpaca's trading functionality through Python scripts and applications.
Alpaca MCP Server
A Model Context Protocol (MCP) server for Alpaca Trading API that provides seamless integration with AI assistants and development tools.
✅ Compatibility
Tested and verified to work on Apple Silicon M1 Pro laptops running macOS.
Features
- Account Information: Get real-time account details, buying power, equity, and status
- Portfolio Management: View current positions with P&L tracking
- Market Data: Retrieve real-time stock quotes with bid/ask spreads
- Order Management: List and monitor recent orders
- Paper Trading Support: Safe testing environment with paper trading API
- Live Trading Ready: Compatible with live trading (use with caution)
Installation
Prerequisites
Quick Start
- Clone the repository:
- Set up your Alpaca API credentials:
Create environment variables or add to your shell profile:
- Test the server:
MCP Integration
For Cline/Claude Dev Tools
Add to your MCP settings JSON:
For Claude Desktop
Add to your claude_desktop_config.json
:
Available Tools
1. get_account
Get comprehensive account information including:
- Account status and number
- Buying power and cash available
- Portfolio equity and value
- Pattern day trader status
- Day trade count
- SMA (Special Memorandum Account)
2. get_positions
View current stock positions with:
- Symbol and quantity
- Current market value
- Cost basis and P&L
- Unrealized gains/losses
- Current stock price
- Position side (long/short)
3. get_quote
Get real-time market quotes for any symbol:
- Bid and ask prices
- Bid and ask sizes
- Price spread calculation
- Timestamp of quote
Parameters:
symbol
(required): Stock symbol (e.g., "AAPL", "TSLA", "NVDA")
4. get_orders
List recent orders with filtering:
- Order ID and status
- Symbol and quantity
- Order type and side
- Fill information
- Submission timestamps
Parameters:
status
(optional): "open", "closed", or "all" (default: "all")limit
(optional): Maximum number of orders (default: 10)
API Credentials
Getting Alpaca API Keys
- Sign up at Alpaca Markets
- Go to the dashboard and navigate to "API Keys"
- Generate new API keys for paper trading or live trading
- Copy your API Key ID and Secret Key
Environment Setup
Option 1: Environment Variables
Option 2: .env file
Safety and Paper Trading
⚠️ Important: This server defaults to paper trading mode for safety. Paper trading uses virtual money and is perfect for testing and development.
To switch to live trading, change the base URL to:
Use live trading only when you're confident in your setup and ready to trade with real money.
Troubleshooting
Common Issues
- "Missing API credentials" error:
- Ensure environment variables are set correctly
- Check that variable names match exactly:
APCA_API_KEY_ID
,APCA_API_SECRET_KEY
- "Connection failed" error:
- Verify your API keys are valid
- Check your internet connection
- Ensure you're using the correct base URL for paper/live trading
- "Module not found" error:
- Install required dependencies:
pip install alpaca-trade-api
- Install required dependencies:
Testing the Server
You can test the server manually using JSON-RPC:
Expected response should include available tools.
Development
Project Structure
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly with paper trading
- Submit a pull request
License
MIT License - see LICENSE file for details.
Support
- Issues: GitHub Issues
- Alpaca API Docs: Alpaca Markets API
- MCP Protocol: Model Context Protocol
Disclaimer
This software is for educational and development purposes. When using live trading features, you are trading with real money. Always test thoroughly with paper trading first. The authors are not responsible for any financial losses.
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Provides tools for interacting with the Alpaca Trading API, enabling trading operations like getting account information, placing/canceling orders, listing positions, and accessing market data.
Related MCP Servers
- AsecurityAlicenseAqualityEnables interaction with MercadoLibre's API for product search, reviews, descriptions, and seller reputation insights.Last updated -4546TypeScriptMIT License
- -securityAlicense-qualityA Model Context Protocol server enabling LLMs like Claude to interact with the Alpaca trading API through natural language for stock trading, checking positions, fetching market data, and managing your account.Last updated -PythonMIT License
- -securityAlicense-qualityA Model Context Protocol server that enables LLMs like Claude to interact with the Alpaca trading API, allowing for trading stocks, checking positions, fetching market data, and managing accounts through natural language.Last updated -PythonMIT License
- AsecurityAlicenseAqualityAllows AI assistants to seamlessly interact with Terminal.shop to browse products, manage shopping carts, place orders, and handle subscriptions through Terminal.shop's API.Last updated -19101JavaScriptMIT License