暴露 Alpaca 市场数据及经纪商 API 作为 MCP 工具。
要通过 Smithery 自动安装 Alpaca 市场数据服务器到 Claude Desktop:
npx -y @smithery/cli install @cesarvarela/alpaca-mcp --client claude
npm install alpaca-mcp
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
npm start (运行 npx tsx index.ts)npm run build (编译到 dist/)node dist/index.js运行后,MCP 服务器监听标准输入/输出。可以使用任何 MCP 客户端或 CLI:
npm link # 可选
alpaca-mcp # 全局启动服务器
{ assetClass?: "us_equity" | "crypto" }{ symbols: string[]; start: string; end: string; timeframe: string }{ start: string; end: string }{ start: string; end: string; symbols: string[] }每个工具返回 JSON 格式的数据在 content[0].text 中,或者返回错误信息。
要在 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>"
}
}
}
}
npm publish
ISC