TA

tedlikeskix/alpaca-mcp-server

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

28 stars 21 forks Качество 66 Тренд 0MIT

Сервер Model Context Protocol (MCP) для Alpaca Trading API

Обзор

Это сервер Model Context Protocol (MCP) для Alpaca, позволяющий LLM-системам, таким как Claude, взаимодействовать с торговым API Alpaca. Он позволяет торговать акциями, проверять позиции, получать рыночные данные и управлять своей учетной записью - на естественном языке. - - - Получите котировки акций в режиме реального времени и исторические данные о ценах - - - Проверьте свои балансы, покупательную способность и статус - - - Просмотрите текущие позиции и их производительность - - - Разместите рыночные и лимитные ордера на естественном языке - - - Список, отслеживайте и отменяйте заказы Python 3.10+ - API-ключи Alpaca - Claude для рабочего стола или другого MCP-клиента 3. Создайте файл .env с вашими учетными данными API Alpaca: 1.Откройте Клод для рабочего стола 2. Перейдите в Настройки 3. Нажмите «Разработчик», а затем «Редактировать конфигурацию» 4. Добавить конфигурацию сервера в claude desktop config.

Обзор (машинный перевод)

Это сервер Model Context Protocol (MCP) для Alpaca, позволяющий LLM-системам, таким как Claude, взаимодействовать с торговым API Alpaca. Он позволяет торговать акциями, проверять позиции, получать рыночные данные и управлять своей учетной записью - на естественном языке.

Особенности

        • Данные рынка * * - Получите котировки акций в реальном времени и исторические данные о ценах ** Информация о счете** - Проверьте свои балансы, покупательную способность и статус Управление позициями - Посмотреть текущие позиции и их результаты
      • Распределение заказов** - размещение рыночных и лимитных заказов на естественном языке ** Управление заказами** - Список, отслеживание и отмена заказов

Предпосылки

Python 3.10+

  • Alpaca API ключи Клод для рабочего стола или другого клиента MCP

##Установка

  1. Клонировать это хранилище:

2.Установить необходимые пакеты:

  1. Создайте файл .env с вашими учетными данными API Alpaca:

Использование

Запуск сервера

Запустите сервер, запустив:

Настройка Claude для рабочего стола

1.Откройте Клод для рабочего стола 2.Перейти к настройкам 3. Нажмите «Разработчик», а затем «Редактировать конфигурацию» 4. Добавить конфигурацию сервера к claude_desktop_config.json:

5.Сохранить и перезапустить Клода для рабочего стола

Доступные инструменты

Эта страница переведена автоматически. Технические детали смотрите в оригинале.

README

Показан фрагмент оригинального 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

Открыть полный README на GitHub

Установка

This server does not publish a one-line install command.

Open the repository installation guide Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "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" } } } }