Alpaca MCP Server
A Model Context Protocol (MCP) server that provides tools for interacting with the Alpaca Trading API.
Features
This MCP server provides the following tools:
- get_account - Get account information and buying power
- list_positions - List all current positions
- list_orders - List orders with optional status filter
- place_order - Place a new order (market/limit/stop/stop_limit)
- cancel_order - Cancel an existing order
- get_asset - Get information about a specific asset
- get_latest_trade - Get latest trade for a symbol
- get_latest_quote - Get latest quote for a symbol
- get_bars - Get historical price bars
Installation
- Clone this repository
- Install dependencies:
- Build the server:
Configuration
The server requires the following environment variables:
ALPACA_API_KEY
- Your Alpaca API keyALPACA_SECRET_KEY
- Your Alpaca secret keyALPACA_BASE_URL
- API base URL (optional, defaults to paper trading URL)
MCP Settings Configuration
Add the following to your MCP settings file:
{
"mcpServers": {
"alpaca": {
"command": "node",
"args": ["/path/to/alpaca-server/build/index.js"],
"env": {
"ALPACA_API_KEY": "your-api-key",
"ALPACA_SECRET_KEY": "your-secret-key",
"ALPACA_BASE_URL": "https://paper-api.alpaca.markets"
}
}
}
}
Usage Examples
{
"tool": "get_account",
"arguments": {}
}
Place a Market Order
{
"tool": "place_order",
"arguments": {
"symbol": "AAPL",
"qty": 10,
"side": "buy",
"type": "market"
}
}
Get Latest Quote
{
"tool": "get_latest_quote",
"arguments": {
"symbol": "AAPL"
}
}
Development
- Run in watch mode:
npm run watch
- Run tests:
npm test
- Lint code:
npm run lint
License
MIT