Logz.io的MCP服务器
 ](https://nodejs.org/) 
一 *非官方的* 模型上下文协议 (MCP)服务器,使克劳德等人工智能助手能够与 Logz.e。的日志管理平台。包括用于简单日志搜索、Lucene查询搜索和从Logz.io获取基本统计数据的工具。
🚀 快速开始
将以下内容添加到您的Claude/Cursor/etc配置文件中:
{
"mcpServers": {
# other servers ...
"logzio": {
"command": "npx",
"args": [
"-y",
"mcp-server-logzio",
"apiKey", "YOUR_LOGZIO_API_KEY"
]
}
}
}美国是默认地区。对于其他地区:
{
"mcpServers": {
# other servers ...
"logzio": {
"command": "npx",
"args": [
"-y",
"mcp-server-logzio",
"apiKey", "YOUR_LOGZIO_API_KEY",
"region", "eu" # add this for example
]
}
}
}🛠️ 高级配置
命令行参数
| 参数 | 描述 | 默认值 | 必填 |
|---|---|---|---|
apiKey | 您的Logz.io API密钥 | - | 是 |
region | Logz.io地区(美国、美国西部、欧盟、加拿大、澳大利亚、英国) | 美国 | 否 |
logzioUrl | 自定义Logz.io API URL(覆盖区域) | - | 否 |
--timeout | 请求超时 | 30000 | 否 |
--retry-attempts | 重试尝试 | 3 | 否 |
--max-results | 每次查询的最大结果 | 1000 | 否 |
支持的地区
服务器自动将区域代码映射到正确的Logz.io API端点:
| 区域代码 | 描述 | API端点 |
|---|---|---|
us | 美国东部(默认) | https://api.logz.io |
us-west | 美国西部 | https://api-wa.logz.io |
eu | 欧洲 | https://api-eu.logz.io |
ca | 加拿大 | https://api-ca.logz.io |
au | 澳大利亚 | https://api-au.logz.io |
uk | 联合王国 | https://api-uk.logz.io |
查找您的地区:登录您的Logz.io帐户并在浏览器中检查URL:
https://app.logz.io→ 使用区域ushttps://app-eu.logz.io→ 使用区域euhttps://app-ca.logz.io→ 使用区域ca- 等等
🔧 可用工具
这些是您的代理将看到的工具。
search_logs
使用简单的查询和过滤器搜索日志。
参数:
query(必填):搜索查询字符串timeRange:时间范围(1小时、6小时、12小时、24小时、3天、7天、30天)from/to:自定义时间范围(ISO 8601)logType:按日志类型筛选severity:按严重程度筛选limit:最大结果(1-1000)sort:排序顺序(asc/desc)
query_logs
使用Lucene查询进行更高级的搜索
参数:
luceneQuery(必填):Lucene查询字符串from/to:时间范围(ISO 8601)size:最大结果(1-1000)sort:排序顺序(asc/desc)
get_log_stats
检索聚合日志统计信息和指标。
参数:
timeRange:时间范围(1小时、6小时、12小时、24小时、3天、7天、30天)from/to:自定义时间范围(ISO 8601)groupBy:分组依据的字段
🏗️ 开发,如果你想弄乱代码
先决条件
- Node.js 24.14.0+
- TypeScript 5.8+
- 有效的Logz.io帐户和API密钥
设置
# Clone the repository
git clone https://github.com/jklnr/logzio-mcp-server.git
cd mcp-server-logzio
# Install dependencies
npm install
# Build the project
npm run build
# Run tests
npm test
# Run in development mode
npm run dev脚本
npm run build-编译TypeScriptnpm run dev-以开发模式运行npm test-运行测试套件npm run format-使用Prettier格式化代码npm run type-check-无排放的型式检查
📁 项目结构
mcp-server-logzio/
├── src/
│ ├── api/ # Logz.io API client and types
│ ├── tools/ # MCP tool implementations
│ ├── utils/ # Utilities (logging, errors)
│ ├── config.ts # Configuration management
│ ├── server.ts # MCP server implementation
│ └── index.ts # Entry point
├── tests/ # Test suites
├── examples/ # Usage examples
├── docs/ # Documentation
└── dist/ # Compiled output