关于 Alpaca MCP Server
配置
本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。
工具
还没有获取到工具列表
本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。
详细介绍
Alpaca MCP 服务
一个通过 Alpaca API 实时访问加密货币市场数据的模型上下文协议(MCP)服务。此服务提供用于检索加密货币数据的标准化接口。
功能
- 加密货币日、周和月时间序列数据
- 最新加密货币汇率
- 历史柱状图/蜡烛图数据
- 内置错误处理和速率限制管理
安装
使用 Claude Desktop
通过 Docker 安装
- 克隆仓库并构建本地镜像,供 Claude 桌面客户端使用
cd alpaca-mcp
docker build -t mcp/alpaca .
- 修改
claude_desktop_config.json,使其符合以下内容,并将REPLACE_API_KEY和REPLACE_API_SECRET替换为你的实际密钥:
claude_desktop_config.json路径
- 在 MacOS 上:
~/Library/Application\ Support/Claude/claude_desktop_config.json- 在 Windows 上:
%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"alpaca": {
"command": "docker",
"args": [
"run",
"-i",
"-e",
"ALPACA_API_KEY",
"-e",
"ALPACA_API_SECRET",
"mcp/alpaca"
],
"env": {
"ALPACA_API_KEY": "REPLACE_API_KEY",
"ALPACA_API_SECRET": "REPLACE_API_SECRET"
}
}
}
}
通过 UV 安装(快速 Python 包安装程序)
UV 是一款现代 Python 包安装程序,可简化安装流程。要将 UV 与 alpaca-mcp 配合使用:
- 首先,如果尚未安装 安装 UV:
# Using pip
pip install uv
# Using brew on macOS
brew install uv
- 配置 Claude Desktop 配置文件以使用 UV:
{
"mcpServers": {
"alpaca": {
"command": "uv",
"args": [
"--directory",
"/path/to/alpaca-mcp",
"run",
"alpaca-mcp"
],
"env": {
"ALPACA_API_KEY": "REPLACE_API_KEY",
"ALPACA_API_SECRET": "REPLACE_API_SECRET"
}
}
}
}
- 使用 UV 安装软件包:
# Clone the repository
git clone https://github.com/berlinbra/alpaca-mcp.git
cd alpaca-mcp
# Install dependencies using UV
uv pip install -e .
- 使用 UV 运行服务:
uv run alpaca_mcp/server.py
- 如需调试,可使用 MCP 检查器:
npx @modelcontextprotocol/inspector uv --directory /path/to/alpaca-mcp run src/alpaca_mcp/server.py
标准开发设置
# Clone the repository
git clone https://github.com/berlinbra/alpaca-mcp.git
cd alpaca-mcp
# Create and activate a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install the package in development mode
pip install -e .
可用工具
目前,服务实现了以下工具:
get-crypto-bars:获取加密货币的历史柱状图/蜡烛图数据
未来将添加更多工具。
get-crypto-bars
输入架构:
{
"symbol": {
"type": "string",
"description": "Cryptocurrency symbol (e.g., BTC/USD, ETH/USD)"
},
"timeframe": {
"type": "string",
"description": "Timeframe for bars (e.g., 1Day, 1Hour, 1Min)",
"default": "1Day"
},
"start": {
"type": "string",
"description": "Start date in YYYY-MM-DD format"
},
"limit": {
"type": "integer",
"description": "Maximum number of bars to return",
"default": 10
}
}
响应示例:
Cryptocurrency bars for BTC/USD (1Day):
Date: 2025-04-10
Open: $68750.12
High: $69200.45
Low: $67900.78
Close: $68900.32
Volume: 12345.67
---
Date: 2025-04-11
Open: $68900.32
High: $70100.55
Low: $68400.21
Close: $69800.44
Volume: 15678.90
错误处理
服务针对多种情况提供了全面的错误处理:
- 超出速率限制
- API 密钥无效
- 网络连接问题
- 超时处理
- 响应格式错误
错误消息以清晰易懂的格式返回。
前提条件
- Python 3.12 或更高版本
- httpx
- mcp
- alpaca-py
- python-dotenv(用于加载环境变量)
许可证
此 MCP 服务采用 MIT 许可证。
评论
支持 Markdown
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。