简单 Loki MCP 服务器是一个 模型上下文协议 (MCP) 接口,可借助 logcli 对 Grafana Loki 日志进行查询。它让 AI 助手能够直接访问并分析 Loki 的日志数据,为日志处理和分析带来便利。
本服务器允许你通过 logcli 对 Grafana Loki 日志进行查询,让 AI 助手能直接访问和分析日志数据。你可依据以下步骤进行安装和使用。
logcli 环境不可用时自动回退到 HTTP API。logcli 不可用,服务器将自动使用 Loki HTTP API。要通过 Smithery 自动安装 Simple Loki MCP Server for Claude Desktop,可执行以下命令:
npx -y @smithery/cli install @ghrud92/simple-loki-mcp --client claude
在配置文件中添加如下内容:
{
"mcpServers": {
"simple-loki": {
"command": "npx",
"args": ["-y", "simple-loki-mcp"],
"env": {
"LOKI_ADDR": "https://loki.sup.band"
}
}
}
}
按以下步骤操作:
git clone https://github.com/ghrud92/simple-loki-mcp.git
cd simple-loki-mcp
npm install
simple-loki用于查询和分析 Loki 日志。
--addr 或 -a:指定 Loki 服务器的地址(默认值:http://localhost:3100)。--query 或 -q:要执行的日志查询。