Skip to main content
Glama
tedlikeskix

Alpaca MCP Server

by tedlikeskix

羊驼 MCP 服务器

这是 Alpaca 的模型上下文协议 (MCP) 服务器,允许像 Claude 这样的法学硕士 (LLM) 与 Alpaca 交易 API 进行交互。它支持通过自然语言进行股票交易、查看持仓、获取市场数据和管理账户。

特征

  • 📊市场数据- 获取实时股票报价和历史价格数据

  • 💵账户信息- 检查您的余额、购买力和状态

  • 📈职位管理- 查看当前职位及其表现

  • 🛒订单下达- 通过自然语言下达市价单和限价单

  • 📋订单管理——列出、跟踪和取消订单

Related MCP server: Alpaca MCP Server

先决条件

  • Python 3.10+

  • 羊驼 API 密钥

  • Claude 桌面版或其他 MCP 客户端

安装

  1. 克隆此存储库:

    git clone https://github.com/YOUR_USERNAME/alpaca-mcp.git
    cd alpaca-mcp
  2. 安装所需的软件包:

    pip install mcp alpaca-py python-dotenv
  3. 使用您的 Alpaca API 凭证创建一个.env文件:

    API_KEY_ID=your_alpaca_api_key
    API_SECRET_KEY=your_alpaca_secret_key

用法

运行服务器

通过运行以下命令启动服务器:

python alpaca_mcp_server.py

为桌面配置 Claude

  1. 打开 Claude 桌面版

  2. 前往“设置”

  3. 点击“开发者”,然后点击“编辑配置”

  4. 将服务器配置添加到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. 保存并重新启动 Claude for Desktop

可用工具

该服务器公开以下工具:

  • get_account_info() - 获取账户余额和状态

  • get_positions() - 列出投资组合中的所有当前头寸

  • get_stock_quote(symbol) - 获取股票的最新报价

  • get_stock_bars(symbol, days) - 获取股票的历史价格条

  • get_orders(status, limit) - 列出指定状态的订单

  • place_market_order(symbol, side, quantity) - 下达市价订单

  • place_limit_order(symbol, side, quantity, limit_price) - 下限价单

  • cancel_all_orders() - 取消所有未结订单

  • close_all_positions(cancel_orders) - 关闭所有未平仓头寸

示例查询

一旦服务器连接到 Claude,您就可以询问以下问题:

  • “我目前的账户余额和购买力是多少?”

  • “显示我当前的位置”

  • “获取 AAPL 的最新报价”

  • “显示过去 10 天 TSLA 的价格历史记录”

  • “以市场价格购买 5 股 MSFT 股票”

  • “以 130 美元的限价卖出 10 股 AMZN”

  • “取消我所有未完成的订单”

笔记

此服务器默认使用 Alpaca 的模拟交易。如需使用真实货币交易,请在TradingClient初始化过程中将paper=True更改为paper=False

安全声明

此 MCP 服务器将访问您的 Alpaca 账户并进行真实交易。在批准任何交易之前,请务必查看 Claude 的建议。

执照

麻省理工学院

A
license - permissive license
Not graded
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    B
    maintenance
    A server that implements the Model Context Protocol for Schwab API, allowing access to account information, positions, stock quotes, and order/transaction history designed for integration with Large Language Models.
    58
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables LLMs like Claude to interact with the Alpaca trading API, allowing for trading stocks, checking positions, fetching market data, and managing accounts through natural language.
    3
    MIT
  • A
    license
    A
    quality
    D
    maintenance
    A Model Context Protocol server that interfaces with Alpaca trading API, allowing users to manage portfolios, place trades, and access market data through natural language interactions.
    8
    36
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    An MCP server implementation for Alpaca's Trading API that enables LLMs to interact with Alpaca's trading infrastructure using natural language, supporting stock, options, and crypto trading, portfolio management, watchlists, and market data.
    4
    MIT

View all related MCP servers

Related MCP Connectors

  • A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…

  • MCP server for OpenMM — exposes market data, account, trading, and strategy tools to AI agents

  • A Model Context Protocol server for Wix AI tools

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/tedlikeskix/alpaca-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server