Humio/LogScale MCP服务器
用于Humio/LogScale日志分析的企业级MCP(模型上下文协议)服务器。该服务器使AI助手能够安全地查询和分析Humio/LogScale实例的日志。
特性
- MCP协议支持:用于AI助手集成的完整MCP工具实施
- 双重运输:Stdio用于CLI客户端,HTTP-SSE用于web客户端
- 已保存搜索执行:使用参数支持执行已保存/计划的搜索
- 架构发现:检索字段架构以获得查询帮助
- 健康监测:内置健康检查和连接监控
- 多个身份验证后端:环境变量(完整),带Vault/K8s/AWS/Azure存根
- 安全第一:输入验证、查询净化、机密过滤
- 审计日志:仅附加合规性审计跟踪
- Kubernetes就绪:健康探测、优雅关机、Helm chart
快速开始
先决条件
- 转到1.23或更高版本
- Humio/LogScale实例
- 具有适当权限的API令牌
安装
# Clone the repository
git clone https://github.com/your-org/humio-mcp.git
cd humio-mcp
# Build
make build
# Run
export HUMIO_TOKEN="your-api-token"
./bin/humio-mcp --config config/config.example.yaml配置
复制示例配置并自定义:
cp config/config.example.yaml config/config.yaml关键配置选项:
server:
transport: stdio # or "http-sse" for HTTP transport
humio:
url: "https://cloud.humio.com"
repository: "your-repository"
auth:
provider: env
token_env_var: "HUMIO_TOKEN"运输方式
标准(默认)
基于CLI的MCP客户端的标准输入/输出传输:
./bin/humio-mcp --config config/config.example.yamlHTTP-SSE
基于web的客户端的HTTP服务器发送事件传输:
# Use the HTTP-SSE config
./bin/humio-mcp --config config/config.http-sse.yamlHTTP-SSE服务器公开:
/mcp/sse-MCP消息的SSE端点/mcp/message-客户端请求的消息端点/healthz-活体探针/readyz-准备就绪探针/metrics-普罗米修斯指标
客户端连接示例:
const eventSource = new EventSource('http://localhost:8080/mcp/sse');
eventSource.onmessage = (event) => {
const message = JSON.parse(event.data);
console.log('Received:', message);
};MCP工具
execute_saved_search
在Humio/LogScale中执行已保存的搜索。
参数:
name(必填):保存的搜索的名称或IDrepository:要查询的存储库(如果未指定,则使用默认值)start:开始时间(例如,“24小时”、“7天”或ISO 8601)end:结束时间(例如,“现在”或ISO 8601)parameters:要传递给已保存搜索的参数
get_saved_search
列出存储库中所有已保存的搜索。
参数:
repository:用于列出搜索的存储库
get_search_schema
获取存储库的字段架构。
参数:
repository:要从中获取架构的存储库
健康检查
检查Humio连接的健康状况。
参数: 无
码头工人
# Build image
make docker
# Run with docker-compose
docker-compose -f deploy/docker-compose.yaml upKubernetes部署
# Using Helm
helm install humio-mcp ./deploy/helm \
--set config.humio.url=https://your-humio.example.com \
--set config.humio.repository=your-repo \
--set existingSecret=your-humio-secret发展
# Run tests
make test
# Run linter
make lint
# Format code
make fmt
# Run all checks
make verify项目结构
.
├── cmd/ # Application entrypoint
├── internal/
│ ├── audit/ # Audit logging
│ ├── auth/ # Authentication providers
│ ├── config/ # Configuration management
│ ├── humio/ # Humio API client
│ ├── k8s/ # Kubernetes integration
│ ├── mcp/ # MCP server and tools
│ ├── observability/ # Logging and metrics
│ └── security/ # Security utilities
├── config/ # Configuration examples
└── deploy/
├── docker/ # Docker files
├── helm/ # Kubernetes Helm chart
└── systemd/ # Systemd service files安全
- 所有输入都经过验证和消毒
- 从日志中编辑敏感数据
- TLS 1.3支持安全连接
- 合规性审计日志
- 非根容器执行
许可证
MIT许可证-有关详细信息,请参阅许可证文件。
