内容
# HumioMCP
Humio 查询服务器,用于查询 Humio/LogScale 仪表盘和执行搜索查询。
使用 [FastMCP](https://github.com/modelcontextprotocol/python-sdk) (Python) 构建。
## 功能
- **列出仪表盘** — 列出 Humio 仓库/视图中的所有仪表盘,可选名称过滤
- **获取仪表盘查询** — 从仪表盘的小部件中提取所有搜索查询(带时间范围)
- **执行搜索** — 运行搜索查询并以 JSON 格式获取结果(默认限制:200 个事件)
- 通过 TOML 配置支持多集群
- 支持相对时间(`24h`、`7d`)和 ISO 8601(`2024-01-01T00:00:00Z`)
---
## 快速入门
### 选项 A:单击 VS Code 配置(推荐)
无需克隆。添加以下内容到您的 VS Code `settings.json` 或 `.vscode/mcp.json`:
```json
{
"servers": {
"humio-mcp": {
"type": "stdio",
"command": "uvx",
"args": [
"--from", "git+https://github.com/weihong-xu-hpe/humio-mcp.git",
"humio-mcp"
],
"env": {
"HUMIO_MCP_CONFIG": "${userHome}/.config/humio-mcp/config.toml"
}
}
}
}
```
然后在 `~/.config/humio-mcp/config.toml` 处创建配置文件:
```toml
default_cluster = "us-west-2"
[clusters.us-west-2]
url = "https://your-humio-url.example.com/logs"
token = "your-api-token"
```
就这样 — `uvx` 自动处理安装和更新。
> **前提条件:** [uv](https://docs.astral.sh/uv/getting-started/installation/) 必须已安装(`brew install uv` 或 `curl -LsSf https://astral.sh/uv/install.sh | sh`)
### 选项 B:克隆并在本地运行
```bash
git clone https://github.com/weihong-xu-hpe/humio-mcp.git
cd humio-mcp
uv sync
cp config.example.toml config.toml
# 编辑 config.toml 以配置集群 URL 和 API 令牌
```
用于本地克隆的 VS Code 配置:
```json
{
"servers": {
"humio-mcp": {
"type": "stdio",
"command": "uv",
"args": ["run", "--directory", "/path/to/HumioMCP", "mcp", "run", "src/humio_mcp/server.py"]
}
}
}
```
### 选项 C:Claude Desktop
添加以下内容到 `~/Library/Application Support/Claude/claude_desktop_config.json`:
```json
{
"mcpServers": {
"humio-mcp": {
"command": "uvx",
"args": [
"--from", "git+https://github.com/weihong-xu-hpe/humio-mcp.git",
"humio-mcp"
],
"env": {
"HUMIO_MCP_CONFIG": "/Users/yourname/.config/humio-mcp/config.toml"
}
}
}
}
```
---
## 配置
编辑 `config.toml`(或 `~/.config/humio-mcp/config.toml`):
```toml
default_cluster = "us-west-2"
[clusters.us-west-2]
url = "https://mira-us-west-2.cloudops.ccs.arubathena.com/logs"
token = "your-api-token"
[clusters.eu-central-1]
url = "https://mira-eu-central-1.example.com/logs"
token = "another-token"
```
配置搜索顺序:
1. `HUMIO_MCP_CONFIG` 环境变量
2. `./config.toml`
3. `~/.config/humio-mcp/config.toml`
## 开发
```bash
# MCP Inspector(交互式调试)
uv run mcp dev src/humio_mcp/server.py
# 标准输入/输出模式
uv run mcp run src/humio_mcp/server.py
```
## 工具
### 列出仪表盘
| 参数 | 类型 | 必需 | 描述 |
|-------|------|----------|-------------|
| 仓库 | 字符串 | 是 | 仓库/视图名称 |
| 集群 | 字符串 | 否 | 集群名称(默认为配置中的集群) |
| 搜索过滤器 | 字符串 | 否 | 按名称子字符串过滤 |
### 获取仪表盘查询
| 参数 | 类型 | 必需 | 描述 |
|-------|------|----------|-------------|
| 仓库 | 字符串 | 是 | 仓库/视图名称 |
| 仪表盘名称 | 字符串 | 是 | 仪表盘名称 |
| 集群 | 字符串 | 否 | 集群名称 |
### 执行搜索
| 参数 | 类型 | 必需 | 描述 |
|-------|------|----------|-------------|
| 仓库 | 字符串 | 是 | 仓库/视图名称 |
| 查询字符串 | 字符串 | 是 | Humio 搜索查询 |
| 开始时间 | 字符串 | 否 | 开始时间(默认为 `24h`) |
| 结束时间 | 字符串 | 否 | 结束时间(默认为 `now`) |
| 集群 | 字符串 | 否 | 集群名称 |