部署指南.md•4.45 kB
# Random.org MCP Server - 部署指南
## 🚀 快速部署(5分钟上手)
### 第一步:安装
```bash
# 推荐:全局安装
npm install -g random-org-mcp-server
# 或者:直接使用(无需安装)
npx random-org-mcp-server
```
### 第二步:获取API密钥
1. 访问 [api.random.org](https://api.random.org/api-keys/beta)
2. 免费注册并获取API密钥
### 第三步:配置Claude Desktop
1. 打开Claude Desktop配置文件:
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Linux**: `~/.config/Claude/claude_desktop_config.json`
2. 添加配置:
```json
{
"mcpServers": {
"random-org": {
"command": "npx",
"args": ["random-org-mcp-server"],
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here"
}
}
}
}
```
3. 重启Claude Desktop
### 第四步:测试
在Claude中尝试:
- "生成5个1到100之间的随机数"
- "生成3个UUID"
- "生成一个8位随机密码"
## 📋 详细部署选项
### 选项1:NPX方式(推荐新手)
**优点**:无需安装,始终使用最新版本
```json
{
"mcpServers": {
"random-org": {
"command": "npx",
"args": ["random-org-mcp-server"],
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here"
}
}
}
}
```
### 选项2:全局安装(推荐生产环境)
```bash
npm install -g random-org-mcp-server
```
配置:
```json
{
"mcpServers": {
"random-org": {
"command": "random-org-mcp",
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here"
}
}
}
}
```
### 选项3:项目本地安装
```bash
mkdir my-mcp-project
cd my-mcp-project
npm init -y
npm install random-org-mcp-server
```
配置:
```json
{
"mcpServers": {
"random-org": {
"command": "node",
"args": ["node_modules/random-org-mcp-server/dist/index.js"],
"cwd": "/path/to/my-mcp-project",
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here"
}
}
}
}
```
## ⚙️ 高级配置
### 完整环境变量配置
```json
{
"mcpServers": {
"random-org": {
"command": "npx",
"args": ["random-org-mcp-server"],
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here",
"RATE_LIMIT_REQUESTS_PER_SECOND": "1",
"RATE_LIMIT_BURST_SIZE": "5",
"REQUEST_TIMEOUT_MS": "10000",
"MAX_RETRIES": "3",
"RETRY_DELAY_MS": "1000"
}
}
}
}
```
### 多个MCP服务器配置
```json
{
"mcpServers": {
"random-org": {
"command": "npx",
"args": ["random-org-mcp-server"],
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here"
}
},
"other-server": {
"command": "npx",
"args": ["other-mcp-server"]
}
}
}
```
## 🔧 故障排除
### 常见问题
#### 1. "命令未找到"错误
```bash
# 检查是否正确安装
npm list -g random-org-mcp-server
# 重新安装
npm install -g random-org-mcp-server
```
#### 2. API密钥错误
- 确保API密钥正确复制
- 检查是否有额外的空格或换行符
- 验证API密钥是否有效
#### 3. 连接超时
```json
{
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here",
"REQUEST_TIMEOUT_MS": "30000"
}
}
```
#### 4. 速率限制
```json
{
"env": {
"RANDOM_ORG_API_KEY": "your_api_key_here",
"RATE_LIMIT_REQUESTS_PER_SECOND": "0.5"
}
}
```
### 调试模式
```bash
# 手动运行服务器查看日志
npx random-org-mcp-server
# 或者全局安装后
random-org-mcp
```
## 🔄 更新
### 更新到最新版本
```bash
# 如果使用全局安装
npm update -g random-org-mcp-server
# 如果使用npx,会自动使用最新版本
npx random-org-mcp-server
```
### 检查版本
```bash
npm view random-org-mcp-server version
```
## 🎯 最佳实践
1. **使用npx**:对于大多数用户,推荐使用npx方式
2. **API密钥安全**:不要在公共代码中暴露API密钥
3. **速率限制**:遵守API使用限制,避免过于频繁的请求
4. **监控使用量**:定期检查API配额使用情况
5. **备份配置**:保存好Claude Desktop配置文件
## 📞 获取帮助
- **GitHub Issues**: [提交问题](https://github.com/QianJue-CN/TRUERandomMCP/issues)
- **npm页面**: [查看包信息](https://www.npmjs.com/package/random-org-mcp-server)
- **API文档**: [Random.org API](https://api.random.org/json-rpc/4)