alpaca-mcp-server
Model Context Protocol (MCP) server for Alpaca trading API
Documentation
Alpaca MCP Server
This is a Model Context Protocol (MCP) server for Alpaca, allowing LLMs like Claude to interact with the Alpaca trading API. It enables trading stocks, checking positions, fetching market data, and managing your account - all through natural language.
Features
- ๐ Alpaca Documentation - Access Alpaca SDK documentation to build
- ๐ Market Data - Get real-time stock quotes and historical price data
- ๐ต Account Information - Check your balances, buying power, and status
- ๐ Position Management - View current positions and their performance
- ๐ Order Placement - Place market and limit orders through natural language
- ๐ Order Management - List, track, and cancel orders
Prerequisites
- Python 3.10+
- Alpaca API keys
- Claude for Desktop or another MCP client
Installation
1. Clone this repository:
git clone https://github.com/YOUR_USERNAME/alpaca-mcp.git
cd alpaca-mcp2. Install the required packages:
pip install mcp alpaca-py python-dotenv3. Create a `.env` file with your Alpaca API credentials:
API_KEY_ID=your_alpaca_api_key
API_SECRET_KEY=your_alpaca_secret_keyUsage
Running the server
Start the server by running:
python alpaca_mcp_server.pyConfiguring Claude for Desktop
1. Open Claude for Desktop
2. Go to Settings
3. Click on "Developer" and then "Edit Config"
4. Add the server configuration to `claude_desktop_config.json`:
{
"mcpServers": {
"alpaca": {
"command": "python",
"args": [
"/path/to/alpaca_mcp_server.py"
],
"env": {
"API_KEY_ID": "your_alpaca_api_key",
"API_SECRET_KEY": "your_alpaca_secret_key"
}
}
}
}5. Save and restart Claude for Desktop
Available Tools
The server exposes the following tools:
- `get_account_info()` - Get account balances and status
- `get_positions()` - List all current positions in the portfolio
- `get_stock_quote(symbol)` - Get the latest quote for a stock
- `get_stock_bars(symbol, days)` - Get historical price bars for a stock
- `get_orders(status, limit)` - List orders with specified status
- `place_market_order(symbol, side, quantity)` - Place a market order
- `place_limit_order(symbol, side, quantity, limit_price)` - Place a limit order
- `cancel_all_orders()` - Cancel all open orders
- `close_all_positions(cancel_orders)` - Close all open positions
Example Queries
Once the server is connected to Claude, you can ask questions like:
- "What's my current account balance and buying power?"
- "Show me my current positions"
- "Get the latest quote for AAPL"
- "Show me the price history for TSLA over the last 10 days"
- "Buy 5 shares of MSFT at market price"
- "Sell 10 shares of AMZN with a limit price of $130"
- "Cancel all my open orders"
Note
This server uses Alpaca's paper trading by default. To use real money trading, change `paper=True` to `paper=False` in the `TradingClient` initialization.
Security Notice
This MCP server will have access to your Alpaca account and can place real trades. Always review what Claude is suggesting before approving any trades.
License
MIT
Frequently asked questions
What is alpaca-mcp-server?
alpaca-mcp-server is Model Context Protocol (MCP) server for Alpaca trading API
How do I install alpaca-mcp-server?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is alpaca-mcp-server open source?
Yes โ it is hosted on GitHub at https://github.com/miguelyad26/alpaca-mcp-server and has 3 stars.
Related MCP tools
Cognee is the open-source AI memory platform for agents. Give your AI agents persistent long-term memory across sessions with a self-hosted knowledge graph engine.
Automate browser based workflows with AI
Hindsight: Agent Memory That Learns
A privacy-first app that strips AI watermarks from content you own.
Agent framework and applications built upon Qwen>=3.0, featuring Function Calling, MCP, Code Interpreter, RAG, Chrome extension, etc.
The power of Claude Code / GeminiCLI / CodexCLI + [Gemini / OpenAI / OpenRouter / Azure / Grok / Ollama / Custom Model / All Of The Above] working as one.
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP