LA

laukikk/alpaca-mcp

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

35 stars 15 forks 质量 63 趋势 0MIT

laukikk/alpaca-mcp 是从 https://github.com/laukikk/alpaca-mcp. 导入的 MCP 服务器候选

概览

laukikk/alpaca-mcp 是从 https://github.com/laukikk/alpaca-mcp. 导入的 MCP 服务器候选

概述(AI 翻译)

一个模型上下文协议(MCP)服务器,提供与Alpaca交易API的接口,允许您管理股票和加密投资组合、下单交易并访问市场数据。

特色

  • 账户管理:查看账户详情、余额及投资组合状态
  • 交易:下卖、限价、止损和止损限价单
  • 投资组合管理:查看头寸、计算表现及平仓
  • 市场数据:获取实时报价和历史价格数据
  • 资产信息:获取可交易资产的详细信息

安装

通过Smithery安装

通过Smithery自动安装Alpaca Trading MCP Server用于Claude Desktop:

手动安装

  1. 克隆此仓库
  2. 安装依赖:

或者用紫外线:

配置

  1. 将.env.example文件复制到.env:

  2. 将您的羊驼纸币交易API凭证添加到.env文件中:

您可以通过在Alpaca注册账户来获取这些凭证。

用途

运行MCP服务器:

服务器将启动并供MCP客户端连接。

用Claude桌面测试

配置:

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

Alpaca Trading MCP Server

A Model Context Protocol (MCP) server that provides an interface to the Alpaca trading API, allowing you to manage your stock and crypto portfolio, place trades, and access market data.

Features

  • Account Management: View account details, balances, and portfolio status
  • Trading: Place market, limit, stop, and stop-limit orders
  • Portfolio Management: View positions, calculate performance, and close positions
  • Market Data: Access real-time quotes and historical price data
  • Asset Information: Get details about tradable assets

Installation

Installing via Smithery

To install Alpaca Trading MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @laukikk/alpaca-mcp --client claude

Manual Installation

  1. Clone this repository
  2. Install dependencies:
pip install -e .

Or using uv:

uv pip install -e .

Configuration

  1. Copy the .env.example file to .env:
cp .env.example .env
  1. Add your Alpaca Paper Trading API credentials to the .env file:
ALPACA_PAPER_API_KEY = "your-api-key"
ALPACA_PAPER_API_SECRET = "your-api-secret"

You can obtain these credentials by creating an account at Alpaca.

Usage

Run the MCP server:

python src/server.py

The server will start and be available for MCP clients to connect to.

Testing with Claude for Desktop

Configuration:

Open your Claude for Desktop App configuration in a text editor. Create the file if it doesn’t exist.

  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Mac: ~/Library/Application\ Support/Claude/claude_desktop_config.json

Add the Alpaca MCP server configuration:

{
    "mcpServers": {
        "alpaca": {
            "command": "uv",
            "args": [
                "--directory",
                "/ABSOLUTE/PATH/TO/PARENT/FOLDER/alpaca-mcp-server",
                "run",
                "src/server.py"
            ]
        }
    }
}

MCP For Server Developers: Quickstart

Available Resources

The server provides the following resources:

  • account://info - Get current account information
  • positions://all - Get all current positions
  • positions://{symbol} - Get position details for a specific symbol
  • orders://recent/{limit} - Get most recent orders with specified limit
  • market://{symbol}/quote - Get current market quote for a specific symbol
  • market://{symbol}/bars/{timeframe} - Get historical price bars for a symbol with specified timeframe
  • assets://list - List tradable assets available on Alpaca
  • assets://{symbol} - Get detailed asset information by symbol

Available Tools

在 GitHub 查看完整 README

安装

npx -y @smithery/cli install @laukikk/alpaca-mcp --client claude
新手?先看 mcpskill.org 教程 →

配置

{ "mcpServers": { "alpaca": { "command": "uv", "args": [ "--directory", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/alpaca-mcp-server", "run", "src/server.py" ] } } }