Alpaca MCP Server

Alpaca MCP Server

A 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.

tedlikeskix

Finance
Visit Server

README

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

  • 📊 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-mcp
    
  2. Install the required packages:

    pip install mcp alpaca-py python-dotenv
    
  3. 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

  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"
      }
    }
  }
}
  1. 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

Recommended Servers

Crypto Price & Market Analysis MCP Server

Crypto Price & Market Analysis MCP Server

A Model Context Protocol (MCP) server that provides comprehensive cryptocurrency analysis using the CoinCap API. This server offers real-time price data, market analysis, and historical trends through an easy-to-use interface.

Featured
TypeScript
chromia-mcp

chromia-mcp

Enables AI to interact with Chromia Wallet for sending $CHR transactions.

Official
Local
TypeScript
TripleWhale MCP Server

TripleWhale MCP Server

An implementation of Model Context Protocol (MCP) that allows users to interact with TripleWhale's e-commerce analytics platform using natural language queries through Claude Desktop.

Official
Local
TypeScript
Adamik MCP Server

Adamik MCP Server

Enables read and write interactions with 60+ blockchain networks through Claude Desktop, providing a standardized multi-chain API for transaction management, account insights, staking, and token interactions.

Official
Local
TypeScript
Open-Ledger-MCP-Server

Open-Ledger-MCP-Server

A Model Context Protocol (MCP) server implementation for the OpenLedger API. This server provides structured context to AI models according to the MCP specification.

Official
TypeScript
ntropy-mcp MCP Server

ntropy-mcp MCP Server

Enables enriching banking data with the Ntropy API, providing tools to create account holders and enrich transactions efficiently.

Official
Python
Iaptic MCP Server

Iaptic MCP Server

A server for interacting with the Iaptic API, allowing AI models like Claude to query customer, purchase, and transaction data, as well as retrieve statistical insights.

Official
TypeScript
Bitrefill Search and Shop

Bitrefill Search and Shop

This MCP wraps Bitrefill public API to allow agents to search for products and shop using cryptocurrencies like Bitcoin, Ethereum, Solana, and many more.

Official
TypeScript
MCP EVM Signer

MCP EVM Signer

A server that securely manages Ethereum private keys locally and enables Claude for Desktop to interact with EVM-compatible blockchains through Infura.

Local
TypeScript
Cryptocurrency Daemon MCP Server

Cryptocurrency Daemon MCP Server

Enables secure interactions with cryptocurrency daemon RPC interfaces through AI assistants, supporting transaction management, wallet operations, and daemon monitoring for Bitcoin-derived cryptocurrencies.

Local
TypeScript