羊驼 MCP 服务器
这是 Alpaca 的模型上下文协议 (MCP) 服务器,允许像 Claude 这样的法学硕士 (LLM) 与 Alpaca 交易 API 进行交互。它支持通过自然语言进行股票交易、查看持仓、获取市场数据和管理账户。
特征
- 📚 Alpaca 文档- 访问 Alpaca SDK 文档进行构建
- 📊市场数据- 获取实时股票报价和历史价格数据
- 💵账户信息- 检查您的余额、购买力和状态
- 📈职位管理- 查看当前职位及其表现
- 🛒订单下达- 通过自然语言下达市价单和限价单
- 📋订单管理——列出、跟踪和取消订单
先决条件
- Python 3.10+
- 羊驼 API 密钥
- Claude 桌面版或其他 MCP 客户端
安装
- 克隆此存储库:
- 安装所需的软件包:
- 使用您的 Alpaca API 凭证创建一个
.env
文件:
用法
运行服务器
通过运行以下命令启动服务器:
为桌面配置 Claude
- 打开桌面版 Claude
- 前往“设置”
- 点击“开发者”,然后点击“编辑配置”
- 将服务器配置添加到
claude_desktop_config.json
:
- 保存并重新启动 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 的建议。
执照
麻省理工学院
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
模型上下文协议服务器使 Claude 等 LLM 能够与 Alpaca 交易 API 进行交互,从而允许通过自然语言进行股票交易、检查头寸、获取市场数据和管理账户。
Related MCP Servers
- AsecurityAlicenseAqualityA Model Context Protocol server that gives LLMs the ability to interact with Ethereum networks, manage wallets, query blockchain data, and execute smart contract operations through a standardized interface.Last updated -313232TypeScriptMIT License
- -securityFlicense-qualityA Model Context Protocol server that enables Claude and other LLMs to interact with Notion workspaces, providing capabilities like searching, retrieving, creating and updating pages, as well as managing databases.Last updated -1942TypeScript
- -securityAlicense-qualityA 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.Last updated -PythonMIT License
- AsecurityAlicenseAqualityA Model Context Protocol server that enables LLMs like Claude to interact with the Nostr social network, allowing for fetching user profiles, text notes, and zap payment information.Last updated -525TypeScriptMIT License