羊驼 MCP 服务器
将 Alpaca 市场数据和 Broker API 作为 MCP 工具公开。
安装
npm install alpaca-mcpRelated MCP server: Financial Datasets MCP Server
本地开发
git clone <repo-url>
cd alpaca-mcp
npm install环境变量
使用以下命令在项目根目录创建一个.env :
ALPACA_ENDPOINT=https://data.alpaca.markets
ALPACA_BROKER_ENDPOINT=https://broker-api.alpaca.markets
ALPACA_API_KEY=YOUR_ALPACA_API_KEY
ALPACA_SECRET_KEY=YOUR_ALPACA_SECRET_KEY命令
启动(dev):
npm start(运行npx tsx index.ts)构建:
npm run build(编译为dist/)运行编译好的:
node dist/index.js
用法
MCP 服务器运行后会监听 stdin/stdout。您可以使用任意 MCP 客户端或命令行工具:
npm link # optional
alpaca-mcp # starts server globally可用工具
获取资产
{ assetClass?: "us_equity" | "crypto" }获取股票条形图
{ symbols: string[]; start: string; end: string; timeframe: string }获取市场日
{ start: string; end: string }获取新闻
{ start: string; end: string; symbols: string[] }
每个都返回content[0].text中的 JSON 或错误。
MCP 客户端配置
要通过mcp.config.json集成,请在mcpServers键下添加以下内容:
{
"mcpServers": {
"alpaca-mcp": {
"command": "npx",
"args": [
"-y",
"alpaca-mcp"
],
"env": {
"ALPACA_ENDPOINT": "https://data.alpaca.markets",
"ALPACA_BROKER_ENDPOINT": "https://broker-api.alpaca.markets",
"ALPACA_API_KEY": "<YOUR_API_KEY>",
"ALPACA_SECRET_KEY": "<YOUR_SECRET_KEY>"
}
}
}
}
## Publishing
```bash
npm publish执照
国际学习中心
Resources
Looking for Admin?
Admins can modify the Dockerfile, update the server description, and track usage metrics. If you are the server author, to access the admin panel.