羊驼MCP服务器
一种模型上下文协议(MCP)服务器,通过 API羊驼该服务器实现了用于检索加密货币数据的标准化接口。
特性
- 每日、每周和每月的加密货币时间序列数据
- 最新加密货币汇率
- 历史柱状图/蜡烛图数据
- 内置错误处理和速率限制管理
安装
使用克劳德桌面
通过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 如果你还没有:
# 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"
}
}
}
}- 安装带有紫外线的包装:
# 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:获取加密货币的历史柱状图/蜡烛图数据
未来将添加更多工具。
获取加密酒吧
输入架构:
{
"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
- 主控程序
- 羊驼皮
- python dotenv(用于加载环境变量)
许可证
此MCP服务器根据MIT许可证获得许可。

