miguelyad26_alpaca-mcp-server
This is a Model Context Protocol (MCP) server for Alpaca, allowing LLMs like Claude to interact with the Alpaca trading API.
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
-
Clone this repository:
git clone https://github.com/YOUR_USERNAME/alpaca-mcp.git cd alpaca-mcp
-
Install the required packages:
pip install mcp alpaca-py python-dotenv
-
Create a
.env
file with your Alpaca API credentials:API_KEY_ID=your_alpaca_api_key API_SECRET_KEY=your_alpaca_secret_key
Usage
Running the server
Start the server by running:
python alpaca_mcp_server.py
Configuring Claude for Desktop
- Open Claude for Desktop
- Go to Settings
- Click on "Developer" and then "Edit Config"
- 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"
}
}
}
}
- Save and restart Claude for Desktop
Available Tools
The server exposes the following tools:
get_account_info()
- Get account balances and statusget_positions()
- List all current positions in the portfolioget_stock_quote(symbol)
- Get the latest quote for a stockget_stock_bars(symbol, days)
- Get historical price bars for a stockget_orders(status, limit)
- List orders with specified statusplace_market_order(symbol, side, quantity)
- Place a market orderplace_limit_order(symbol, side, quantity, limit_price)
- Place a limit ordercancel_all_orders()
- Cancel all open ordersclose_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
Related MCP Servers
View all finance servers →mcp-server
by financial-datasets
This is a Model Context Protocol (MCP) server that provides access to stock market data from Financial Datasets.
evm-mcp-server
by mcpdotdirect
A comprehensive Model Context Protocol (MCP) server that provides blockchain services across multiple EVM-compatible networks.
razorpay-mcp-server
by razorpay
The Razorpay MCP Server is a Model Context Protocol server that integrates with Razorpay APIs for advanced payment processing.
mcp-cn-a-stock
by elsejj
This is an MCP (Model Content Protocol) service providing A-share data for large models.
investor-agent
by ferdousbhai
The investor-agent is a Model Context Protocol server designed to provide comprehensive financial insights and analysis to Large Language Models.
mcp-trader
by wshobson
A Model Context Protocol (MCP) server designed for stock traders, offering a suite of tools for technical analysis and trading.
bsc-mcp
by TermiX-official
BNBChain MCP is a tool server designed for interacting with the Binance Smart Chain, enabling token transfers, smart contract interactions, and more, tailored for developers and AI agents.