TA

tedlikeskix/alpaca-mcp-server

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

28 stars 21 forks 品質 66 トレンド 0MIT

Alpaca取引API用のモデルコンテキストプロトコル(MCP)サーバー

概要

これは、Alpaca 用のモデルコンテキストプロトコル (MCP) サーバーで、Claude のような LLM が Alpaca 取引 API と相互作用できるようにします。 取引株式を有効化し、ポジションの確認、市場データの取得、アカウント管理が可能です。 - リアルタイムの株価情報と履歴価格データを取得する - 残高をチェックし、電力を購入し、ステータス - ✓ - 現在のポジションとパフォーマンスを表示 - トレーダー - 自然言語による市場と注文を制限 - リスト、トラック、および注文をキャンセル - Python 3.10 + - Alpaca API キー - デスクトップまたは別のMCPクライアントのClaude 3。 Alpaca API 認証情報で .env ファイルを作成します。 1。 デスクトップ2用のClaudeを開きます。 設定3に移動します。 「開発者」をクリックし、「Configを編集」4をクリックします。 サーバ設定を claude desktop config に追加します.

概要(AI 翻訳)

これは、Alpaca 用のモデルコンテキストプロトコル (MCP) サーバーで、Claude のような LLM が Alpaca 取引 API と相互作用できるようにします。 取引株式を有効化し、ポジションの確認、市場データの取得、アカウント管理が可能です。

##特徴

  • 市場データ** - リアルタイムの株式引用符と歴史的価格データを取得する
  • 💡アカウント情報 - 残高の確認、電力購入、ステータスの確認
  • ✓Position Management - 現在の位置とその性能を表示
  • 月 * オーダー プレースメント** - 自然な言語による市場と限界の発注を置いて下さい
  • 注文を注文する** - リスト、トラック、およびキャンセル

前提条件

  • Python 3.10 +
  • Alpaca API キー
  • デスクトップまたは別のMCPクライアントのClaude

インストール

  1. このリポジトリをクローンする:

  2. 必要なパッケージを取付けて下さい:

3。 [.env]ファイルをAlpaca APIの認証情報で作成します。

使用法

サーバーの実行

実行してサーバーを起動します。

デスクトップ用のClaudeの設定

  1. デスクトップのための開いたクロード
  2. 設定に移動
  3. 「Developer」をクリックし、「Config」を編集
  4. [claude_desktop_config.json にサーバー構成を追加します。

5。 デスクトップ用のClaudeを保存して再起動します

利用可能なツール

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

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

GitHub で README 全文を見る

インストール

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