# Alpaca Trading MCP for AI Agents MCP

> Alpaca Trading gives your AI agent direct, programmatic access to real-time stock, crypto, and brokerage data. It lets you execute complex trades—placing market, limit, or stop orders—and manage account details without leaving your chat window. Use it to pull historical bars for backtesting, monitor live quotes, or check every order's status instantly.

## Overview
- **Category:** money-moves
- **Price:** Free
- **Tags:** algorithmic-trading, stock-market, crypto-trading, brokerage-api, market-data, financial-automation

## Description

Connect Alpaca Trading to your AI agent and automate everything from trade execution to deep market analysis. This MCP lets you treat your AI client like a sophisticated trading terminal capable of interacting with real brokerage accounts. Instead of manually logging into a dashboard, asking questions or running scripts in natural language sends commands directly to the exchange.

Need to know if shorting is allowed? Use one command. Need to place an order for 10 shares when the price hits $50? That’s another. The system handles the complexity behind the scenes. When you subscribe, you connect your specific Alpaca API keys and instantly get access to this entire suite of financial tools through Vinkius' catalog.

This means whether you're a retail investor checking portfolio status or a developer integrating live market data into an application, your agent acts as the central command post. You can retrieve historical quotes, check current asset availability, and manage account configurations—all conversational actions that used to require multiple logins and complex API calls.

## Tools

### create_broker_account
Initiates the process to set up a brand new brokerage account with Alpaca Markets.

### create_order
Places a specific trading order for stocks or crypto assets, defining the type and quantity.

### delete_all_orders
Cancels every single open order associated with your current account ID.

### get_assets
Lists all assets that are currently available and tradable on the Alpaca exchange platform.

### get_broker_account
Retrieves specific details about your brokerage account using its unique identifier.

### get_crypto_bars
Fetches historical price bars and data points specifically for cryptocurrency pairs.

### get_latest_stocks_quotes
Retrieves the most current bid and ask prices for specified stock tickers.

### get_latest_stocks_trades
Gets details on the most recent executed trades that have occurred in specific stocks.

### get_orders
Queries and lists all of your current and past orders, allowing for advanced filtering by status or time frame.

### get_stocks_bars
Retrieves historical price bars (OHLCV data) for specified stock tickers across different time periods.

### get_stocks_quotes
Gets historical quote records for stocks, useful for analyzing pricing patterns over time.

### get_stocks_trades
Retrieves a log of past executed trades (price and volume) for specific stock tickers.

### issue_token
Generates secure OAuth2 tokens necessary for automated machine-to-machine authentication.

### update_account_configs
Modifies various account settings, such as enabling or disabling fractional trading permissions.

## Prompt Examples

**Prompt:** 
```
What are the current latest quotes for AAPL and ETH?
```

**Response:** 
```
**Market Quotes (Real-Time)**

| Ticker | Asset | Bid Price | Ask Price |
| :--- | :--- | :---: | :---: |
| AAPL | Stock | $175.20 | $175.45 |
| ETH/USD | Crypto | $3,450.10 | $3,452.00 |

*These quotes are live and subject to immediate market change.*
```

**Prompt:** 
```
I want to buy 20 shares of TSLA when the price hits $180.
```

**Response:** 
```
**✅ Order Placed Successfully**

We've set up a limit order for 20 shares of TSLA.

*   **Type:** Limit Buy
*   **Target Price:** $180.00
*   **Status:** Pending
*   **Order ID:** 550e8400-e29b

You'll get an alert when the price hits this level.
```

**Prompt:** 
```
Show me all my closed orders from the last week.
```

**Response:** 
```
**📊 Closed Order Summary (Last 7 Days)**

You had 3 transactions:

*   **MSFT:** Bought 15 shares. Filled at $420.10.
*   **TSLA:** Sold 10 shares. Filled at $225.99.
*   **NVDA (Limit):** Bought 5 shares. Filled exactly at your set limit price of $880.00.
```

## Capabilities

### Execute and Manage Trades
Place new trading orders (market, limit, or stop) and clear all outstanding open orders with a single prompt.

### Retrieve Real-Time Market Data
Get the latest quotes, current trades, and historical bars for both stocks and cryptocurrencies.

### Monitor Order History
Query all your past and active orders using filters like status or symbols to track performance.

### Manage Account Configuration
Check your current brokerage account details and update settings, such as shorting permissions or fractional trading options.

## Use Cases

### Backtesting an old strategy
A quant researcher needs to test a volatile pattern from six months ago. Instead of writing complex code, they ask their agent for the historical data using `get_stocks_bars`, and the agent pulls the exact time series needed immediately.

### Reacting to breaking news
When a company announces unexpected earnings, the investor prompts their agent: 'What's the current quote for AAPL?' The agent uses `get_latest_stocks_quotes` and reports the live bid/ask spread instantly.

### Executing a complex multi-leg trade
The user dictates, 'I want to buy 10 shares of NVDA if it drops below $90.' The agent interprets this as a limit order and executes the setup using `create_order` without manual intervention.

### Checking all open positions before quitting for the day
The user simply asks, 'What orders are currently pending?' The agent runs `get_orders`, providing a clean summary of every active trade and its current status.

## Benefits

- You can place complex orders using `create_order` or cancel everything instantly with `delete_all_orders`, letting your agent handle the transaction logic.
- Track every trade's status, from open to closed, by querying your order history directly with `get_orders`. You always know what’s active.
- Analyze market trends quickly. Use `get_stocks_bars` or `get_crypto_bars` to pull historical data for immediate backtesting analysis.
- Get instant pricing updates on stocks via `get_latest_stocks_quotes`, so your agent can quote current values without needing a separate API call.
- Manage risk and compliance by checking and updating account rules using `update_account_configs` before running automated strategies.

## How It Works

The bottom line is that you're running complex financial operations using only conversation with your AI client.

1. Subscribe to this MCP and enter your required Alpaca API Key ID and Secret Key.
2. Your AI agent uses natural language instructions (e.g., 'Buy 5 shares of AAPL at market price') to determine the necessary action.
3. The system executes the command, returning confirmation details or requested market data directly into your chat.

## Frequently Asked Questions

**How do I use the Alpaca Trading MCP to place a trade?**
You simply tell your AI agent what you want to buy or sell, and how many shares. You don't need to worry about order types or syntax; the agent translates your natural language command into an executable trading instruction.

**Can this MCP help me analyze crypto data?**
Yes, it handles crypto just as well as stocks. You can retrieve historical price bars and get the latest quotes for major cryptocurrencies like Bitcoin or Ethereum, making deep market analysis possible.

**Is Alpaca Trading MCP safe to use for live trades?**
The MCP connects directly to your brokerage account using secure API keys. It ensures that every order you place is tracked and executed according to the rules of your connected Alpaca account.

**What if I need historical data for backtesting? Does Alpaca Trading support it?**
Absolutely. You can pull specific historical records, such as daily or hourly price bars, for any stock or crypto pair. This allows you to test trading strategies against real past market conditions.

**Does the MCP help me manage my account settings?**
Yes. If you need to change permissions, like enabling fractional shares or adjusting shorting limits, your agent can interact with your account configuration using simple commands.