gold-price-mcp
v1.0.1
Published
MCP server for tracking gold price fluctuations and sending email alerts when prices rise
Maintainers
Readme
🥇 Gold Price MCP Server
一个基于 Model Context Protocol (MCP) 的黄金价格查询和涨幅提醒服务器。支持 Claude Desktop、Cursor 等 AI 客户端。
✨ 功能
| 工具 | 说明 |
|------|------|
| get_gold_price | 获取当前/指定日期的黄金价格(支持多种货币) |
| get_gold_price_change | 查询黄金价格涨跌幅(对比 N 天前) |
| send_gold_alert_email | 涨幅超过阈值时自动发送邮件通知 |
🚀 快速开始
1. 获取 API Key
前往 GoldAPI.io 注册账号,获取免费 API Key(100 次/月)。
2. 安装 & 使用
方式一:npx 直接运行(推荐)
npx gold-price-mcp方式二:全局安装
npm install -g gold-price-mcp
gold-price-mcp3. 配置环境变量
| 变量 | 必须 | 说明 |
|------|------|------|
| GOLD_API_KEY | ✅ | GoldAPI.io 的 API Key |
| SMTP_HOST | 📧 | SMTP 服务器地址(如 smtp.qq.com) |
| SMTP_PORT | 📧 | SMTP 端口(如 465) |
| SMTP_USER | 📧 | 发件人邮箱 |
| SMTP_PASS | 📧 | SMTP 密码/授权码 |
📧 = 仅在使用邮件通知功能时需要
🔧 在 AI 客户端中配置
Claude Desktop
编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"gold-price": {
"command": "npx",
"args": ["-y", "gold-price-mcp"],
"env": {
"GOLD_API_KEY": "你的API Key",
"SMTP_HOST": "smtp.qq.com",
"SMTP_PORT": "465",
"SMTP_USER": "你的邮箱",
"SMTP_PASS": "你的授权码"
}
}
}
}Cursor
在 Cursor 设置的 MCP 部分添加:
{
"mcpServers": {
"gold-price": {
"command": "npx",
"args": ["-y", "gold-price-mcp"],
"env": {
"GOLD_API_KEY": "你的API Key"
}
}
}
}📖 工具使用示例
配置完成后,你可以直接对 AI 说:
- "查一下今天的黄金价格"
- "黄金最近 7 天涨了多少?"
- "如果黄金今天涨幅超过 2%,发邮件通知我 [email protected]"
- "用人民币显示今天的金价"
🏗️ 开发
# 克隆项目
git clone <your-repo-url>
cd mcp-test
# 安装依赖
npm install
# 编译
npm run build
# 测试(使用 MCP Inspector)
npx @modelcontextprotocol/inspector node build/index.js📄 License
MIT
